AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Bag Class Reference

#include "Bag.h"

Inheritance diagram for Bag:
Item Object

Public Member Functions

 Bag ()
 
 ~Bag () override
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
bool Create (ObjectGuid::LowType guidlow, uint32 itemid, Player const *owner) override
 
void StoreItem (uint8 slot, Item *pItem, bool update)
 
void RemoveItem (uint8 slot, bool update)
 
ItemGetItemByPos (uint8 slot) const
 
uint32 GetItemCount (uint32 item, Item *eItem=nullptr) const
 
uint32 GetItemCountWithLimitCategory (uint32 limitCategory, Item *skipItem=nullptr) const
 
uint8 GetSlotByItemGUID (ObjectGuid guid) const
 
bool IsEmpty () const
 
uint32 GetFreeSlots () const
 
uint32 GetBagSize () const
 
void SaveToDB (CharacterDatabaseTransaction trans) override
 
bool LoadFromDB (ObjectGuid::LowType guid, ObjectGuid owner_guid, Field *fields, uint32 entry) override
 
void DeleteFromDB (CharacterDatabaseTransaction trans) override
 
void BuildCreateUpdateBlockForPlayer (UpdateData *data, Player *target) override
 
std::string GetDebugInfo () const override
 
- Public Member Functions inherited from Item
ItemCloneItem (uint32 count, Player const *player=nullptr) const
 
 Item ()
 
virtual bool Create (ObjectGuid::LowType guidlow, uint32 itemid, Player const *owner)
 
ItemTemplate const * GetTemplate () const
 
ObjectGuid GetOwnerGUID () const
 
void SetOwnerGUID (ObjectGuid guid)
 
PlayerGetOwner () const
 
void SetBinding (bool val)
 
bool IsSoulBound () const
 
bool IsBoundAccountWide () const
 
bool IsBindedNotWith (Player const *player) const
 
bool IsBoundByEnchant () const
 
bool IsBoundByTempEnchant () const
 
virtual void SaveToDB (CharacterDatabaseTransaction trans)
 
virtual bool LoadFromDB (ObjectGuid::LowType guid, ObjectGuid owner_guid, Field *fields, uint32 entry)
 
virtual void DeleteFromDB (CharacterDatabaseTransaction trans)
 
void DeleteFromInventoryDB (CharacterDatabaseTransaction trans)
 
void SaveRefundDataToDB ()
 
void DeleteRefundDataFromDB (CharacterDatabaseTransaction *trans)
 
BagToBag ()
 
const BagToBag () const
 
bool IsLocked () const
 
bool IsBag () const
 
bool IsCurrencyToken () const
 
bool IsNotEmptyBag () const
 
bool IsBroken () const
 
bool CanBeTraded (bool mail=false, bool trade=false) const
 
void SetInTrade (bool b=true)
 
bool IsInTrade () const
 
bool IsRefundable () const
 
bool IsBOPTradable () const
 
bool IsWrapped () const
 
bool HasEnchantRequiredSkill (Player const *player) const
 
uint32 GetEnchantRequiredLevel () const
 
bool IsFitToSpellRequirements (SpellInfo const *spellInfo) const
 
bool IsLimitedToAnotherMapOrZone (uint32 cur_mapId, uint32 cur_zoneId) const
 
bool GemsFitSockets () const
 
uint32 GetCount () const
 
void SetCount (uint32 value)
 
uint32 GetMaxStackCount () const
 
bool HasSocket () const
 
uint8 GetGemCountWithID (uint32 GemID) const
 
uint8 GetGemCountWithLimitCategory (uint32 limitCategory) const
 
InventoryResult CanBeMergedPartlyWith (ItemTemplate const *proto) const
 
uint8 GetSlot () const
 
BagGetContainer ()
 
uint8 GetBagSlot () const
 
void SetSlot (uint8 slot)
 
uint16 GetPos () const
 
void SetContainer (Bag *container)
 
