Core/Loot: Removed unneccessary field from Loot class and pass it as parameter everywhere
This commit is contained in:
@@ -8922,9 +8922,6 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type, bool aeLooting/* = fa
|
||||
|
||||
loot = &item->loot;
|
||||
|
||||
// Store container id
|
||||
loot->containerID = item->GetGUID();
|
||||
|
||||
// If item doesn't already have loot, attempt to load it. If that
|
||||
// fails then this is first time opening, generate loot
|
||||
if (!item->m_lootGenerated && !sLootItemStorage->LoadStoredLoot(item, this))
|
||||
@@ -8950,7 +8947,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type, bool aeLooting/* = fa
|
||||
// Force save the loot and money items that were just rolled
|
||||
// Also saves the container item ID in Loot struct (not to DB)
|
||||
if (loot->gold > 0 || loot->unlootedCount > 0)
|
||||
sLootItemStorage->AddNewStoredLoot(loot, this);
|
||||
sLootItemStorage->AddNewStoredLoot(item->GetGUID().GetCounter(), loot, this);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -26061,7 +26058,7 @@ void Player::AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore cons
|
||||
Unit::ProcSkillsAndAuras(this, nullptr, PROC_FLAG_LOOTED, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, PROC_HIT_NONE, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void Player::StoreLootItem(uint8 lootSlot, Loot* loot, AELootResult* aeResult/* = nullptr*/)
|
||||
void Player::StoreLootItem(ObjectGuid lootWorldObjectGuid, uint8 lootSlot, Loot* loot, AELootResult* aeResult/* = nullptr*/)
|
||||
{
|
||||
NotNormalLootItem* qitem = nullptr;
|
||||
NotNormalLootItem* ffaitem = nullptr;
|
||||
@@ -26150,8 +26147,8 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot, AELootResult* aeResult/*
|
||||
aeResult->Add(newitem, item->count, loot->loot_type);
|
||||
|
||||
// LootItem is being removed (looted) from the container, delete it from the DB.
|
||||
if (!loot->containerID.IsEmpty())
|
||||
sLootItemStorage->RemoveStoredLootItemForContainer(loot->containerID.GetCounter(), item->itemid, item->count, item->itemIndex);
|
||||
if (lootWorldObjectGuid.IsItem() && loot->loot_type == LOOT_CORPSE)
|
||||
sLootItemStorage->RemoveStoredLootItemForContainer(lootWorldObjectGuid.GetCounter(), item->itemid, item->count, item->itemIndex);
|
||||
|
||||
ApplyItemLootedSpell(newitem, true);
|
||||
}
|
||||
|
||||
@@ -1412,7 +1412,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count);
|
||||
void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store, ItemContext context = ItemContext::NONE, bool broadcast = false, bool createdByPlayer = false);
|
||||
void AutoStoreLoot(uint32 loot_id, LootStore const& store, ItemContext context = ItemContext::NONE, bool broadcast = false, bool createdByPlayer = false) { AutoStoreLoot(NULL_BAG, NULL_SLOT, loot_id, store, context, broadcast, createdByPlayer); }
|
||||
void StoreLootItem(uint8 lootSlot, Loot* loot, AELootResult* aeResult = nullptr);
|
||||
void StoreLootItem(ObjectGuid lootWorldObjectGuid, uint8 lootSlot, Loot* loot, AELootResult* aeResult = nullptr);
|
||||
|
||||
InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = nullptr, uint32* offendingItemId = nullptr) const;
|
||||
InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem = nullptr, bool swap = false, uint32* no_space_count = nullptr) const;
|
||||
|
||||
@@ -123,7 +123,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPackets::Loot::LootItem& p
|
||||
loot = &creature->loot;
|
||||
}
|
||||
|
||||
player->StoreLootItem(req.LootListID - 1, loot, aeResultPtr);
|
||||
player->StoreLootItem(lguid, req.LootListID - 1, loot, aeResultPtr);
|
||||
|
||||
// If player is removing the last LootItem, delete the empty container.
|
||||
if (loot->isLooted() && lguid.IsItem())
|
||||
@@ -257,8 +257,8 @@ void WorldSession::HandleLootMoneyOpcode(WorldPackets::Loot::LootMoney& /*packet
|
||||
loot->gold = 0;
|
||||
|
||||
// Delete the money loot record from the DB
|
||||
if (!loot->containerID.IsEmpty())
|
||||
sLootItemStorage->RemoveStoredMoneyForContainer(loot->containerID.GetCounter());
|
||||
if (guid.IsItem() && loot->loot_type == LOOT_CORPSE)
|
||||
sLootItemStorage->RemoveStoredMoneyForContainer(guid.GetCounter());
|
||||
|
||||
// Delete container if empty
|
||||
if (loot->isLooted() && guid.IsItem())
|
||||
|
||||
@@ -220,10 +220,6 @@ struct TC_GAME_API Loot
|
||||
LootType loot_type; // required for achievement system
|
||||
uint8 maxDuplicates; // Max amount of items with the same entry that can drop (default is 1; on 25 man raid mode 3)
|
||||
|
||||
// GUID of container that holds this loot (item_instance.entry)
|
||||
// Only set for inventory items that can be right-click looted
|
||||
ObjectGuid containerID;
|
||||
|
||||
Loot(uint32 _gold = 0);
|
||||
~Loot();
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ bool LootItemStorage::LoadStoredLoot(Item* item, Player* player)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(*GetLock());
|
||||
|
||||
auto itr = _lootItemStore.find(loot->containerID.GetCounter());
|
||||
auto itr = _lootItemStore.find(item->GetGUID().GetCounter());
|
||||
if (itr == _lootItemStore.end())
|
||||
return false;
|
||||
|
||||
@@ -235,7 +235,7 @@ void LootItemStorage::RemoveStoredLootItemForContainer(uint64 containerId, uint3
|
||||
itr->second.RemoveItem(itemId, count, itemIndex);
|
||||
}
|
||||
|
||||
void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
|
||||
void LootItemStorage::AddNewStoredLoot(uint64 containerId, Loot* loot, Player* player)
|
||||
{
|
||||
// Saves the money and item loot associated with an openable item to the DB
|
||||
if (loot->isLooted()) // no money and no loot
|
||||
@@ -245,22 +245,22 @@ void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(*GetLock());
|
||||
|
||||
auto itr = _lootItemStore.find(loot->containerID.GetCounter());
|
||||
auto itr = _lootItemStore.find(containerId);
|
||||
if (itr != _lootItemStore.end())
|
||||
{
|
||||
TC_LOG_ERROR("misc", "Trying to store item loot by player: %s for container id: %s that is already in storage!", player->GetGUID().ToString().c_str(), loot->containerID.ToString().c_str());
|
||||
TC_LOG_ERROR("misc", "Trying to store item loot by player: %s for container id: " UI64FMTD " that is already in storage!", player->GetGUID().ToString().c_str(), containerId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
StoredLootContainer container(loot->containerID.GetCounter());
|
||||
StoredLootContainer container(containerId);
|
||||
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
if (loot->gold)
|
||||
container.AddMoney(loot->gold, trans);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEMS);
|
||||
stmt->setUInt64(0, loot->containerID.GetCounter());
|
||||
stmt->setUInt64(0, containerId);
|
||||
trans->Append(stmt);
|
||||
|
||||
for (LootItem const& li : loot->items)
|
||||
@@ -286,7 +286,7 @@ void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
|
||||
// write
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(*GetLock());
|
||||
_lootItemStore.emplace(loot->containerID.GetCounter(), std::move(container));
|
||||
_lootItemStore.emplace(containerId, std::move(container));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class LootItemStorage
|
||||
void RemoveStoredMoneyForContainer(uint64 containerId);
|
||||
void RemoveStoredLootForContainer(uint64 containerId);
|
||||
void RemoveStoredLootItemForContainer(uint64 containerId, uint32 itemId, uint32 count, uint32 itemIndex);
|
||||
void AddNewStoredLoot(Loot* loot, Player* player);
|
||||
void AddNewStoredLoot(uint64 containerId, Loot* loot, Player* player);
|
||||
|
||||
private:
|
||||
LootItemStorage() { }
|
||||
|
||||
Reference in New Issue
Block a user