diff options
author | Shauren <shauren.trinity@gmail.com> | 2024-01-29 16:57:07 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2024-01-29 16:57:07 +0100 |
commit | 00cb775558d19209630850bb148748ed4c3836c7 (patch) | |
tree | cb3785f891811a03b1f2b2d25045455b1c4ee240 /src/server/game/Loot | |
parent | 924efc89b2668d390bf768ccd936cc67e4a77f5d (diff) |
Core/Loot: Fixed items some not being lootable on second opening of a lootable item
Diffstat (limited to 'src/server/game/Loot')
-rw-r--r-- | src/server/game/Loot/LootItemStorage.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/server/game/Loot/LootItemStorage.cpp b/src/server/game/Loot/LootItemStorage.cpp index 152afcc2e76..9dc8cae1de6 100644 --- a/src/server/game/Loot/LootItemStorage.cpp +++ b/src/server/game/Loot/LootItemStorage.cpp @@ -169,6 +169,25 @@ bool LootItemStorage::LoadStoredLoot(Item* item, Player* player) } } + if (!loot->items.empty()) + { + std::sort(loot->items.begin(), loot->items.end(), [](LootItem const& left, LootItem const& right) { return left.LootListId < right.LootListId; }); + + uint32 lootListId = 0; + // add dummy loot items to ensure items are indexable by their LootListId + while (loot->items.size() <= loot->items.back().LootListId) + { + if (loot->items[lootListId].LootListId != lootListId) + { + auto li = loot->items.emplace(loot->items.begin() + lootListId); + li->LootListId = lootListId; + li->is_looted = true; + } + + ++lootListId; + } + } + // Mark the item if it has loot so it won't be generated again on open item->m_loot.reset(loot); item->m_lootGenerated = true; @@ -332,7 +351,7 @@ void StoredLootContainer::RemoveItem(uint32 itemId, uint32 count, uint32 itemInd auto bounds = _lootItems.equal_range(itemId); for (auto itr = bounds.first; itr != bounds.second; ++itr) { - if (itr->second.Count == count) + if (itr->second.ItemIndex == itemIndex) { _lootItems.erase(itr); break; |