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

@@ -25097,8 +25097,8 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
// LootItem is being removed (looted) from the container, delete it from the DB.
if (loot->containerId > 0)
sLootItemStorage->RemoveStoredLootItem(loot->containerId, item->itemid, item->count);
sLootItemStorage->RemoveStoredLootItem(loot->containerId, item->itemid, item->count, loot);
sScriptMgr->OnLootItem(this, newitem, item->count, this->GetLootGUID());
}
else

View File

@@ -205,7 +205,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recvData*/)
// Delete the money loot record from the DB
if (loot->containerId > 0)
sLootItemStorage->RemoveStoredLootMoney(loot->containerId);
sLootItemStorage->RemoveStoredLootMoney(loot->containerId, loot);
// Delete container if empty
if (loot->isLooted() && IS_ITEM_GUID(guid))

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);
}

View File

@@ -43,8 +43,8 @@ class LootItemStorage
void AddNewStoredLoot(Loot* loot, Player* player);
bool LoadStoredLoot(Item* item);
void RemoveStoredLootItem(uint32 containerId, uint32 itemid, uint32 count);
void RemoveStoredLootMoney(uint32 containerId);
void RemoveStoredLootItem(uint32 containerId, uint32 itemid, uint32 count, Loot* loot);
void RemoveStoredLootMoney(uint32 containerId, Loot* loot);
void RemoveStoredLoot(uint32 containerId);
private: