aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2024-04-29 00:06:02 +0200
committerShauren <shauren.trinity@gmail.com>2024-04-29 00:06:02 +0200
commitcc9241784491198581a19f3f5502a42d048ea063 (patch)
tree323d98827c0d81464cd767207e8d523448599351 /src/server/game/Entities
parent9dcc6c020763e5a79e9d73b364a73b00d63ce734 (diff)
Core/Items: Implemented packets setting up inventory cleanup parameters
Diffstat (limited to 'src/server/game/Entities')
-rw-r--r--src/server/game/Entities/Player/Player.cpp60
-rw-r--r--src/server/game/Entities/Player/Player.h28
2 files changed, 87 insertions, 1 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 0d59ce555ac..85f9cdaf74d 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -17628,7 +17628,8 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
struct PlayerLoadData
{
- // "SELECT c.guid, account, name, race, class, gender, level, xp, money, inventorySlots, bankSlots, restState, playerFlags, playerFlagsEx, "
+ // "SELECT c.guid, account, name, race, class, gender, level, xp, money, inventorySlots, inventoryBagFlags, bagSlotFlags1, bagSlotFlags2, bagSlotFlags3, bagSlotFlags4, bagSlotFlags5, "
+ // "bankSlots, bankBagFlags, bankBagSlotFlags1, bankBagSlotFlags2, bankBagSlotFlags3, bankBagSlotFlags4, bankBagSlotFlags5, bankBagSlotFlags6, bankBagSlotFlags7, restState, playerFlags, playerFlagsEx, "
// "position_x, position_y, position_z, map, orientation, taximask, createTime, createMode, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, "
// "resettalents_time, primarySpecialization, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, summonedPetNumber, at_login, zone, online, death_expire_time, taxi_path, dungeonDifficulty, "
// "totalKills, todayKills, yesterdayKills, chosenTitle, watchedFaction, drunk, "
@@ -17647,7 +17648,11 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
uint32 xp;
uint64 money;
uint8 inventorySlots;
+ EnumFlag<BagSlotFlags> inventoryBagFlags = BagSlotFlags::None;
+ std::array<BagSlotFlags, 5> bagSlotFlags;
uint8 bankSlots;
+ EnumFlag<BagSlotFlags> bankBagFlags = BagSlotFlags::None;
+ std::array<BagSlotFlags, 7> bankBagSlotFlags;
PlayerRestState restState;
PlayerFlags playerFlags;
PlayerFlagsEx playerFlagsEx;
@@ -17722,7 +17727,13 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
xp = fields[i++].GetUInt32();
money = fields[i++].GetUInt64();
inventorySlots = fields[i++].GetUInt8();
+ inventoryBagFlags = static_cast<BagSlotFlags>(fields[i++].GetUInt32());
+ for (BagSlotFlags& flags : bagSlotFlags)
+ flags = static_cast<BagSlotFlags>(fields[i++].GetUInt32());
bankSlots = fields[i++].GetUInt8();
+ bankBagFlags = static_cast<BagSlotFlags>(fields[i++].GetUInt32());
+ for (BagSlotFlags& flags : bankBagSlotFlags)
+ flags = static_cast<BagSlotFlags>(fields[i++].GetUInt32());
restState = PlayerRestState(fields[i++].GetUInt8());
playerFlags = PlayerFlags(fields[i++].GetUInt32());
playerFlagsEx = PlayerFlagsEx(fields[i++].GetUInt32());
@@ -17877,7 +17888,14 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
SetCustomizations(Trinity::Containers::MakeIteratorPair(customizations.begin(), customizations.end()), false);
SetInventorySlotCount(fields.inventorySlots);
+ SetBackpackAutoSortDisabled(fields.inventoryBagFlags.HasFlag(BagSlotFlags::DisableAutoSort));
+ SetBackpackSellJunkDisabled(fields.inventoryBagFlags.HasFlag(BagSlotFlags::ExcludeJunkSell));
+ for (uint32 bagIndex = 0; bagIndex < fields.bagSlotFlags.size(); ++bagIndex)
+ ReplaceAllBagSlotFlags(bagIndex, fields.bagSlotFlags[bagIndex]);
SetBankBagSlotCount(fields.bankSlots);
+ SetBankAutoSortDisabled(fields.bankBagFlags.HasFlag(BagSlotFlags::DisableAutoSort));
+ for (uint32 bagIndex = 0; bagIndex < fields.bankBagSlotFlags.size(); ++bagIndex)
+ ReplaceAllBankBagSlotFlags(bagIndex, fields.bankBagSlotFlags[bagIndex]);
SetNativeGender(fields.gender);
SetUpdateFieldValue(m_values.ModifyValue(&Player::m_playerData).ModifyValue(&UF::PlayerData::Inebriation), fields.drunk);
ReplaceAllPlayerFlags(fields.playerFlags);
@@ -20034,7 +20052,27 @@ void Player::SaveToDB(LoginDatabaseTransaction loginTransaction, CharacterDataba
stmt->setUInt32(index++, GetXP());
stmt->setUInt64(index++, GetMoney());
stmt->setUInt8(index++, GetInventorySlotCount());
+ stmt->setUInt32(index++, [&]
+ {
+ BagSlotFlags inventoryFlags = BagSlotFlags::None;
+ if (m_activePlayerData->BackpackAutoSortDisabled)
+ inventoryFlags |= BagSlotFlags::DisableAutoSort;
+ if (m_activePlayerData->BackpackSellJunkDisabled)
+ inventoryFlags |= BagSlotFlags::ExcludeJunkSell;
+ return AsUnderlyingType(inventoryFlags);
+ }());
+ for (uint32 bagSlotFlag : m_activePlayerData->BagSlotFlags)
+ stmt->setUInt32(index++, bagSlotFlag);
stmt->setUInt8(index++, GetBankBagSlotCount());
+ stmt->setUInt32(index++, [&]
+ {
+ BagSlotFlags inventoryFlags = BagSlotFlags::None;
+ if (m_activePlayerData->BankAutoSortDisabled)
+ inventoryFlags |= BagSlotFlags::DisableAutoSort;
+ return AsUnderlyingType(inventoryFlags);
+ }());
+ for (uint32 bankBagSlotFlag : m_activePlayerData->BankBagSlotFlags)
+ stmt->setUInt32(index++, bankBagSlotFlag);
stmt->setUInt8(index++, m_activePlayerData->RestInfo[REST_TYPE_XP].StateID);
stmt->setUInt32(index++, m_playerData->PlayerFlags);
stmt->setUInt32(index++, m_playerData->PlayerFlagsEx);
@@ -20151,7 +20189,27 @@ void Player::SaveToDB(LoginDatabaseTransaction loginTransaction, CharacterDataba
stmt->setUInt32(index++, GetXP());
stmt->setUInt64(index++, GetMoney());
stmt->setUInt8(index++, GetInventorySlotCount());
+ stmt->setUInt32(index++, [&]
+ {
+ BagSlotFlags inventoryFlags = BagSlotFlags::None;
+ if (m_activePlayerData->BackpackAutoSortDisabled)
+ inventoryFlags |= BagSlotFlags::DisableAutoSort;
+ if (m_activePlayerData->BackpackSellJunkDisabled)
+ inventoryFlags |= BagSlotFlags::ExcludeJunkSell;
+ return AsUnderlyingType(inventoryFlags);
+ }());
+ for (uint32 bagSlotFlag : m_activePlayerData->BagSlotFlags)
+ stmt->setUInt32(index++, bagSlotFlag);
stmt->setUInt8(index++, GetBankBagSlotCount());
+ stmt->setUInt32(index++, [&]
+ {
+ BagSlotFlags inventoryFlags = BagSlotFlags::None;
+ if (m_activePlayerData->BankAutoSortDisabled)
+ inventoryFlags |= BagSlotFlags::DisableAutoSort;
+ return AsUnderlyingType(inventoryFlags);
+ }());
+ for (uint32 bankBagSlotFlag : m_activePlayerData->BankBagSlotFlags)
+ stmt->setUInt32(index++, bankBagSlotFlag);
stmt->setUInt8(index++, m_activePlayerData->RestInfo[REST_TYPE_XP].StateID);
stmt->setUInt32(index++, m_playerData->PlayerFlags);
stmt->setUInt32(index++, m_playerData->PlayerFlagsEx);
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 5b8d4ed20e0..758c3ccd28a 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -768,6 +768,20 @@ enum class ItemSearchCallbackResult
Continue
};
+enum class BagSlotFlags : uint32
+{
+ None = 0x00,
+ DisableAutoSort = 0x01,
+ PriorityEquipment = 0x02,
+ PriorityConsumables = 0x04,
+ PriorityTradeGoods = 0x08,
+ PriorityJunk = 0x10,
+ PriorityQuestItems = 0x20,
+ ExcludeJunkSell = 0x40,
+};
+
+DEFINE_ENUM_FLAG(BagSlotFlags);
+
enum NewWorldReason
{
NEW_WORLD_NORMAL = 16, // Normal map change
@@ -1383,6 +1397,20 @@ class TC_GAME_API Player final : public Unit, public GridObject<Player>
void SetInventorySlotCount(uint8 slots);
uint8 GetBankBagSlotCount() const { return m_activePlayerData->NumBankSlots; }
void SetBankBagSlotCount(uint8 count) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::NumBankSlots), count); }
+ bool IsBackpackAutoSortDisabled() const { return m_activePlayerData->BackpackAutoSortDisabled; }
+ void SetBackpackAutoSortDisabled(bool disabled) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::BackpackAutoSortDisabled), disabled); }
+ bool IsBackpackSellJunkDisabled() const { return m_activePlayerData->BackpackSellJunkDisabled; }
+ void SetBackpackSellJunkDisabled(bool disabled) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::BackpackSellJunkDisabled), disabled); }
+ bool IsBankAutoSortDisabled() const { return m_activePlayerData->BankAutoSortDisabled; }
+ void SetBankAutoSortDisabled(bool disabled) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::BankAutoSortDisabled), disabled); }
+ EnumFlag<BagSlotFlags> GetBagSlotFlags(uint32 bagIndex) const { return static_cast<BagSlotFlags>(m_activePlayerData->BagSlotFlags[bagIndex]); }
+ void SetBagSlotFlag(uint32 bagIndex, EnumFlag<BagSlotFlags> flags) { SetUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::BagSlotFlags, bagIndex), flags.AsUnderlyingType()); }
+ void RemoveBagSlotFlag(uint32 bagIndex, EnumFlag<BagSlotFlags> flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::BagSlotFlags, bagIndex), flags.AsUnderlyingType()); }
+ void ReplaceAllBagSlotFlags(uint32 bagIndex, EnumFlag<BagSlotFlags> flags) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::BagSlotFlags, bagIndex), flags.AsUnderlyingType()); }
+ EnumFlag<BagSlotFlags> GetBankBagSlotFlags(uint32 bagIndex) const { return static_cast<BagSlotFlags>(m_activePlayerData->BankBagSlotFlags[bagIndex]); }
+ void SetBankBagSlotFlag(uint32 bagIndex, EnumFlag<BagSlotFlags> flags) { SetUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::BankBagSlotFlags, bagIndex), flags.AsUnderlyingType()); }
+ void RemoveBankBagSlotFlag(uint32 bagIndex, EnumFlag<BagSlotFlags> flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::BankBagSlotFlags, bagIndex), flags.AsUnderlyingType()); }
+ void ReplaceAllBankBagSlotFlags(uint32 bagIndex, EnumFlag<BagSlotFlags> flags) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::BankBagSlotFlags, bagIndex), flags.AsUnderlyingType()); }
bool HasItemCount(uint32 item, uint32 count = 1, bool inBankAlso = false) const;
bool HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem = nullptr) const;
bool CanNoReagentCast(SpellInfo const* spellInfo) const;