bool IsInBag () const
 
bool IsEquipped () const
 
uint32 GetSkill ()
 
uint32 GetSpell ()
 
int32 GetItemRandomPropertyId () const
 
uint32 GetItemSuffixFactor () const
 
void SetItemRandomProperties (int32 randomPropId)
 
void UpdateItemSuffixFactor ()
 
void SetEnchantment (EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster=ObjectGuid::Empty)
 
void SetEnchantmentDuration (EnchantmentSlot slot, uint32 duration, Player *owner)
 
void SetEnchantmentCharges (EnchantmentSlot slot, uint32 charges)
 
void ClearEnchantment (EnchantmentSlot slot)
 
uint32 GetEnchantmentId (EnchantmentSlot slot) const
 
uint32 GetEnchantmentDuration (EnchantmentSlot slot) const
 
uint32 GetEnchantmentCharges (EnchantmentSlot slot) const
 
std::string const & GetText () const
 
void SetText (std::string const &text)
 
void SendUpdateSockets ()
 
void SendTimeUpdate (Player *owner)
 
void UpdateDuration (Player *owner, uint32 diff)
 
int32 GetSpellCharges (uint8 index=0) const
 
void SetSpellCharges (uint8 index, int32 value)
 
ItemUpdateState GetState () const
 
void SetState (ItemUpdateState state, Player *forplayer=nullptr)
 
void AddToUpdateQueueOf (Player *player)
 
void RemoveFromUpdateQueueOf (Player *player)
 
bool IsInUpdateQueue () const
 
uint32 GetQueuePos () const
 
void FSetState (ItemUpdateState state)
 
bool hasQuest (uint32 quest_id) const override
 
bool hasInvolvedQuest (uint32) const override
 
bool IsPotion () const
 
bool IsWeaponVellum () const
 
bool IsArmorVellum () const
 
bool IsConjuredConsumable () const
 
void SetNotRefundable (Player *owner, bool changestate=true, CharacterDatabaseTransaction *trans=nullptr)
 
void SetRefundRecipient (ObjectGuid::LowType pGuidLow)
 
void SetPaidMoney (uint32 money)
 
void SetPaidExtendedCost (uint32 iece)
 
ObjectGuid::LowType GetRefundRecipient ()
 
uint32 GetPaidMoney ()
 
uint32 GetPaidExtendedCost ()
 
void UpdatePlayedTime (Player *owner)
 
uint32 GetPlayedTime ()
 
bool IsRefundExpired ()
 
void SetSoulboundTradeable (AllowedLooterSet &allowedLooters)
 
void ClearSoulboundTradeable (Player *currentOwner)
 
bool CheckSoulboundTradeExpire ()
 
void BuildUpdate (UpdateDataMapType &data_map, UpdatePlayerSet &) override
 
void AddToObjectUpdate () override
 
void RemoveFromObjectUpdate () override
 
uint32 GetScriptId () const
 
std::string GetDebugInfo () const override
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
bool IsInWorld () const
 
virtual void AddToWorld ()
 
virtual void RemoveFromWorld ()
 
ObjectGuid GetGUID () const
 
PackedGuid const & GetPackGUID () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
virtual void SetObjectScale (float scale)
 
virtual uint32 GetDynamicFlags () const
 
bool HasDynamicFlag (uint32 flag) const
 
virtual void SetDynamicFlag (uint32 flag)
 
virtual void RemoveDynamicFlag (uint32 flag)
 
virtual void ReplaceAllDynamicFlags (uint32 flag)
 
TypeID GetTypeId () const
 
bool isType (uint16 mask) const
 
virtual void BuildCreateUpdateBlockForPlayer (UpdateData *data, Player *target)
 
void SendUpdateToPlayer (Player *player)
 
void BuildValuesUpdateBlockForPlayer (UpdateData *data, Player *target)
 
void BuildOutOfRangeUpdateBlock (UpdateData *data) const
 
