TrinityCore
Loading...
Searching...
No Matches
Bag Class Reference

#include <Bag.h>

+ Inheritance diagram for Bag:

Public Member Functions

 Bag ()
 
 ~Bag ()
 
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)
 
Item * GetItemByPos (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) const override
 
std::string GetDebugInfo () const override
 
- Public Member Functions inherited from Item
Item * CloneItem (uint32 count, Player const *player=nullptr) const
 
 Item ()
 
std::string const & GetNameForLocaleIdx (LocaleConstant locale) const override
 
ItemTemplate const * GetTemplate () const
 
ObjectGuid GetOwnerGUID () const
 
void SetOwnerGUID (ObjectGuid guid)
 
ObjectGuid GetContainedIn () const
 
void SetContainedIn (ObjectGuid guid)
 
ObjectGuid GetCreator () const
 
void SetCreator (ObjectGuid guid)
 
ObjectGuid GetGiftCreator () const
 
void SetGiftCreator (ObjectGuid guid)
 
Player * GetOwner () const
 
void SetExpiration (uint32 expiration)
 
void SetBinding (bool val)
 
bool HasItemFlag (ItemFieldFlags flag) const
 
void SetItemFlag (ItemFieldFlags flags)
 
void RemoveItemFlag (ItemFieldFlags flags)
 
void ReplaceAllItemFlags (ItemFieldFlags flags)
 
bool IsSoulBound () const
 
bool IsBoundAccountWide () const
 
bool IsBindedNotWith (Player const *player) const
 
bool IsBoundByEnchant () const
 
void DeleteFromInventoryDB (CharacterDatabaseTransaction trans)
 
void SaveRefundDataToDB ()
 
void DeleteRefundDataFromDB (CharacterDatabaseTransaction *trans)
 
Bag * ToBag ()
 
Bag const * ToBag () const
 
bool IsRefundable () const
 
bool IsBOPTradeable () const
 
bool IsWrapped () const
 
bool IsLocked () const
 
bool IsBag () const
 
bool IsCurrencyToken () const
 
bool IsNotEmptyBag () const
 
bool IsBroken () const
 
void SetDurability (uint32 durability)
 
void SetMaxDurability (uint32 maxDurability)
 
bool CanBeTraded (bool mail=false, bool trade=false) const
 
void SetInTrade (bool b=true)
 
bool IsInTrade () const
 
uint32 CalculateDurabilityRepairCost (float discount, bool useRateConfig=true) 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
 
uint8 GetGemCountWithID (uint32 GemID) const
 
uint8 GetGemCountWithLimitCategory (uint32 limitCategory) const
 
InventoryResult CanBeMergedPartlyWith (ItemTemplate const *proto) const
 
uint8 GetSlot () const
 
Bag * GetContainer ()
 
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)
 
void SetCreatePlayedTime (uint32 createPlayedTime)
 
int32 GetSpellCharges (uint8 index=0) const
 
void SetSpellCharges (uint8 index, int32 value)
 
ItemUpdateState GetState () const
 
void SetState (ItemUpdateState state, Player *forplayer=nullptr)
 
bool IsInUpdateQueue () const
 
uint16 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
 
uint32 GetItemLevel () const
 
uint32 GetDisplayId () const
 
void SetNotRefundable (Player *owner, bool changestate=true, CharacterDatabaseTransaction *trans=nullptr)
 
void SetRefundRecipient (ObjectGuid const &guid)
 
void SetPaidMoney (uint32 money)
 
void SetPaidExtendedCost (uint32 iece)
 
ObjectGuid const & GetRefundRecipient () const
 
uint32 GetPaidMoney () const
 
uint32 GetPaidExtendedCost () const
 
void UpdatePlayedTime (Player *owner)
 
uint32 GetPlayedTime ()
 
bool IsRefundExpired ()
 
void SetSoulboundTradeable (GuidSet const &allowedLooters)
 
void ClearSoulboundTradeable (Player *currentOwner)
 
bool CheckSoulboundTradeExpire ()
 
void BuildUpdate (UpdateDataMapType &) override
 
bool AddToObjectUpdate () override
 
void RemoveFromObjectUpdate () override
 
uint32 GetScriptId () const
 
uint32 GetBuyPrice () const
 
uint32 GetSellPrice (bool forVendor=false) const
 
void SetPetitionId (uint32 petitionId)
 
void SetPetitionNumSignatures (uint32 signatures)
 
std::string GetDebugInfo () const override
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
bool IsInWorld () const
 
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
 
void SendUpdateToPlayer (Player *player)
 
void BuildValuesUpdateBlockForPlayer (UpdateData *data, Player const *target) const
 
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 ApplyModUInt16Value (uint16 index, uint8 offset, int16 val, bool apply)
 
void ApplyModPositiveFloatValue (uint16 index, float val, bool apply)
 
void ApplyModSignedFloatValue (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)
 
void ToggleByteFlag (uint16 index, uint8 offset, uint8 flag)
 
bool HasByteFlag (uint16 index, uint8 offset, uint8 flag) const
 
void ApplyModByteFlag (uint16 index, uint8 offset, uint8 flag, bool apply)
 
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
 
void SetIsNewObject (bool enable)
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &) const
 
void SetFieldNotifyFlag (uint16 flag)
 
void RemoveFieldNotifyFlag (uint16 flag)
 
void ForceValuesUpdateAtIndex (uint32)
 
bool IsWorldObject () const
 
WorldObject * ToWorldObject ()
 
WorldObject const * ToWorldObject () const
 
bool IsItem () const
 
Item * ToItem ()
 
Item const * ToItem () const
 
