Fix lootable items re-fill when not really empty
This commit is contained in:
@@ -25097,7 +25097,7 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
|
|||||||
|
|
||||||
// LootItem is being removed (looted) from the container, delete it from the DB.
|
// LootItem is being removed (looted) from the container, delete it from the DB.
|
||||||
if (loot->containerId > 0)
|
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());
|
sScriptMgr->OnLootItem(this, newitem, item->count, this->GetLootGUID());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recvData*/)
|
|||||||
|
|
||||||
// Delete the money loot record from the DB
|
// Delete the money loot record from the DB
|
||||||
if (loot->containerId > 0)
|
if (loot->containerId > 0)
|
||||||
sLootItemStorage->RemoveStoredLootMoney(loot->containerId);
|
sLootItemStorage->RemoveStoredLootMoney(loot->containerId, loot);
|
||||||
|
|
||||||
// Delete container if empty
|
// Delete container if empty
|
||||||
if (loot->isLooted() && IS_ITEM_GUID(guid))
|
if (loot->isLooted() && IS_ITEM_GUID(guid))
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ void LootItemStorage::RemoveEntryFromDB(uint32 containerId, uint32 itemid, uint3
|
|||||||
CharacterDatabase.CommitTransaction(trans);
|
CharacterDatabase.CommitTransaction(trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
|
void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* /*player*/)
|
||||||
{
|
{
|
||||||
if (lootItemStore.find(loot->containerId) != lootItemStore.end())
|
if (lootItemStore.find(loot->containerId) != lootItemStore.end())
|
||||||
{
|
{
|
||||||
@@ -88,8 +88,11 @@ void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
|
|||||||
if (!loot->isLooted())
|
if (!loot->isLooted())
|
||||||
for (LootItemList::const_iterator li = loot->items.begin(); li != loot->items.end(); li++)
|
for (LootItemList::const_iterator li = loot->items.begin(); li != loot->items.end(); li++)
|
||||||
{
|
{
|
||||||
if (!li->AllowedForPlayer(player))
|
// Even if an item is not available for a specific player, it doesn't mean that
|
||||||
continue;
|
// 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);
|
const ItemTemplate* itemTemplate = sObjectMgr->GetItemTemplate(li->itemid);
|
||||||
if (!itemTemplate || itemTemplate->IsCurrencyToken())
|
if (!itemTemplate || itemTemplate->IsCurrencyToken())
|
||||||
@@ -148,7 +151,7 @@ bool LootItemStorage::LoadStoredLoot(Item* item)
|
|||||||
return true;
|
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);
|
LootItemContainer::iterator itr = lootItemStore.find(containerId);
|
||||||
if (itr == lootItemStore.end())
|
if (itr == lootItemStore.end())
|
||||||
@@ -163,11 +166,13 @@ void LootItemStorage::RemoveStoredLootItem(uint32 containerId, uint32 itemid, ui
|
|||||||
break;
|
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);
|
lootItemStore.erase(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LootItemStorage::RemoveStoredLootMoney(uint32 containerId)
|
void LootItemStorage::RemoveStoredLootMoney(uint32 containerId, Loot *loot)
|
||||||
{
|
{
|
||||||
LootItemContainer::iterator itr = lootItemStore.find(containerId);
|
LootItemContainer::iterator itr = lootItemStore.find(containerId);
|
||||||
if (itr == lootItemStore.end())
|
if (itr == lootItemStore.end())
|
||||||
@@ -182,7 +187,9 @@ void LootItemStorage::RemoveStoredLootMoney(uint32 containerId)
|
|||||||
break;
|
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);
|
lootItemStore.erase(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ class LootItemStorage
|
|||||||
void AddNewStoredLoot(Loot* loot, Player* player);
|
void AddNewStoredLoot(Loot* loot, Player* player);
|
||||||
bool LoadStoredLoot(Item* item);
|
bool LoadStoredLoot(Item* item);
|
||||||
|
|
||||||
void RemoveStoredLootItem(uint32 containerId, uint32 itemid, uint32 count);
|
void RemoveStoredLootItem(uint32 containerId, uint32 itemid, uint32 count, Loot* loot);
|
||||||
void RemoveStoredLootMoney(uint32 containerId);
|
void RemoveStoredLootMoney(uint32 containerId, Loot* loot);
|
||||||
void RemoveStoredLoot(uint32 containerId);
|
void RemoveStoredLoot(uint32 containerId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user