void BuildMovementUpdateBlock (UpdateData *data, uint32 flags=0) const
 
virtual void DestroyForPlayer (Player *target, bool onDeath=false) const
 
int32 GetInt32Value (uint16 index) const
 
uint32 GetUInt32Value (uint16 index) const
 
uint64 GetUInt64Value (uint16 index) const
 
float GetFloatValue (uint16 index) const
 
uint8 GetByteValue (uint16 index, uint8 offset) const
 
uint16 GetUInt16Value (uint16 index, uint8 offset) const
 
ObjectGuid GetGuidValue (uint16 index) const
 
void SetInt32Value (uint16 index, int32 value)
 
void SetUInt32Value (uint16 index, uint32 value)
 
void UpdateUInt32Value (uint16 index, uint32 value)
 
void SetUInt64Value (uint16 index, uint64 value)
 
void SetFloatValue (uint16 index, float value)
 
void SetByteValue (uint16 index, uint8 offset, uint8 value)
 
void SetUInt16Value (uint16 index, uint8 offset, uint16 value)
 
void SetInt16Value (uint16 index, uint8 offset, int16 value)
 
void SetGuidValue (uint16 index, ObjectGuid value)
 
void SetStatFloatValue (uint16 index, float value)
 
void SetStatInt32Value (uint16 index, int32 value)
 
bool AddGuidValue (uint16 index, ObjectGuid value)
 
bool RemoveGuidValue (uint16 index, ObjectGuid value)
 
void ApplyModUInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModUInt64Value (uint16 index, int32 val, bool apply)
 
void ApplyModPositiveFloatValue (uint16 index, float val, bool apply)
 
void ApplyModSignedFloatValue (uint16 index, float val, bool apply)
 
void ApplyPercentModFloatValue (uint16 index, float val, bool apply)
 
void SetFlag (uint16 index, uint32 newFlag)
 
void RemoveFlag (uint16 index, uint32 oldFlag)
 
void ToggleFlag (uint16 index, uint32 flag)
 
bool HasFlag (uint16 index, uint32 flag) const
 
void ApplyModFlag (uint16 index, uint32 flag, bool apply)
 
void SetByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void RemoveByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
bool HasByteFlag (uint16 index, uint8 offset, uint8 flag) const
 
void SetFlag64 (uint16 index, uint64 newFlag)
 
void RemoveFlag64 (uint16 index, uint64 oldFlag)
 
void ToggleFlag64 (uint16 index, uint64 flag)
 
bool HasFlag64 (uint16 index, uint64 flag) const
 
void ApplyModFlag64 (uint16 index, uint64 flag, bool apply)
 
void ClearUpdateMask (bool remove)
 
uint16 GetValuesCount () const
 
virtual bool hasQuest (uint32) const
 
virtual bool hasInvolvedQuest (uint32) const
 
virtual void BuildUpdate (UpdateDataMapType &, UpdatePlayerSet &)
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &)
 
void SetFieldNotifyFlag (uint16 flag)
 
void RemoveFieldNotifyFlag (uint16 flag)
 
void ForceValuesUpdateAtIndex (uint32)
 
bool IsPlayer () const
 
PlayerToPlayer ()
 
Player const * ToPlayer () const
 
bool IsCreature () const
 
CreatureToCreature ()
 
Creature const * ToCreature () const
 
bool IsUnit () const
 
UnitToUnit ()
 
Unit const * ToUnit () const
 
bool IsGameObject () const
 
GameObjectToGameObject ()
 
GameObject const * ToGameObject () const
 
bool IsCorpse () const
 
CorpseToCorpse ()
 
Corpse const * ToCorpse () const
 
bool IsDynamicObject () const
 
DynamicObjectToDynObject ()
 
DynamicObject const * ToDynObject () const
 
bool IsItem () const
 
virtual std::string GetDebugInfo () const
 

Protected Attributes

