diff --git a/src/LootObjectStack.cpp b/src/LootObjectStack.cpp index 4a047a16..23324da8 100644 --- a/src/LootObjectStack.cpp +++ b/src/LootObjectStack.cpp @@ -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 ordered = OrderByDistance(); - for (size_t i = MAX_LOOT_OBJECT_COUNT; i < ordered.size(); i++) - Remove(ordered[i].guid); - return true; }