mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
[Performance] Look object stack
This commit is contained in:
@@ -249,16 +249,17 @@ bool LootObject::IsLootPossible(Player* bot)
|
||||
|
||||
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)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user