bool IsPlayer () const
 
Player * ToPlayer ()
 
Player const * ToPlayer () const
 
bool IsCreature () const
 
Creature * ToCreature ()
 
Creature const * ToCreature () const
 
bool IsUnit () const
 
Unit * ToUnit ()
 
Unit const * ToUnit () const
 
bool IsGameObject () const
 
GameObject * ToGameObject ()
 
GameObject const * ToGameObject () const
 
bool IsCorpse () const
 
Corpse * ToCorpse ()
 
Corpse const * ToCorpse () const
 
bool IsDynObject () const
 
DynamicObject * ToDynObject ()
 
DynamicObject const * ToDynObject () const
 
Trinity::unique_weak_ptr< Object > GetWeakPtr () const
 

Protected Member Functions

void SetBagSize (uint32 numSlots)
 
void SetSlot (uint32 slot, ObjectGuid guid)
 
- Protected Member Functions inherited from Object
 Object ()
 
void _InitValues ()
 
void _Create (ObjectGuid const &guid)
 
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 const *target) const
 
void AddToObjectUpdateIfNeeded ()
 

Protected Attributes

Item * m_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 Item * CreateItem (uint32 itemEntry, uint32 count, Player const *player=nullptr)
 
static void DeleteFromDB (CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
 
static void DeleteFromInventoryDB (CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
 
static uint32 GetBuyPrice (ItemTemplate const *proto)
 
static uint32 GetSellPrice (ItemTemplate const *proto)
 
- Static Public Member Functions inherited from Object
static ObjectGuid GetGUID (Object const *o)
 
static WorldObject * ToWorldObject (Object *o)
 
static WorldObject const * ToWorldObject (Object const *o)
 
static Item * ToItem (Object *o)
 
static Item const * ToItem (Object const *o)
 
static Player * ToPlayer (Object *o)
 
static Player const * ToPlayer (Object const *o)
 
static Creature * ToCreature (Object *o)
 
static Creature const * ToCreature (Object const *o)
 
static Unit * ToUnit (Object *o)
 
static Unit const * ToUnit (Object const *o)
 
static GameObject * ToGameObject (Object *o)
 
static GameObject const * ToGameObject (Object const *o)
 
static Corpse * ToCorpse (Object *o)
 
static Corpse const * ToCorpse (Object const *o)
 
static DynamicObject * ToDynObject (Object *o)
 
static DynamicObject const * ToDynObject (Object const *o)
 
- Public Attributes inherited from Item
Loot loot
 
bool m_lootGenerated
 

Detailed Description

Definition at line 26 of file Bag.h.

Constructor & Destructor Documentation

◆ Bag()

◆ ~Bag()

Bag::~Bag ( )

Member Function Documentation

◆ AddToWorld()

void Bag::AddToWorld ( )
overridevirtual

Reimplemented from Object.

Definition at line 53 of file Bag.cpp.

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

◆ BuildCreateUpdateBlockForPlayer()

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

Reimplemented from Object.

Definition at line 174 of file Bag.cpp.

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

◆ Create()

◆ DeleteFromDB()

void Bag::DeleteFromDB ( CharacterDatabaseTransaction  trans)
overridevirtual

Reimplemented from Item.

Definition at line 129 of file Bag.cpp.

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

◆ GetBagSize()

◆ GetDebugInfo()

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

Reimplemented from Object.

Definition at line 248 of file Bag.cpp.

References Item::GetDebugInfo().

◆ GetFreeSlots()

uint32 Bag::GetFreeSlots ( ) const

Definition at line 138 of file Bag.cpp.

References GetBagSize(), and m_bagslot.

◆ GetItemByPos()

Item * Bag::GetItemByPos ( uint8  slot) const

Definition at line 240 of file Bag.cpp.

References GetBagSize(), and m_bagslot.

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

◆ GetItemCount()

◆ GetItemCountWithLimitCategory()

uint32 Bag::GetItemCountWithLimitCategory ( uint32  limitCategory,
Item *  skipItem = nullptr 
) const

Definition at line 217 of file Bag.cpp.

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

◆ GetSlotByItemGUID()

uint8 Bag::GetSlotByItemGUID ( ObjectGuid  guid) const

Definition at line 230 of file Bag.cpp.

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

◆ IsEmpty()

bool Bag::IsEmpty ( ) const

Definition at line 184 of file Bag.cpp.

References GetBagSize(), and m_bagslot.

Referenced by Player::SwapItem().

◆ LoadFromDB()

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

◆ RemoveFromWorld()

void Bag::RemoveFromWorld ( )
overridevirtual

Reimplemented from Object.

Definition at line 62 of file Bag.cpp.

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

◆ RemoveItem()

void Bag::RemoveItem ( uint8  slot,
bool  update 
)

◆ SaveToDB()

void Bag::SaveToDB ( CharacterDatabaseTransaction  trans)
overridevirtual

Reimplemented from Item.

Definition at line 106 of file Bag.cpp.

References Item::SaveToDB().

◆ SetBagSize()

void Bag::SetBagSize ( uint32  numSlots)
inlineprotected

Definition at line 62 of file Bag.h.

References CONTAINER_FIELD_NUM_SLOTS, and Object::SetUInt32Value().

Referenced by Create().

◆ SetSlot()

void Bag::SetSlot ( uint32  slot,
ObjectGuid  guid 
)
inlineprotected

Definition at line 63 of file Bag.h.

References CONTAINER_FIELD_SLOT_1, and Object::SetGuidValue().

Referenced by Create().

◆ StoreItem()

Member Data Documentation

◆ m_bagslot


The documentation for this class was generated from the following files: