Fix lootable items re-fill when not really empty

This commit is contained in:
Yehonal
2018-02-06 22:15:35 +00:00
parent 9e680b4aed
commit a6e91bc4ac
4 changed files with 19 additions and 12 deletions

View File

@@ -57,7 +57,7 @@ void LootItemStorage::RemoveEntryFromDB(uint32 containerId, uint32 itemid, uint3
CharacterDatabase.CommitTransaction(trans);
}
void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* /*player*/)
{
if (lootItemStore.find(loot->containerId) != lootItemStore.end())
{
@@ -88,8 +88,11 @@ void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
if (!loot->isLooted())
for (LootItemList::const_iterator li = loot->items.begin(); li != loot->items.end(); li++)
{
if (!li->AllowedForPlayer(player))
continue;
// Even if an item is not available for a specific player, it doesn't mean that
// we are not able to trade this container to another player that is able to loot that item
// if we don't save it then the item will be lost at player re-login.
//if (!li->AllowedForPlayer(player))
// continue;
const ItemTemplate* itemTemplate = sObjectMgr->GetItemTemplate(li->itemid);
if (!itemTemplate || itemTemplate->IsCurrencyToken())
@@ -148,7 +151,7 @@ bool LootItemStorage::LoadStoredLoot(Item* item)
return true;
}
void LootItemStorage::RemoveStoredLootItem(uint32 containerId, uint32 itemid, uint32 count)
void LootItemStorage::RemoveStoredLootItem(uint32 containerId, uint32 itemid, uint32 count, Loot *loot)
{
LootItemContainer::iterator itr = lootItemStore.find(containerId);
if (itr == lootItemStore.end())
@@ -163,11 +166,13 @@ void LootItemStorage::RemoveStoredLootItem(uint32 containerId, uint32 itemid, ui
break;
}
if (itemList.empty())
// loot with empty itemList but unlootedCount > 0
// must be deleted manually by the player or traded
if (!loot->unlootedCount)
lootItemStore.erase(itr);
}
void LootItemStorage::RemoveStoredLootMoney(uint32 containerId)
void LootItemStorage::RemoveStoredLootMoney(uint32 containerId, Loot *loot)
{
LootItemContainer::iterator itr = lootItemStore.find(containerId);
if (itr == lootItemStore.end())
@@ -182,7 +187,9 @@ void LootItemStorage::RemoveStoredLootMoney(uint32 containerId)
break;
}
if (itemList.empty())
// loot with empty itemList but unlootedCount > 0
// must be deleted manually by the player or traded
if (!loot->unlootedCount)
lootItemStore.erase(itr);
}