Core/Loot: Removed unneccessary field from Loot class and pass it as parameter everywhere
This commit is contained in:
1 parent
0c33018b90
commit
b48e834b1c
7 files changed
+17
-24
No files matched your search
@@ -8443,9 +8443,6 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
|
||||
|
||||
loot = &item->loot;
|
||||
|
||||
// Store container id
|
||||
loot->containerID = item->GetGUID().GetCounter();
|
||||
|
||||
// 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))
|
||||
@@ -8471,7 +8468,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
|
||||
// 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;
|
||||
}
|
||||
@@ -24910,7 +24907,7 @@ void Player::AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore cons
|
||||
}
|
||||
}
|
||||
|
||||
void Player::StoreLootItem(uint8 lootSlot, Loot* loot, GameObject* go)
|
||||
void Player::StoreLootItem(ObjectGuid lootWorldObjectGuid, uint8 lootSlot, Loot* loot, GameObject* go)
|
||||
{
|
||||
NotNormalLootItem* qitem = nullptr;
|
||||
NotNormalLootItem* ffaitem = nullptr;
|
||||
@@ -24997,8 +24994,8 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot, GameObject* go)
|
||||
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CATCH_FROM_POOL, item->itemid, item->count, 0, nullptr, go);
|
||||
|
||||
// LootItem is being removed (looted) from the container, delete it from the DB.
|
||||
if (loot->containerID > 0)
|
||||
sLootItemStorage->RemoveStoredLootItemForContainer(loot->containerID, item->itemid, item->count, item->itemIndex);
|
||||
if (lootWorldObjectGuid.IsItem() && loot->loot_type == LOOT_CORPSE)
|
||||
sLootItemStorage->RemoveStoredLootItemForContainer(lootWorldObjectGuid.GetCounter(), item->itemid, item->count, item->itemIndex);
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1210,7 +1210,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, bool broadcast = false);
|
||||
void AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast = false) { AutoStoreLoot(NULL_BAG, NULL_SLOT, loot_id, store, broadcast); }
|
||||
void StoreLootItem(uint8 lootSlot, Loot* loot, GameObject* go = nullptr);
|
||||
void StoreLootItem(ObjectGuid lootWorldObjectGuid, uint8 lootSlot, Loot* loot, GameObject* go = 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;
|
||||
|
||||
@@ -96,7 +96,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData)
|
||||
loot = &creature->loot;
|
||||
}
|
||||
|
||||
player->StoreLootItem(lootSlot, loot, gameObject);
|
||||
player->StoreLootItem(lguid, lootSlot, loot, gameObject);
|
||||
|
||||
// If player is removing the last LootItem, delete the empty container.
|
||||
if (loot->isLooted() && lguid.IsItem())
|
||||
@@ -262,8 +262,8 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
|
||||
loot->gold = 0;
|
||||
|
||||
// Delete the money loot record from the DB
|
||||
if (loot->containerID > 0)
|
||||
sLootItemStorage->RemoveStoredMoneyForContainer(loot->containerID);
|
||||
if (guid.IsItem() && loot->loot_type == LOOT_CORPSE)
|
||||
sLootItemStorage->RemoveStoredMoneyForContainer(guid.GetCounter());
|
||||
|
||||
// Delete container if empty
|
||||
if (loot->isLooted() && guid.IsItem())
|
||||
|
||||
@@ -140,7 +140,7 @@ void LootItem::AddAllowedLooter(Player const* player)
|
||||
// --------- Loot ---------
|
||||
//
|
||||
|
||||
Loot::Loot(uint32 _gold /*= 0*/) : gold(_gold), unlootedCount(0), roundRobinPlayer(), loot_type(LOOT_NONE), maxDuplicates(1), containerID(0)
|
||||
Loot::Loot(uint32 _gold /*= 0*/) : gold(_gold), unlootedCount(0), roundRobinPlayer(), loot_type(LOOT_NONE), maxDuplicates(1)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -226,10 +226,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)
|
||||
|
||||
// GUIDLow of container that holds this loot (item_instance.entry)
|
||||
// Only set for inventory items that can be right-click looted
|
||||
uint32 containerID;
|
||||
|
||||
Loot(uint32 _gold = 0);
|
||||
~Loot();
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ bool LootItemStorage::LoadStoredLoot(Item* item, Player* player)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(*GetLock());
|
||||
|
||||
auto itr = _lootItemStore.find(loot->containerID);
|
||||
auto itr = _lootItemStore.find(item->GetGUID().GetCounter());
|
||||
if (itr == _lootItemStore.end())
|
||||
return false;
|
||||
|
||||
@@ -230,7 +230,7 @@ void LootItemStorage::RemoveStoredLootItemForContainer(uint32 containerId, uint3
|
||||
itr->second.RemoveItem(itemId, count, itemIndex);
|
||||
}
|
||||
|
||||
void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
|
||||
void LootItemStorage::AddNewStoredLoot(uint32 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
|
||||
@@ -240,22 +240,22 @@ void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(*GetLock());
|
||||
|
||||
auto itr = _lootItemStore.find(loot->containerID);
|
||||
auto itr = _lootItemStore.find(containerId);
|
||||
if (itr != _lootItemStore.end())
|
||||
{
|
||||
TC_LOG_ERROR("misc", "Trying to store item loot by player: %s for container id: %u that is already in storage!", player->GetGUID().ToString().c_str(), loot->containerID);
|
||||
TC_LOG_ERROR("misc", "Trying to store item loot by player: %s for container id: %u that is already in storage!", player->GetGUID().ToString().c_str(), containerId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
StoredLootContainer container(loot->containerID);
|
||||
StoredLootContainer container(containerId);
|
||||
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
if (loot->gold)
|
||||
container.AddMoney(loot->gold, trans);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEMS);
|
||||
stmt->setUInt32(0, loot->containerID);
|
||||
stmt->setUInt32(0, containerId);
|
||||
trans->Append(stmt);
|
||||
|
||||
for (LootItem const& li : loot->items)
|
||||
@@ -281,7 +281,7 @@ void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
|
||||
// write
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(*GetLock());
|
||||
_lootItemStore.emplace(loot->containerID, std::move(container));
|
||||
_lootItemStore.emplace(containerId, std::move(container));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ class LootItemStorage
|
||||
void RemoveStoredMoneyForContainer(uint32 containerId);
|
||||
void RemoveStoredLootForContainer(uint32 containerId);
|
||||
void RemoveStoredLootItemForContainer(uint32 containerId, uint32 itemId, uint32 count, uint32 itemIndex);
|
||||
void AddNewStoredLoot(Loot* loot, Player* player);
|
||||
void AddNewStoredLoot(uint32 containerId, Loot* loot, Player* player);
|
||||
|
||||
private:
|
||||
LootItemStorage() { }
|
||||
|
||||
Reference in new issue
Block a user