Itemm_bagslot [MAX_BAG_SIZE]
 
- Protected Attributes inherited from Object
uint16 m_objectType
 
TypeID m_objectTypeId
 
uint16 m_updateFlag
 
union {
   int32 *   m_int32Values
 
   uint32 *   m_uint32Values
 
   float *   m_floatValues
 
}; 
 
UpdateMask _changesMask
 
uint16 m_valuesCount
 
uint16 _fieldNotifyFlags
 
bool m_objectUpdated
 

Additional Inherited Members

- Static Public Member Functions inherited from Item
static ItemCreateItem (uint32 item, uint32 count, Player const *player=nullptr, bool clone=false, uint32 randomPropertyId=0)
 
static void DeleteFromDB (CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
 
static void DeleteFromInventoryDB (CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
 
static int32 GenerateItemRandomPropertyId (uint32 item_id)
 
- Static Public Member Functions inherited from Object
static ObjectGuid GetGUID (Object const *o)
 
- Public Attributes inherited from Item
Loot loot
 
bool m_lootGenerated
 
- Public Attributes inherited from Object
DataMap CustomData
 
- Protected Member Functions inherited from Object
 Object ()
 
void _InitValues ()
 
void _Create (ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
 
std::string _ConcatFields (uint16 startIndex, uint16 size) const
 
bool _LoadIntoDataField (std::string const &data, uint32 startOffset, uint32 count)
 
uint32 GetUpdateFieldData (Player const *target, uint32 *&flags) const
 
void BuildMovementUpdate (ByteBuffer *data, uint16 flags) const
 
virtual void BuildValuesUpdate (uint8 updateType, ByteBuffer *data, Player *target)
 
virtual void AddToObjectUpdate ()=0
 
virtual void RemoveFromObjectUpdate ()=0
 
void AddToObjectUpdateIfNeeded ()
 

Detailed Description

Constructor & Destructor Documentation

◆ Bag()

Bag::Bag ( )
25 : Item()
26{
29
31
32 memset(m_bagslot, 0, sizeof(Item*) * MAX_BAG_SIZE);
33}
#define MAX_BAG_SIZE
Definition: Bag.h:22
@ TYPEID_CONTAINER
Definition: ObjectGuid.h:34
@ TYPEMASK_CONTAINER
Definition: ObjectGuid.h:48
@ CONTAINER_END
Definition: UpdateFields.h:81
Item * m_bagslot[MAX_BAG_SIZE]
Definition: Bag.h:64
Definition: Item.h:220
Item()
Definition: Item.cpp:261
uint16 m_objectType
Definition: Object.h:240
uint16 m_valuesCount
Definition: Object.h:254
TypeID m_objectTypeId
Definition: Object.h:242

References CONTAINER_END, m_bagslot, Object::m_objectType, Object::m_objectTypeId, Object::m_valuesCount, MAX_BAG_SIZE, TYPEID_CONTAINER, and TYPEMASK_CONTAINER.

◆ ~Bag()

Bag::~Bag ( )
override
36{
37 for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
38 if (Item* item = m_bagslot[i])
39 {
40 if (item->IsInWorld())
41 {
42 LOG_FATAL("entities.item", "Item {} (slot {}, bag slot {}) in bag {} (slot {}, bag slot {}, m_bagslot {}) is to be deleted but is still in world.",
43 item->GetEntry(), (uint32)item->GetSlot(), (uint32)item->GetBagSlot(),
45 item->RemoveFromWorld();
46 }
47 delete m_bagslot[i];
48 }
49}
#define LOG_FATAL(filterType__,...)
Definition: Log.h:153
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
uint8 GetSlot() const
Definition: Item.h:281
uint8 GetBagSlot() const
Definition: Item.cpp:784
uint32 GetEntry() const
Definition: Object.h:112

References Item::GetBagSlot(), Object::GetEntry(), Item::GetSlot(), LOG_FATAL, m_bagslot, and MAX_BAG_SIZE.

Member Function Documentation

◆ AddToWorld()

void Bag::AddToWorld ( )
overridevirtual

Reimplemented from Object.

52{
54
55 for (uint32 i = 0; i < GetBagSize(); ++i)
56 if (m_bagslot[i])
58}
uint32 GetBagSize() const
Definition: Bag.h:48
virtual void AddToWorld()
Definition: Object.cpp:152

References Object::AddToWorld(), GetBagSize(), and m_bagslot.

◆ BuildCreateUpdateBlockForPlayer()

void Bag::BuildCreateUpdateBlockForPlayer ( UpdateData data,
Player target 
)
overridevirtual

Reimplemented from Object.

170{
172
173 for (uint32 i = 0; i < GetBagSize(); ++i)
174 if (m_bagslot[i])
176}
virtual void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target)
Definition: Object.cpp:189

References Object::BuildCreateUpdateBlockForPlayer(), GetBagSize(), and m_bagslot.

◆ Create()

bool Bag::Create ( ObjectGuid::LowType  guidlow,
uint32  itemid,
Player const *  owner 
)
overridevirtual

Reimplemented from Item.

70{
71 ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid);
72
73 if (!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE)
74 return false;
75
76 Object::_Create(guidlow, 0, HighGuid::Item);
77
78 SetEntry(itemid);
79 SetObjectScale(1.0f);
80
81 SetGuidValue(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : ObjectGuid::Empty);
82 SetGuidValue(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : ObjectGuid::Empty);
83
87
88 // Setting the number of Slots the Container has
90
91 // Cleaning 20 slots
92 for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
93 {
95 m_bagslot[i] = nullptr;
96 }
97
98 return true;
99}
#define sObjectMgr
Definition: ObjectMgr.h:1635
@ CONTAINER_FIELD_SLOT_1
Definition: UpdateFields.h:80
@ CONTAINER_FIELD_NUM_SLOTS
Definition: UpdateFields.h:78
@ ITEM_FIELD_DURABILITY
Definition: UpdateFields.h:69
@ ITEM_FIELD_STACK_COUNT
Definition: UpdateFields.h:39
@ ITEM_FIELD_MAXDURABILITY
Definition: UpdateFields.h:70
@ ITEM_FIELD_OWNER
Definition: UpdateFields.h:35
@ ITEM_FIELD_CONTAINED
Definition: UpdateFields.h:36
Definition: ItemTemplate.h:619
uint32 ContainerSlots
Definition: ItemTemplate.h:646
uint32 MaxDurability
Definition: ItemTemplate.h:676
void _Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
Definition: Object.cpp:134
void SetGuidValue(uint16 index, ObjectGuid value)
Definition: Object.cpp:723
void SetEntry(uint32 entry)
Definition: Object.h:113
virtual void SetObjectScale(float scale)
Definition: Object.h:116
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:650
static ObjectGuid const Empty
Definition: ObjectGuid.h:120

References Object::_Create(), CONTAINER_FIELD_NUM_SLOTS, CONTAINER_FIELD_SLOT_1, ItemTemplate::ContainerSlots, ObjectGuid::Empty, Object::GetGUID(), ITEM_FIELD_CONTAINED, ITEM_FIELD_DURABILITY, ITEM_FIELD_MAXDURABILITY, ITEM_FIELD_OWNER, ITEM_FIELD_STACK_COUNT, m_bagslot, MAX_BAG_SIZE, ItemTemplate::MaxDurability, Object::SetEntry(), Object::SetGuidValue(), Object::SetObjectScale(), Object::SetUInt32Value(), and sObjectMgr.

◆ DeleteFromDB()

void Bag::DeleteFromDB ( CharacterDatabaseTransaction  trans)
overridevirtual

Reimplemented from Item.

125{
126 for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
127 if (m_bagslot[i])
128 m_bagslot[i]->DeleteFromDB(trans);
129
130 Item::DeleteFromDB(trans);
131}
static void DeleteFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
Definition: Item.cpp:518

References Item::DeleteFromDB(), m_bagslot, and MAX_BAG_SIZE.

◆ GetBagSize()

◆ GetDebugInfo()

std::string Bag::GetDebugInfo ( ) const
overridevirtual

Reimplemented from Object.

244{
245 std::stringstream sstr;
246 sstr << Item::GetDebugInfo();
247 return sstr.str();
248}
std::string GetDebugInfo() const override
Definition: Item.cpp:1289

References Item::GetDebugInfo().

◆ GetFreeSlots()

uint32 Bag::GetFreeSlots ( ) const
134{
135 uint32 slots = 0;
136 for (uint32 i = 0; i < GetBagSize(); ++i)
137 if (!m_bagslot[i])
138 ++slots;
139
140 return slots;
141}

References GetBagSize(), and m_bagslot.

◆ GetItemByPos()

Item * Bag::GetItemByPos ( uint8  slot) const
236{
237 if (slot < GetBagSize())
238 return m_bagslot[slot];
239
240 return nullptr;
241}

References GetBagSize(), and m_bagslot.

Referenced by reset_commandscript::ResetItemsInBags(), reset_commandscript::ResetItemsInBank(), and Player::SwapItem().

◆ GetItemCount()

uint32 Bag::GetItemCount ( uint32  item,
Item eItem = nullptr 
) const
189{
190 Item* pItem;
191 uint32 count = 0;
192 for (uint32 i = 0; i < GetBagSize(); ++i)
193 {
194 pItem = m_bagslot[i];
195 if (pItem && pItem != eItem && pItem->GetEntry() == item)
196 count += pItem->GetCount();
197 }
198
199 if (eItem && eItem->GetTemplate()->GemProperties)
200 {
201 for (uint32 i = 0; i < GetBagSize(); ++i)
202 {
203 pItem = m_bagslot[i];
204 if (pItem && pItem != eItem && pItem->GetTemplate()->Socket[0].Color)
205 count += pItem->GetGemCountWithID(item);
206 }
207 }
208
209 return count;
210}
uint8 GetGemCountWithID(uint32 GemID) const
Definition: Item.cpp:1014
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:544
uint32 GetCount() const
Definition: Item.h:272
uint32 Color
Definition: ItemTemplate.h:602
uint32 GemProperties
Definition: ItemTemplate.h:683
_Socket Socket[MAX_ITEM_PROTO_SOCKETS]
Definition: ItemTemplate.h:681

References _Socket::Color, ItemTemplate::GemProperties, GetBagSize(), Item::GetCount(), Object::GetEntry(), Item::GetGemCountWithID(), Item::GetTemplate(), m_bagslot, and ItemTemplate::Socket.

◆ GetItemCountWithLimitCategory()

uint32 Bag::GetItemCountWithLimitCategory ( uint32  limitCategory,
Item skipItem = nullptr 
) const
213{
214 uint32 count = 0;
215 for (uint32 i = 0; i < GetBagSize(); ++i)
216 if (Item* pItem = m_bagslot[i])
217 if (pItem != skipItem)
218 if (ItemTemplate const* pProto = pItem->GetTemplate())
219 if (pProto->ItemLimitCategory == limitCategory)
220 count += m_bagslot[i]->GetCount();
221
222 return count;
223}

References GetBagSize(), Item::GetCount(), and m_bagslot.

◆ GetSlotByItemGUID()

uint8 Bag::GetSlotByItemGUID ( ObjectGuid  guid) const
226{
227 for (uint32 i = 0; i < GetBagSize(); ++i)
228 if (m_bagslot[i] != 0)
229 if (m_bagslot[i]->GetGUID() == guid)
230 return i;
231
232 return NULL_SLOT;
233}
@ NULL_SLOT
Definition: Item.h:41
ObjectGuid GetGUID() const
Definition: Object.h:110

References GetBagSize(), Object::GetGUID(), m_bagslot, and NULL_SLOT.

◆ IsEmpty()

bool Bag::IsEmpty ( ) const
180{
181 for (uint32 i = 0; i < GetBagSize(); ++i)
182 if (m_bagslot[i])
183 return false;
184
185 return true;
186}

References GetBagSize(), and m_bagslot.

Referenced by Player::SwapItem().

◆ LoadFromDB()

bool Bag::LoadFromDB ( ObjectGuid::LowType  guid,
ObjectGuid  owner_guid,
Field fields,
uint32  entry 
)
overridevirtual

Reimplemented from Item.

107{
108 if (!Item::LoadFromDB(guid, owner_guid, fields, entry))
109 return false;
110
111 ItemTemplate const* itemProto = GetTemplate(); // checked in Item::LoadFromDB
113 // cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
114 for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
115 {
117 delete m_bagslot[i];
118 m_bagslot[i] = nullptr;
119 }
120
121 return true;
122}
virtual bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field *fields, uint32 entry)
Definition: Item.cpp:419

References CONTAINER_FIELD_NUM_SLOTS, CONTAINER_FIELD_SLOT_1, ItemTemplate::ContainerSlots, ObjectGuid::Empty, Item::GetTemplate(), Item::LoadFromDB(), m_bagslot, MAX_BAG_SIZE, Object::SetGuidValue(), and Object::SetUInt32Value().

◆ RemoveFromWorld()

void Bag::RemoveFromWorld ( )
overridevirtual

Reimplemented from Object.

61{
62 for (uint32 i = 0; i < GetBagSize(); ++i)
63 if (m_bagslot[i])
65
67}
virtual void RemoveFromWorld()
Definition: Object.cpp:166

References GetBagSize(), m_bagslot, and Object::RemoveFromWorld().

◆ RemoveItem()

void Bag::RemoveItem ( uint8  slot,
bool  update 
)
144{
145 ASSERT(slot < MAX_BAG_SIZE);
146
147 if (m_bagslot[slot])
148 m_bagslot[slot]->SetContainer(nullptr);
149
150 m_bagslot[slot] = nullptr;
152}
#define ASSERT
Definition: Errors.h:68
void SetContainer(Bag *container)
Definition: Item.h:286

References ASSERT, CONTAINER_FIELD_SLOT_1, ObjectGuid::Empty, m_bagslot, MAX_BAG_SIZE, Item::SetContainer(), and Object::SetGuidValue().

Referenced by Player::SwapItem().

◆ SaveToDB()

void Bag::SaveToDB ( CharacterDatabaseTransaction  trans)
overridevirtual

Reimplemented from Item.

102{
103 Item::SaveToDB(trans);
104}
virtual void SaveToDB(CharacterDatabaseTransaction trans)
Definition: Item.cpp:336

References Item::SaveToDB().

◆ StoreItem()

void Bag::StoreItem ( uint8  slot,
Item pItem,
bool  update 
)
155{
156 ASSERT(slot < MAX_BAG_SIZE);
157
158 if (pItem && pItem->GetGUID() != this->GetGUID())
159 {
160 m_bagslot[slot] = pItem;
161 SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), pItem->GetGUID());
164 pItem->SetContainer(this);
165 pItem->SetSlot(slot);
166 }
167}
ObjectGuid GetOwnerGUID() const
Definition: Item.h:231
void SetSlot(uint8 slot)
Definition: Item.h:284
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109

References ASSERT, CONTAINER_FIELD_SLOT_1, Object::GetGUID(), Item::GetOwnerGUID(), ITEM_FIELD_CONTAINED, ITEM_FIELD_OWNER, m_bagslot, MAX_BAG_SIZE, Item::SetContainer(), Object::SetGuidValue(), and Item::SetSlot().

Referenced by Player::_StoreItem(), and Player::SwapItem().

Member Data Documentation

◆ m_bagslot