mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-20 18:10:02 +01:00
[Performance] Look object stack
This commit is contained in:
parent
82114fdfff
commit
3abce62bba
@ -249,16 +249,17 @@ bool LootObject::IsLootPossible(Player* bot)
|
|||||||
|
|
||||||
bool LootObjectStack::Add(ObjectGuid guid)
|
bool LootObjectStack::Add(ObjectGuid guid)
|
||||||
{
|
{
|
||||||
|
if (availableLoot.size() >= MAX_LOOT_OBJECT_COUNT) {
|
||||||
|
availableLoot.shrink(time(nullptr) - 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (availableLoot.size() >= MAX_LOOT_OBJECT_COUNT) {
|
||||||
|
availableLoot.clear();
|
||||||
|
}
|
||||||
|
|
||||||
if (!availableLoot.insert(guid).second)
|
if (!availableLoot.insert(guid).second)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (availableLoot.size() < MAX_LOOT_OBJECT_COUNT)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
std::vector<LootObject> ordered = OrderByDistance();
|
|
||||||
for (size_t i = MAX_LOOT_OBJECT_COUNT; i < ordered.size(); i++)
|
|
||||||
Remove(ordered[i].guid);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user