mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
Fix lootable items re-fill when not really empty
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user