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

#include "Item.h"

Inheritance diagram for Item:
Object Bag

Public Member Functions

Item * CloneItem (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)
 
Player * GetOwner () 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)
 
Bag * ToBag ()
 
Bag const * ToBag () 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
 
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 GetEnchantmentsString () 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) 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 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
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &)
 
void SetFieldNotifyFlag (uint16 flag)
 
void RemoveFieldNotifyFlag (uint16 flag)
 
void ForceValuesUpdateAtIndex (uint32)
 
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 IsDynamicObject () const
 
DynamicObject * ToDynObject ()
 
DynamicObject const * ToDynObject () const
 
bool IsItem () const
 
virtual void Heartbeat ()
 
template<typename... T>
bool EntryEquals (T... entries) const
 

Static Public Member Functions

static Item * CreateItem (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

Loot loot
 
bool m_lootGenerated
 
- Public Attributes inherited from Object
DataMap CustomData
 

Private Attributes

std::string m_text
 
uint8 m_slot
 
Bag * m_container
 
ItemUpdateState uState
 
int32 uQueuePos
 
bool mb_in_trade
 
time_t m_lastPlayedTimeUpdate
 
uint32 m_refundRecipient
 
uint32 m_paidMoney
 
uint32 m_paidExtendedCost
 
AllowedLooterSet allowedGUIDs
 

Additional Inherited Members

- Protected Member Functions inherited from Object
 Object ()
 
void _InitValues ()
 
void _Create (ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
 
void _Create (ObjectGuid guid)
 
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)
 
void AddToObjectUpdateIfNeeded ()
 
- 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
 

Detailed Description

Constructor & Destructor Documentation

◆ Item()

Item::Item ( )
263{
266
268
270 m_slot = 0;
272 uQueuePos = -1;
273 m_container = nullptr;
274 m_lootGenerated = false;
275 mb_in_trade = false;
277
279 m_paidMoney = 0;
281}
@ ITEM_NEW
Definition Item.h:211
@ TYPEID_ITEM
Definition ObjectGuid.h:36
@ TYPEMASK_ITEM
Definition ObjectGuid.h:50
@ UPDATEFLAG_LOWGUID
Definition UpdateData.h:43
@ ITEM_END
Definition UpdateFields.h:73
int32 uQueuePos
Definition Item.h:373
Bag * m_container
Definition Item.h:371
bool mb_in_trade
Definition Item.h:374
uint32 m_paidMoney
Definition Item.h:377
time_t m_lastPlayedTimeUpdate
Definition Item.h:375
uint32 m_paidExtendedCost
Definition Item.h:378
bool m_lootGenerated
Definition Item.h:322
uint32 m_refundRecipient
Definition Item.h:376
uint8 m_slot
Definition Item.h:370
ItemUpdateState uState
Definition Item.h:372
uint16 m_objectType
Definition Object.h:259
uint16 m_valuesCount
Definition Object.h:273
uint16 m_updateFlag
Definition Object.h:262
TypeID m_objectTypeId
Definition Object.h:261
Seconds GetGameTime()
Definition GameTime.cpp:39

References GameTime::GetGameTime(), ITEM_END, ITEM_NEW, m_container, m_lastPlayedTimeUpdate, m_lootGenerated, Object::m_objectType, Object::m_objectTypeId, m_paidExtendedCost, m_paidMoney, m_refundRecipient, m_slot, Object::m_updateFlag, Object::m_valuesCount, mb_in_trade, TYPEID_ITEM, TYPEMASK_ITEM, UPDATEFLAG_LOWGUID, uQueuePos, and uState.

Member Function Documentation

◆ AddToObjectUpdate()

void Item::AddToObjectUpdate ( )
overridevirtual

Implements Object.

1176{
1177 if (Player* owner = GetOwner())
1178 owner->GetMap()->AddUpdateObject(this);
1179}
Player * GetOwner() const
Definition Item.cpp:543
Definition Player.h:1086

References GetOwner().

◆ AddToUpdateQueueOf()

void Item::AddToUpdateQueueOf ( Player *  player)
739{
740 if (IsInUpdateQueue())
741 return;
742
743 ASSERT(player);
744
745 if (player->GetGUID() != GetOwnerGUID())
746 {
747 LOG_DEBUG("entities.player.items", "Item::AddToUpdateQueueOf - Owner's guid ({}) and player's guid ({}) don't match!", GetOwnerGUID().ToString(), player->GetGUID().ToString());
748 return;
749 }
750
751 if (player->m_itemUpdateQueueBlocked)
752 return;
753
754 player->m_itemUpdateQueue.push_back(this);
755 uQueuePos = player->m_itemUpdateQueue.size() - 1;
756}
#define ASSERT
Definition Errors.h:68
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
ObjectGuid GetOwnerGUID() const
Definition Item.h:231
bool IsInUpdateQueue() const
Definition Item.h:329
std::string ToString() const
Definition ObjectGuid.cpp:49
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:120
std::vector< Item * > m_itemUpdateQueue
Definition Player.h:2861
bool m_itemUpdateQueueBlocked
Definition Player.h:2862
std::string ToString(Type &&val, Params &&... params)
Definition StringConvert.h:250

References ASSERT, Object::GetGUID(), GetOwnerGUID(), IsInUpdateQueue(), LOG_DEBUG, Player::m_itemUpdateQueue, Player::m_itemUpdateQueueBlocked, ObjectGuid::ToString(), and uQueuePos.

Referenced by SetState().

◆ BuildUpdate()

void Item::BuildUpdate ( UpdateDataMapType &  data_map)
overridevirtual

Reimplemented from Object.

1169{
1170 if (Player* owner = GetOwner())
1171 BuildFieldsUpdate(owner, data_map);
1172 ClearUpdateMask(false);
1173}
void BuildFieldsUpdate(Player *, UpdateDataMapType &)
Definition Object.cpp:543
void ClearUpdateMask(bool remove)
Definition Object.cpp:531

References Object::BuildFieldsUpdate(), Object::ClearUpdateMask(), and GetOwner().

◆ CanBeMergedPartlyWith()

InventoryResult Item::CanBeMergedPartlyWith ( ItemTemplate const *  proto) const
862{
863 // not allow merge looting currently items
864 if (m_lootGenerated)
866
867 // check item type
868 if (GetEntry() != proto->ItemId)
870
871 // check free space (full stacks can't be target of merge
872 if (GetCount() >= proto->GetMaxStackSize())
874
875 return EQUIP_ERR_OK;
876}
@ EQUIP_ERR_ALREADY_LOOTED
Definition Item.h:96
@ EQUIP_ERR_OK
Definition Item.h:47
@ EQUIP_ERR_ITEM_CANT_STACK
Definition Item.h:66
uint32 GetCount() const
Definition Item.h:272
uint32 GetEntry() const
Definition Object.h:123

References EQUIP_ERR_ALREADY_LOOTED, EQUIP_ERR_ITEM_CANT_STACK, EQUIP_ERR_OK, GetCount(), Object::GetEntry(), ItemTemplate::GetMaxStackSize(), ItemTemplate::ItemId, and m_lootGenerated.

Referenced by Player::CanStoreItem_InBag(), Player::CanStoreItem_InInventorySlots(), Player::CanStoreItem_InSpecificSlot(), and Player::CanStoreItems().

◆ CanBeTraded()

bool Item::CanBeTraded ( bool  mail = false,
bool  trade = false 
) const
789{
790 if ((!mail || !IsBoundAccountWide()) && (IsSoulBound() && (!IsBOPTradable() || !trade)))
791 return false;
792
793 if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()))
794 return false;
795
796 if (Player* owner = GetOwner())
797 {
798 if (owner->CanUnequipItem(GetPos(), false) != EQUIP_ERR_OK)
799 return false;
800
801 // Xinef: check if item is looted now
802 if (owner->GetLootGUID() == GetGUID())
803 return false;
804 }
805
806 if (IsBoundByTempEnchant()) // pussywizard
807 return false;
808
809 if ((!mail || !IsBoundAccountWide()) && IsBoundByEnchant())
810 return false;
811
812 return true;
813}
Definition Bag.h:28
bool IsBoundByTempEnchant() const
Definition Item.cpp:852
bool IsBoundAccountWide() const
Definition Item.h:237
bool IsSoulBound() const
Definition Item.h:236
bool IsBOPTradable() const
Definition Item.h:262
uint16 GetPos() const
Definition Item.h:285
bool IsBoundByEnchant() const
Definition Item.cpp:841
bool IsBag() const
Definition Item.h:254
ObjectGuid GetGUID() const
Definition Object.h:121
static bool IsBagPos(uint16 pos)
Definition PlayerStorage.cpp:594

References EQUIP_ERR_OK, Object::GetGUID(), GetOwner(), GetPos(), IsBag(), Player::IsBagPos(), IsBOPTradable(), IsBoundAccountWide(), IsBoundByEnchant(), IsBoundByTempEnchant(), and IsSoulBound().

Referenced by ToCloud9GrpcHandler::GetPlayerItemsByGuids(), WorldSession::HandleAuctionSellItem(), WorldSession::HandleSendMail(), and WorldSession::HandleSetTradeItemOpcode().

◆ CheckSoulboundTradeExpire()

bool Item::CheckSoulboundTradeExpire ( )
1293{
1294 Player* owner = GetOwner();
1295 if (!owner)
1296 return false; // retry later
1297
1298 if (GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + 2 * HOUR < owner->GetTotalPlayedTime())
1299 {
1301 return true; // remove from tradeable list
1302 }
1303
1304 return false;
1305}
@ ITEM_FIELD_CREATE_PLAYED_TIME
Definition UpdateFields.h:71
void ClearSoulboundTradeable(Player *currentOwner)
Definition Item.cpp:1279
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:303

References ClearSoulboundTradeable(), GetOwner(), Object::GetUInt32Value(), and ITEM_FIELD_CREATE_PLAYED_TIME.

◆ ClearEnchantment()

void Item::ClearEnchantment ( EnchantmentSlot  slot)
967{
968 if (!GetEnchantmentId(slot))
969 return;
970
971 for (uint8 x = 0; x < MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS; ++x)
974}
#define MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS
Definition DBCStructure.h:1874
std::uint8_t uint8
Definition Define.h:109
#define MAX_ENCHANTMENT_OFFSET
Definition Item.h:197
@ ITEM_CHANGED
Definition Item.h:210
@ ITEM_FIELD_ENCHANTMENT_1_1
Definition UpdateFields.h:43
void SetState(ItemUpdateState state, Player *forplayer=nullptr)
Definition Item.cpp:708
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition Item.h:304
void SetUInt32Value(uint16 index, uint32 value)
Definition Object.cpp:648

References GetEnchantmentId(), GetOwner(), ITEM_CHANGED, ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_OFFSET, MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS, SetState(), and Object::SetUInt32Value().

Referenced by Player::CastItemCombatSpell(), WorldSession::HandleCancelTempEnchantmentOpcode(), and Player::SetVirtualItemSlot().

◆ ClearSoulboundTradeable()

void Item::ClearSoulboundTradeable ( Player *  currentOwner)
1280{
1282 if (allowedGUIDs.empty())
1283 return;
1284
1285 allowedGUIDs.clear();
1286 SetState(ITEM_CHANGED, currentOwner);
1288 stmt->SetData(0, GetGUID().GetCounter());
1289 CharacterDatabase.Execute(stmt);
1290}
@ CHAR_DEL_ITEM_BOP_TRADE
Definition CharacterDatabase.h:121
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
@ ITEM_FIELD_FLAG_BOP_TRADEABLE
Definition ItemTemplate.h:117
@ ITEM_FIELD_FLAGS
Definition UpdateFields.h:42
AllowedLooterSet allowedGUIDs
Definition Item.h:379
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition Object.cpp:851
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157

References allowedGUIDs, CHAR_DEL_ITEM_BOP_TRADE, CharacterDatabase, Object::GetGUID(), ITEM_CHANGED, ITEM_FIELD_FLAG_BOP_TRADEABLE, ITEM_FIELD_FLAGS, Object::RemoveFlag(), PreparedStatementBase::SetData(), and SetState().

Referenced by Player::_LoadItem(), Player::_StoreItem(), CheckSoulboundTradeExpire(), Player::DestroyItem(), Spell::EffectEnchantItemPerm(), Spell::EffectEnchantItemPrismatic(), Spell::EffectEnchantItemTmp(), Player::EquipItem(), and WorldSession::HandleSocketOpcode().

◆ CloneItem()

Item * Item::CloneItem ( uint32  count,
Player const *  player = nullptr 
) const
1134{
1135 // player CAN be nullptr in which case we must not update random properties because that accesses player's item update queue
1136 Item* newItem = CreateItem(GetEntry(), count, player, true, player ? GetItemRandomPropertyId() : 0);
1137 if (!newItem)
1138 return nullptr;
1139
1144 return newItem;
1145}
@ ITEM_FIELD_FLAG_REFUNDABLE
Definition ItemTemplate.h:121
@ ITEM_FIELD_DURATION
Definition UpdateFields.h:40
@ ITEM_FIELD_CREATOR
Definition UpdateFields.h:37
@ ITEM_FIELD_GIFTCREATOR
Definition UpdateFields.h:38
Definition Item.h:220
static Item * CreateItem(uint32 item, uint32 count, Player const *player=nullptr, bool clone=false, uint32 randomPropertyId=0)
Definition Item.cpp:1099
int32 GetItemRandomPropertyId() const
Definition Item.h:295

References CreateItem(), Object::GetEntry(), GetItemRandomPropertyId(), Object::GetUInt32Value(), ITEM_FIELD_CREATOR, ITEM_FIELD_DURATION, ITEM_FIELD_FLAG_BOP_TRADEABLE, ITEM_FIELD_FLAG_REFUNDABLE, ITEM_FIELD_FLAGS, ITEM_FIELD_GIFTCREATOR, and Object::SetUInt32Value().

Referenced by Guild::BankMoveItemData::_StoreItem(), Player::_StoreItem(), WorldSession::HandleAcceptTradeOpcode(), WorldSession::HandleAuctionSellItem(), WorldSession::HandleSellItemOpcode(), and Player::SplitItem().

◆ Create()

bool Item::Create ( ObjectGuid::LowType  guidlow,
uint32  itemid,
Player const *  owner 
)
virtual

Reimplemented in Bag.

284{
285 Object::_Create(guidlow, 0, HighGuid::Item);
286
287 SetEntry(itemid);
288 SetObjectScale(1.0f);
289
290 SetGuidValue(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : ObjectGuid::Empty);
291 SetGuidValue(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : ObjectGuid::Empty);
292
293 ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid);
294 if (!itemProto)
295 return false;
296
300
301 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
302 SetSpellCharges(i, itemProto->Spells[i].SpellCharges);
303
306 sScriptMgr->OnItemCreate(this, itemProto, owner);
307 return true;
308}
#define MAX_ITEM_PROTO_SPELLS
Definition ItemTemplate.h:615
#define sObjectMgr
Definition ObjectMgr.h:1731
#define sScriptMgr
Definition ScriptMgr.h:769
@ 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
void SetSpellCharges(uint8 index, int32 value)
Definition Item.h:319
Definition ObjectGuid.h:121
void _Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
Definition Object.cpp:128
void SetGuidValue(uint16 index, ObjectGuid value)
Definition Object.cpp:721
void SetEntry(uint32 entry)
Definition Object.h:124
virtual void SetObjectScale(float scale)
Definition Object.h:127
Definition ItemTemplate.h:619
_Spell Spells[MAX_ITEM_PROTO_SPELLS]
Definition ItemTemplate.h:662
uint32 MaxDurability
Definition ItemTemplate.h:676
uint32 Duration
Definition ItemTemplate.h:686
int32 SpellCharges
Definition ItemTemplate.h:593

References Object::_Create(), ObjectGuid::Empty, Object::GetGUID(), Item, ITEM_FIELD_CONTAINED, ITEM_FIELD_CREATE_PLAYED_TIME, ITEM_FIELD_DURABILITY, ITEM_FIELD_DURATION, ITEM_FIELD_MAXDURABILITY, ITEM_FIELD_OWNER, ITEM_FIELD_STACK_COUNT, MAX_ITEM_PROTO_SPELLS, Object::SetEntry(), Object::SetGuidValue(), Object::SetObjectScale(), SetSpellCharges(), Object::SetUInt32Value(), sObjectMgr, and sScriptMgr.

Referenced by ToCloud9GrpcHandler::AddExistingItemToPlayer(), CreateItem(), and WorldSession::HandleMailCreateTextItem().

◆ CreateItem()

Item * Item::CreateItem ( uint32  item,
uint32  count,
Player const *  player = nullptr,
bool  clone = false,
uint32  randomPropertyId = 0 
)
static
1100{
1101 if (count < 1)
1102 return nullptr; //don't create item at zero count
1103
1104 ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item);
1105 if (!pProto)
1106 ABORT();
1107
1108 if (count > pProto->GetMaxStackSize())
1109 count = pProto->GetMaxStackSize();
1110
1111 ASSERT_NODEBUGINFO(count != 0 && "pProto->Stackable == 0 but checked at loading already");
1112
1114 if (sToCloud9Sidecar->IsCrossrealm() && player)
1115 realmId = player->GetGUID().GetRealmID();
1116
1117 Item* pItem = NewItemOrBag(pProto);
1118 if (!pItem->Create(sObjectMgr->GetGenerator<HighGuid::Item>().Generate(realmId), item, player))
1119 {
1120 delete pItem;
1121 return nullptr;
1122 }
1123
1124 pItem->SetCount(count);
1125 if (!clone)
1126 pItem->SetItemRandomProperties(randomPropertyId ? randomPropertyId : Item::GenerateItemRandomPropertyId(item));
1127 else if (randomPropertyId)
1128 pItem->SetItemRandomProperties(randomPropertyId);
1129
1130 return pItem;
1131}
Item * NewItemOrBag(ItemTemplate const *proto)
Definition Bag.h:67
std::uint16_t uint16
Definition Define.h:108
#define ABORT
Definition Errors.h:76
#define ASSERT_NODEBUGINFO
Definition Errors.h:69
constexpr uint16 DEFAULT_NON_CROSSREALM_REALM_ID
Definition ObjectGuid.h:31
#define sToCloud9Sidecar
Definition TC9Sidecar.h:81
virtual bool Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const *owner)
Definition Item.cpp:283
void SetItemRandomProperties(int32 randomPropId)
Definition Item.cpp:662
void SetCount(uint32 value)
Definition Item.h:273
static int32 GenerateItemRandomPropertyId(uint32 item_id)
Definition Item.cpp:616
uint32 GetMaxStackSize() const
Definition ItemTemplate.h:727

References ABORT, ASSERT_NODEBUGINFO, Create(), DEFAULT_NON_CROSSREALM_REALM_ID, GenerateItemRandomPropertyId(), Object::GetGUID(), ItemTemplate::GetMaxStackSize(), ObjectGuid::GetRealmID(), Item, NewItemOrBag(), SetCount(), SetItemRandomProperties(), sObjectMgr, and sToCloud9Sidecar.

Referenced by Player::CanEquipNewItem(), CloneItem(), AchievementMgr::CompletedAchievement(), Spell::EffectSummonChangeItem(), Player::EquipNewItem(), item_commandscript::HandleItemRefundCommand(), quest_commandscript::HandleQuestComplete(), quest_commandscript::HandleQuestReward(), spell_gen_spirit_of_competition_participant::HandleScript(), spell_gen_spirit_of_competition_winner::HandleScript(), send_commandscript::HandleSendItemsCommand(), MailDraft::prepareItems(), ItemRecovery::Restore(), ArenaSeasonTeamRewarderImpl::RewardWithMail(), Player::SendItemRetrievalMail(), SendRollWonItemViaMail(), WorldState::SendScourgeInvasionMail(), ServerMailMgr::SendServerMail(), and Player::StoreNewItem().

◆ DeleteFromDB() [1/2]

void Item::DeleteFromDB ( CharacterDatabaseTransaction  trans)
virtual

Reimplemented in Bag.

521{
522 DeleteFromDB(trans, GetGUID().GetCounter());
523}
static void DeleteFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
Definition Item.cpp:512

References DeleteFromDB(), and Object::GetGUID().

◆ DeleteFromDB() [2/2]

void Item::DeleteFromDB ( CharacterDatabaseTransaction  trans,
ObjectGuid::LowType  itemGuid 
)
static

◆ DeleteFromInventoryDB() [1/2]

void Item::DeleteFromInventoryDB ( CharacterDatabaseTransaction  trans)
534{
535 DeleteFromInventoryDB(trans, GetGUID().GetCounter());
536}
static void DeleteFromInventoryDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
Definition Item.cpp:526

References DeleteFromInventoryDB(), and Object::GetGUID().

◆ DeleteFromInventoryDB() [2/2]

◆ DeleteRefundDataFromDB()

void Item::DeleteRefundDataFromDB ( CharacterDatabaseTransaction *  trans)
1206{
1207 if (trans)
1208 {
1210 stmt->SetData(0, GetGUID().GetCounter());
1211 (*trans)->Append(stmt);
1212 }
1213}
@ CHAR_DEL_ITEM_REFUND_INSTANCE
Definition CharacterDatabase.h:382

References CHAR_DEL_ITEM_REFUND_INSTANCE, CharacterDatabase, Object::GetGUID(), and PreparedStatementBase::SetData().

Referenced by SetNotRefundable().

◆ FSetState()

◆ GemsFitSockets()

bool Item::GemsFitSockets ( ) const
977{
978 for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
979 {
981
982 if (!SocketColor) // no socket slot
983 continue;
984
985 uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
986 if (!enchant_id) // no gems on this socket
987 return false;
988
989 SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
990 if (!enchantEntry) // invalid gem id on this socket
991 return false;
992
993 uint8 GemColor = 0;
994
995 uint32 gemid = enchantEntry->GemID;
996 if (gemid)
997 {
998 ItemTemplate const* gemProto = sObjectMgr->GetItemTemplate(gemid);
999 if (gemProto)
1000 {
1001 GemPropertiesEntry const* gemProperty = sGemPropertiesStore.LookupEntry(gemProto->GemProperties);
1002 if (gemProperty)
1003 GemColor = gemProperty->color;
1004 }
1005 }
1006
1007 if (!(GemColor & SocketColor)) // bad gem color on this socket
1008 return false;
1009 }
1010 return true;
1011}
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
DBCStorage< GemPropertiesEntry > sGemPropertiesStore(GemPropertiesEntryfmt)
std::uint32_t uint32
Definition Define.h:107
SocketColor
Definition ItemTemplate.h:245
#define MAX_GEM_SOCKETS
Definition Item.h:188
EnchantmentSlot
Definition Item.h:168
@ SOCK_ENCHANTMENT_SLOT
Definition Item.h:171
ItemTemplate const * GetTemplate() const
Definition Item.cpp:538
Definition DBCStructure.h:1053
uint32 color
Definition DBCStructure.h:1056
uint32 GemProperties
Definition ItemTemplate.h:683
_Socket Socket[MAX_ITEM_PROTO_SOCKETS]
Definition ItemTemplate.h:681
Definition DBCStructure.h:1877
uint32 GemID
Definition DBCStructure.h:1888
uint32 Color
Definition ItemTemplate.h:602

References _Socket::Color, GemPropertiesEntry::color, SpellItemEnchantmentEntry::GemID, ItemTemplate::GemProperties, GetEnchantmentId(), GetTemplate(), MAX_GEM_SOCKETS, sGemPropertiesStore, sObjectMgr, SOCK_ENCHANTMENT_SLOT, ItemTemplate::Socket, and sSpellItemEnchantmentStore.

Referenced by WorldSession::HandleSocketOpcode().

◆ GenerateItemRandomPropertyId()

int32 Item::GenerateItemRandomPropertyId ( uint32  item_id)
static
617{
618 ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_id);
619
620 if (!itemProto)
621 return 0;
622
623 // item must have one from this field values not null if it can have random enchantments
624 if ((!itemProto->RandomProperty) && (!itemProto->RandomSuffix))
625 return 0;
626
627 // item can have not null only one from field values
628 if ((itemProto->RandomProperty) && (itemProto->RandomSuffix))
629 {
630 LOG_ERROR("sql.sql", "Item template {} have RandomProperty == {} and RandomSuffix == {}, but must have one from field =0", itemProto->ItemId, itemProto->RandomProperty, itemProto->RandomSuffix);
631 return 0;
632 }
633
634 // RandomProperty case
635 if (itemProto->RandomProperty)
636 {
637 uint32 randomPropId = GetItemEnchantMod(itemProto->RandomProperty);
638 ItemRandomPropertiesEntry const* random_id = sItemRandomPropertiesStore.LookupEntry(randomPropId);
639 if (!random_id)
640 {
641 LOG_ERROR("sql.sql", "Enchantment id #{} used but it doesn't have records in 'ItemRandomProperties.dbc'", randomPropId);
642 return 0;
643 }
644
645 return random_id->ID;
646 }
647 // RandomSuffix case
648 else
649 {
650 uint32 randomPropId = GetItemEnchantMod(itemProto->RandomSuffix);
651 ItemRandomSuffixEntry const* random_id = sItemRandomSuffixStore.LookupEntry(randomPropId);
652 if (!random_id)
653 {
654 LOG_ERROR("sql.sql", "Enchantment id #{} used but it doesn't have records in sItemRandomSuffixStore.", randomPropId);
655 return 0;
656 }
657
658 return -int32(random_id->ID);
659 }
660}
DBCStorage< ItemRandomSuffixEntry > sItemRandomSuffixStore(ItemRandomSuffixfmt)
DBCStorage< ItemRandomPropertiesEntry > sItemRandomPropertiesStore(ItemRandomPropertiesfmt)
std::int32_t int32
Definition Define.h:103
uint32 GetItemEnchantMod(int32 entry)
Definition ItemEnchantmentMgr.cpp:84
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
Definition DBCStructure.h:1246
uint32 ID
Definition DBCStructure.h:1247
Definition DBCStructure.h:1255
uint32 ID
Definition DBCStructure.h:1256
int32 RandomProperty
Definition ItemTemplate.h:672
int32 RandomSuffix
Definition ItemTemplate.h:673
uint32 ItemId
Definition ItemTemplate.h:620

References GetItemEnchantMod(), ItemRandomPropertiesEntry::ID, ItemRandomSuffixEntry::ID, ItemTemplate::ItemId, LOG_ERROR, ItemTemplate::RandomProperty, ItemTemplate::RandomSuffix, sItemRandomPropertiesStore, sItemRandomSuffixStore, and sObjectMgr.

Referenced by CreateItem(), and LootItem::LootItem().

◆ GetBagSlot()

◆ GetContainer()

Bag * Item::GetContainer ( )
inline

◆ GetCount()

uint32 Item::GetCount ( ) const
inline

References Object::GetUInt32Value(), and ITEM_FIELD_STACK_COUNT.

Referenced by Guild::_DoItemsMove(), Guild::BankMoveItemData::_ReserveSpace(), Player::_StoreItem(), AuctionHouseSearcher::AddAuction(), Player::CanBankItem(), CanBeMergedPartlyWith(), Player::CanEquipItem(), Guild::BankMoveItemData::CanStore(), Player::CanStoreItem(), Player::CanStoreItem_InBag(), Player::CanStoreItem_InInventorySlots(), Player::CanStoreItem_InSpecificSlot(), Player::CanStoreItems(), Player::CanTakeMoreSimilarItems(), Player::CanUnequipItem(), Spell::CheckItems(), Player::DestroyItem(), Player::DestroyItemCount(), WorldSession::DoLootRelease(), Spell::EffectMilling(), Spell::EffectProspecting(), Player::EquipItem(), GetDebugInfo(), Bag::GetItemCount(), Bag::GetItemCountWithLimitCategory(), ToCloud9GrpcHandler::GetPlayerItemsByGuids(), WorldSession::HandleAcceptTradeOpcode(), WorldSession::HandleAuctionSellItem(), WorldSession::HandleAutoBankItemOpcode(), WorldSession::HandleAutoStoreBankItemOpcode(), WorldSession::HandleBuybackItem(), WorldSession::HandleDestroyItemOpcode(), WorldSession::HandleMailTakeItem(), WorldSession::HandleSellItemOpcode(), WorldSession::HandleSendMail(), Player::HasItemCount(), Player::HasItemOrGemWithIdEquipped(), Player::HasItemOrGemWithLimitCategoryEquipped(), Guild::BankMoveItemData::LogAction(), Player::MoveItemToInventory(), SaveToDB(), WorldSession::SendMailList(), Player::SendNewItem(), Player::SplitItem(), Guild::BankMoveItemData::StoreItem(), and Player::SwapItem().

◆ GetDebugInfo()

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

Reimplemented from Object.

1308{
1309 std::stringstream sstr;
1310 sstr << Object::GetDebugInfo() << "\n"
1311 << std::boolalpha
1312 << "Owner: " << GetOwnerGUID().ToString() << " Count: " << GetCount()
1313 << " BagSlot: " << std::to_string(GetBagSlot()) << " Slot: " << std::to_string(GetSlot()) << " Equipped: " << IsEquipped();
1314 return sstr.str();
1315}
bool IsEquipped() const
Definition Item.cpp:783
uint8 GetBagSlot() const
Definition Item.cpp:778
virtual std::string GetDebugInfo() const
Definition Object.cpp:1000

References GetBagSlot(), GetCount(), Object::GetDebugInfo(), GetOwnerGUID(), GetSlot(), IsEquipped(), and ObjectGuid::ToString().

Referenced by Bag::GetDebugInfo().

◆ GetEnchantmentCharges()

◆ GetEnchantmentDuration()

◆ GetEnchantmentId()

◆ GetEnchantmentsString()

std::string Item::GetEnchantmentsString ( ) const
915{
916 std::ostringstream ssEnchants;
917 for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)
918 {
919 ssEnchants << GetEnchantmentId(EnchantmentSlot(i)) << ' ';
920 ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << ' ';
921 ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << ' ';
922 }
923 return ssEnchants.str();
924}
@ MAX_ENCHANTMENT_SLOT
Definition Item.h:183
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const
Definition Item.h:305
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const
Definition Item.h:306

References GetEnchantmentCharges(), GetEnchantmentDuration(), GetEnchantmentId(), and MAX_ENCHANTMENT_SLOT.

Referenced by ItemRecovery::Save(), and SaveToDB().

◆ GetEnchantRequiredLevel()

uint32 Item::GetEnchantRequiredLevel ( ) const
828{
829 uint32 level = 0;
830
831 // Check all enchants for required level
832 for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot)
833 if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)))
834 if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id))
835 if (enchantEntry->requiredLevel > level)
836 level = enchantEntry->requiredLevel;
837
838 return level;
839}
@ PERM_ENCHANTMENT_SLOT
Definition Item.h:169

References GetEnchantmentId(), MAX_ENCHANTMENT_SLOT, PERM_ENCHANTMENT_SLOT, and sSpellItemEnchantmentStore.

◆ GetGemCountWithID()

uint8 Item::GetGemCountWithID ( uint32  GemID) const
1021{
1022 uint8 count = 0;
1023 for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot <= PRISMATIC_ENCHANTMENT_SLOT; ++enchant_slot)
1024 {
1025 if (enchant_slot == BONUS_ENCHANTMENT_SLOT)
1026 continue;
1027
1028 uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
1029 if (!enchant_id)
1030 continue;
1031
1032 SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
1033 if (!enchantEntry)
1034 continue;
1035
1036 if (GemID == enchantEntry->GemID)
1037 ++count;
1038 }
1039 return count;
1040}
@ PRISMATIC_ENCHANTMENT_SLOT
Definition Item.h:175
@ BONUS_ENCHANTMENT_SLOT
Definition Item.h:174

References BONUS_ENCHANTMENT_SLOT, SpellItemEnchantmentEntry::GemID, GetEnchantmentId(), PRISMATIC_ENCHANTMENT_SLOT, SOCK_ENCHANTMENT_SLOT, and sSpellItemEnchantmentStore.

Referenced by Bag::GetItemCount(), and Player::HasItemOrGemWithIdEquipped().

◆ GetGemCountWithLimitCategory()

uint8 Item::GetGemCountWithLimitCategory ( uint32  limitCategory) const
1043{
1044 uint8 count = 0;
1045 for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot <= PRISMATIC_ENCHANTMENT_SLOT; ++enchant_slot)
1046 {
1047 if (enchant_slot == BONUS_ENCHANTMENT_SLOT)
1048 continue;
1049
1050 uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
1051 if (!enchant_id)
1052 continue;
1053
1054 SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
1055 if (!enchantEntry)
1056 continue;
1057
1058 ItemTemplate const* gemProto = sObjectMgr->GetItemTemplate(enchantEntry->GemID);
1059 if (!gemProto)
1060 continue;
1061
1062 if (gemProto->ItemLimitCategory == limitCategory)
1063 ++count;
1064 }
1065 return count;
1066}
uint32 ItemLimitCategory
Definition ItemTemplate.h:687

References BONUS_ENCHANTMENT_SLOT, SpellItemEnchantmentEntry::GemID, GetEnchantmentId(), ItemTemplate::ItemLimitCategory, PRISMATIC_ENCHANTMENT_SLOT, sObjectMgr, SOCK_ENCHANTMENT_SLOT, and sSpellItemEnchantmentStore.

Referenced by Player::CanEquipUniqueItem(), and Player::HasItemOrGemWithLimitCategoryEquipped().

◆ GetItemRandomPropertyId()

◆ GetItemSuffixFactor()

◆ GetMaxStackCount()

◆ GetOwner()

◆ GetOwnerGUID()

◆ GetPaidExtendedCost()

uint32 Item::GetPaidExtendedCost ( )
inline

◆ GetPaidMoney()

uint32 Item::GetPaidMoney ( )
inline

◆ GetPlayedTime()

uint32 Item::GetPlayedTime ( )

◆ GetPos()

◆ GetQueuePos()

uint32 Item::GetQueuePos ( ) const
inline

◆ GetRefundRecipient()

ObjectGuid::LowType Item::GetRefundRecipient ( )
inline

◆ GetScriptId()

◆ GetSkill()

uint32 Item::GetSkill ( )
550{
551 return GetTemplate()->GetSkill();
552}
uint32 GetSkill() const
Definition ItemTemplate.h:782

References ItemTemplate::GetSkill(), and GetTemplate().

Referenced by Player::CanUseItem(), Player::GetBaseWeaponSkillValue(), Unit::GetWeaponSkillValue(), and Player::UpdateWeaponSkill().

◆ GetSlot()

◆ GetSpell()

uint32 Item::GetSpell ( )
555{
556 ItemTemplate const* proto = GetTemplate();
557
558 switch (proto->Class)
559 {
561 switch (proto->SubClass)
562 {
564 return 196;
566 return 197;
568 return 264;
570 return 266;
572 return 198;
574 return 199;
576 return 200;
578 return 201;
580 return 202;
582 return 227;
584 return 1180;
586 return 2567;
588 return 3386;
590 return 5011;
592 return 5009;
593 default:
594 return 0;
595 }
596 case ITEM_CLASS_ARMOR:
597 switch (proto->SubClass)
598 {
600 return 9078;
602 return 9077;
604 return 8737;
606 return 750;
608 return 9116;
609 default:
610 return 0;
611 }
612 }
613 return 0;
614}
@ ITEM_SUBCLASS_WEAPON_CROSSBOW
Definition ItemTemplate.h:362
@ ITEM_SUBCLASS_WEAPON_GUN
Definition ItemTemplate.h:347
@ ITEM_SUBCLASS_WEAPON_AXE2
Definition ItemTemplate.h:345
@ ITEM_SUBCLASS_WEAPON_SPEAR
Definition ItemTemplate.h:361
@ ITEM_SUBCLASS_WEAPON_STAFF
Definition ItemTemplate.h:354
@ ITEM_SUBCLASS_WEAPON_MACE
Definition ItemTemplate.h:348
@ ITEM_SUBCLASS_WEAPON_MACE2
Definition ItemTemplate.h:349
@ ITEM_SUBCLASS_WEAPON_DAGGER
Definition ItemTemplate.h:359
@ ITEM_SUBCLASS_WEAPON_BOW
Definition ItemTemplate.h:346
@ ITEM_SUBCLASS_WEAPON_SWORD
Definition ItemTemplate.h:351
@ ITEM_SUBCLASS_WEAPON_AXE
Definition ItemTemplate.h:344
@ ITEM_SUBCLASS_WEAPON_WAND
Definition ItemTemplate.h:363
@ ITEM_SUBCLASS_WEAPON_THROWN
Definition ItemTemplate.h:360
@ ITEM_SUBCLASS_WEAPON_SWORD2
Definition ItemTemplate.h:352
@ ITEM_SUBCLASS_WEAPON_POLEARM
Definition ItemTemplate.h:350
@ ITEM_SUBCLASS_ARMOR_MAIL
Definition ItemTemplate.h:393
@ ITEM_SUBCLASS_ARMOR_CLOTH
Definition ItemTemplate.h:391
@ ITEM_SUBCLASS_ARMOR_LEATHER
Definition ItemTemplate.h:392
@ ITEM_SUBCLASS_ARMOR_SHIELD
Definition ItemTemplate.h:396
@ ITEM_SUBCLASS_ARMOR_PLATE
Definition ItemTemplate.h:394
@ ITEM_CLASS_ARMOR
Definition ItemTemplate.h:295
@ ITEM_CLASS_WEAPON
Definition ItemTemplate.h:293
uint32 Class
Definition ItemTemplate.h:621
uint32 SubClass
Definition ItemTemplate.h:622

References ItemTemplate::Class, GetTemplate(), ITEM_CLASS_ARMOR, ITEM_CLASS_WEAPON, ITEM_SUBCLASS_ARMOR_CLOTH, ITEM_SUBCLASS_ARMOR_LEATHER, ITEM_SUBCLASS_ARMOR_MAIL, ITEM_SUBCLASS_ARMOR_PLATE, ITEM_SUBCLASS_ARMOR_SHIELD, ITEM_SUBCLASS_WEAPON_AXE, ITEM_SUBCLASS_WEAPON_AXE2, ITEM_SUBCLASS_WEAPON_BOW, ITEM_SUBCLASS_WEAPON_CROSSBOW, ITEM_SUBCLASS_WEAPON_DAGGER, ITEM_SUBCLASS_WEAPON_GUN, ITEM_SUBCLASS_WEAPON_MACE, ITEM_SUBCLASS_WEAPON_MACE2, ITEM_SUBCLASS_WEAPON_POLEARM, ITEM_SUBCLASS_WEAPON_SPEAR, ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_SWORD, ITEM_SUBCLASS_WEAPON_SWORD2, ITEM_SUBCLASS_WEAPON_THROWN, ITEM_SUBCLASS_WEAPON_WAND, and ItemTemplate::SubClass.

◆ GetSpellCharges()

int32 Item::GetSpellCharges ( uint8  index = 0) const
inline

◆ GetState()

◆ GetTemplate()

ItemTemplate const * Item::GetTemplate ( ) const
539{
540 return sObjectMgr->GetItemTemplate(GetEntry());
541}

References Object::GetEntry(), and sObjectMgr.

Referenced by Player::_ApplyAllItemMods(), Player::_ApplyAllLevelScaleItemMods(), Player::_ApplyItemMods(), Player::_LoadItem(), Player::_RemoveAllItemMods(), Player::_SaveInventory(), Player::_StoreItem(), AuctionHouseSearcher::AddAuction(), AddItemsSetItem(), Player::AddQuestAndCheckCompletion(), Player::ApplyEnchantment(), Player::ApplyEquipCooldown(), Player::ApplyItemEquipSpell(), Player::ApplyItemObtainSpells(), Player::AutoUnequipOffhandIfNeed(), AuraEffect::CalculateAmount(), Player::CanBankItem(), Player::CanEquipItem(), Player::CanEquipUniqueItem(), Guild::BankMoveItemData::CanStore(), Player::CanStoreItem_InBag(), Player::CanStoreItem_InSpecificSlot(), Player::CanStoreItems(), Player::CanUnequipItem(), Player::CanUseItem(), Player::CastItemUseSpell(), Player::CheckAmmoCompatibility(), Spell::CheckCast(), Spell::CheckItems(), Player::CreateCorpse(), Player::DestroyItem(), instance_trial_of_the_crusader::DoCheckDedicatedInsanity(), Spell::DoCreateItem(), WorldSession::DoLootRelease(), Spell::DoSpellHitOnUnit(), Player::DurabilityRepair(), Spell::EffectDisEnchant(), Spell::EffectEnchantItemPerm(), Spell::EffectEnchantItemPrismatic(), Spell::EffectEnchantItemTmp(), Spell::EffectFeedPet(), Spell::EffectMilling(), Spell::EffectOpenLock(), Spell::EffectProspecting(), Player::EquipItem(), EquippedOk(), GemsFitSockets(), Unit::GetAPMultiplier(), AuctionHouseMgr::GetAuctionDeposit(), Player::GetAverageItemLevel(), Player::GetAverageItemLevelForDF(), Player::GetItemCount(), Bag::GetItemCount(), GetMaxStackCount(), GetScriptId(), Player::GetShield(), GetSkill(), GetSpell(), Player::GetTotalItemLevel(), Unit::GetUnitBlockChance(), Player::GetWeaponForAttack(), WorldSession::HandleAcceptTradeOpcode(), WorldSession::HandleAuctionSellItem(), WorldSession::HandleAutoEquipItemOpcode(), debug_commandscript::HandleDebugItemExpireCommand(), WorldSession::HandleDestroyItemOpcode(), WorldSession::HandleMailTakeItem(), WorldSession::HandleOpenItemOpcode(), WorldSession::HandleOpenWrappedItemCallback(), WorldSession::HandleReadItem(), WorldSession::HandleSellItemOpcode(), WorldSession::HandleSendMail(), WorldSession::HandleSocketOpcode(), WorldSession::HandleUseItemOpcode(), WorldSession::HandleWrapItemOpcode(), Player::HasItemOrGemWithLimitCategoryEquipped(), Player::HasItemTotemCategory(), hasQuest(), HasSocket(), IsArmorVellum(), IsBag(), IsBoundAccountWide(), IsConjuredConsumable(), IsCurrencyToken(), IsFitToSpellRequirements(), IsLimitedToAnotherMapOrZone(), IsPotion(), Player::IsTwoHandUsed(), IsWeaponVellum(), LoadFromDB(), Bag::LoadFromDB(), Guild::BankMoveItemData::LogAction(), Player::RemoveItem(), ItemRecovery::Save(), Player::SendEquipError(), Player::SendLoot(), SendRollWonItemViaMail(), Player::SetRegularAttackTime(), Player::StoreNewItem(), Spell::SummonGuardian(), Player::SwapItem(), Spell::TakeAmmo(), Spell::TakeCastItem(), Spell::TakeReagents(), Player::ToggleMetaGemsActive(), Player::UpdateDamageDoneMods(), UpdateDuration(), Player::UpdateItemDuration(), Player::UpdateWeaponSkill(), Player::VisualizeItem(), and Spell::WriteAmmoToPacket().

◆ GetText()

std::string const & Item::GetText ( ) const
inline
309{ return m_text; }
std::string m_text
Definition Item.h:369

References m_text.

Referenced by ToCloud9GrpcHandler::GetPlayerItemsByGuids().

◆ HasEnchantRequiredSkill()

bool Item::HasEnchantRequiredSkill ( Player const *  player) const
816{
817 // Check all enchants for required skill
818 for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot)
819 if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)))
820 if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id))
821 if (enchantEntry->requiredSkill && player->GetSkillValue(enchantEntry->requiredSkill) < enchantEntry->requiredSkillValue)
822 return false;
823
824 return true;
825}

References GetEnchantmentId(), Player::GetSkillValue(), MAX_ENCHANTMENT_SLOT, PERM_ENCHANTMENT_SLOT, and sSpellItemEnchantmentStore.

◆ hasInvolvedQuest()

bool Item::hasInvolvedQuest ( uint32  ) const
inlineoverridevirtual

Reimplemented from Object.

337{ return false; }

◆ hasQuest()

bool Item::hasQuest ( uint32  quest_id) const
inlineoverridevirtual

Reimplemented from Object.

336{ return GetTemplate()->StartQuest == quest_id; }
uint32 StartQuest
Definition ItemTemplate.h:668

References GetTemplate(), and ItemTemplate::StartQuest.

◆ HasSocket()

bool Item::HasSocket ( ) const
1014{
1015 // There can only be one socket added, and it's always in slot `PRISMATIC_ENCHANTMENT_SLOT`.
1016 // Built-in sockets Socket from upgrade
1018}

References _Socket::Color, GetEnchantmentId(), GetTemplate(), PRISMATIC_ENCHANTMENT_SLOT, and ItemTemplate::Socket.

Referenced by Player::_ApplyItemMods(), Player::CorrectMetaGemEnchants(), Player::EnchantmentFitsRequirements(), Player::GetItemCount(), Bag::GetItemCount(), and Player::HasItemOrGemWithIdEquipped().

◆ IsArmorVellum()

bool Item::IsArmorVellum ( ) const
inline
340{ return GetTemplate()->IsArmorVellum(); }
bool IsArmorVellum() const
Definition ItemTemplate.h:819

References GetTemplate(), and ItemTemplate::IsArmorVellum().

Referenced by Spell::CheckItems(), and Spell::EffectEnchantItemPerm().

◆ IsBag()

bool Item::IsBag ( ) const
inline

◆ IsBindedNotWith()

bool Item::IsBindedNotWith ( Player const *  player) const
1148{
1149 // not binded item
1150 if (!IsSoulBound())
1151 return false;
1152
1153 // own item
1154 if (GetOwnerGUID() == player->GetGUID())
1155 return false;
1156
1157 if (IsBOPTradable())
1158 if (allowedGUIDs.find(player->GetGUID()) != allowedGUIDs.end())
1159 return false;
1160
1161 // BOA item case
1162 if (IsBoundAccountWide())
1163 return false;
1164
1165 return true;
1166}

References allowedGUIDs, Object::GetGUID(), GetOwnerGUID(), IsBOPTradable(), IsBoundAccountWide(), and IsSoulBound().

Referenced by Player::CanBankItem(), Player::CanEquipItem(), Player::CanStoreItem(), Player::CanStoreItems(), Player::CanUseItem(), and WorldSession::HandleSetTradeItemOpcode().

◆ IsBOPTradable()

bool Item::IsBOPTradable ( ) const
inline

◆ IsBoundAccountWide()

bool Item::IsBoundAccountWide ( ) const
inline
@ ITEM_FLAG_IS_BOUND_TO_ACCOUNT
Definition ItemTemplate.h:174
bool HasFlag(ItemFlags flag) const
Definition ItemTemplate.h:827

References GetTemplate(), ItemTemplate::HasFlag(), and ITEM_FLAG_IS_BOUND_TO_ACCOUNT.

Referenced by CanBeTraded(), WorldSession::HandleSendMail(), and IsBindedNotWith().

◆ IsBoundByEnchant()

bool Item::IsBoundByEnchant ( ) const
842{
843 // Check all enchants for soulbound
844 for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot)
845 if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)))
846 if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id))
847 if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
848 return true;
849 return false;
850}
@ ENCHANTMENT_CAN_SOULBOUND
Definition Item.h:201

References ENCHANTMENT_CAN_SOULBOUND, GetEnchantmentId(), MAX_ENCHANTMENT_SLOT, PERM_ENCHANTMENT_SLOT, and sSpellItemEnchantmentStore.

Referenced by CanBeTraded().

◆ IsBoundByTempEnchant()

bool Item::IsBoundByTempEnchant ( ) const
853{
855 if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id))
856 if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
857 return true;
858 return false;
859}
@ TEMP_ENCHANTMENT_SLOT
Definition Item.h:170

References ENCHANTMENT_CAN_SOULBOUND, GetEnchantmentId(), sSpellItemEnchantmentStore, and TEMP_ENCHANTMENT_SLOT.

Referenced by CanBeTraded().

◆ IsBroken()

◆ IsConjuredConsumable()

bool Item::IsConjuredConsumable ( ) const
inline
341{ return GetTemplate()->IsConjuredConsumable(); }
bool IsConjuredConsumable() const
Definition ItemTemplate.h:820

References GetTemplate(), and ItemTemplate::IsConjuredConsumable().

◆ IsCurrencyToken()

bool Item::IsCurrencyToken ( ) const
inline
255{ return GetTemplate()->IsCurrencyToken(); }
bool IsCurrencyToken() const
Definition ItemTemplate.h:725

References GetTemplate(), and ItemTemplate::IsCurrencyToken().

◆ IsEquipped()

◆ IsFitToSpellRequirements()

bool Item::IsFitToSpellRequirements ( SpellInfo const *  spellInfo) const
879{
880 ItemTemplate const* proto = GetTemplate();
881
882 if (spellInfo->EquippedItemClass != -1) // -1 == any item class
883 {
884 // Special case - accept vellum for armor/weapon requirements
885 if ((spellInfo->EquippedItemClass == ITEM_CLASS_ARMOR && proto->IsArmorVellum())
886 || (spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON && proto->IsWeaponVellum()))
887 if (spellInfo->IsAbilityOfSkillType(SKILL_ENCHANTING)) // only for enchanting spells
888 return true;
889
890 if (spellInfo->EquippedItemClass != int32(proto->Class))
891 return false; // wrong item class
892
893 if (spellInfo->EquippedItemSubClassMask != 0) // 0 == any subclass
894 {
895 if ((spellInfo->EquippedItemSubClassMask & (1 << proto->SubClass)) == 0)
896 return false; // subclass not present in mask
897 }
898 }
899
900 if (spellInfo->EquippedItemInventoryTypeMask != 0) // 0 == any inventory type
901 {
902 // Special case - accept weapon type for main and offhand requirements
903 if (proto->InventoryType == INVTYPE_WEAPON &&
904 (spellInfo->EquippedItemInventoryTypeMask & (1 << INVTYPE_WEAPONMAINHAND) ||
905 spellInfo->EquippedItemInventoryTypeMask & (1 << INVTYPE_WEAPONOFFHAND)))
906 return true;
907 else if ((spellInfo->EquippedItemInventoryTypeMask & (1 << proto->InventoryType)) == 0)
908 return false; // inventory type not present in mask
909 }
910
911 return true;
912}
@ INVTYPE_WEAPON
Definition ItemTemplate.h:269
@ INVTYPE_WEAPONMAINHAND
Definition ItemTemplate.h:277
@ INVTYPE_WEAPONOFFHAND
Definition ItemTemplate.h:278
@ SKILL_ENCHANTING
Definition SharedDefines.h:3187
bool IsWeaponVellum() const
Definition ItemTemplate.h:818

References ItemTemplate::Class, SpellInfo::EquippedItemClass, SpellInfo::EquippedItemInventoryTypeMask, SpellInfo::EquippedItemSubClassMask, GetTemplate(), ItemTemplate::InventoryType, INVTYPE_WEAPON, INVTYPE_WEAPONMAINHAND, INVTYPE_WEAPONOFFHAND, SpellInfo::IsAbilityOfSkillType(), ItemTemplate::IsArmorVellum(), ItemTemplate::IsWeaponVellum(), ITEM_CLASS_ARMOR, ITEM_CLASS_WEAPON, SKILL_ENCHANTING, and ItemTemplate::SubClass.

Referenced by Player::CheckAttackFitToAuraRequirement(), Spell::CheckItems(), Aura::GetProcEffectMask(), Player::HasItemFitToSpellRequirements(), Player::RemoveItemDependentAurasAndCasts(), and Player::UpdateExpertise().

◆ IsInBag()

bool Item::IsInBag ( ) const
inline
288{ return m_container != nullptr; }

References m_container.

Referenced by IsEquipped().

◆ IsInTrade()

bool Item::IsInTrade ( ) const
inline
260{ return mb_in_trade; }

References mb_in_trade.

Referenced by Player::CanStoreItems(), and Player::HasItemCount().

◆ IsInUpdateQueue()

bool Item::IsInUpdateQueue ( ) const
inline

◆ IsLimitedToAnotherMapOrZone()

bool Item::IsLimitedToAnotherMapOrZone ( uint32  cur_mapId,
uint32  cur_zoneId 
) const
1069{
1070 ItemTemplate const* proto = GetTemplate();
1071 return proto && ((proto->Map && proto->Map != cur_mapId) || (proto->Area && proto->Area != cur_zoneId));
1072}
uint32 Map
Definition ItemTemplate.h:678
uint32 Area
Definition ItemTemplate.h:677

References ItemTemplate::Area, GetTemplate(), and ItemTemplate::Map.

Referenced by Player::_LoadItem().

◆ IsLocked()

bool Item::IsLocked ( ) const
inline

◆ IsNotEmptyBag()

bool Item::IsNotEmptyBag ( ) const

◆ IsPotion()

bool Item::IsPotion ( ) const
inline
338{ return GetTemplate()->IsPotion(); }
bool IsPotion() const
Definition ItemTemplate.h:817

References GetTemplate(), and ItemTemplate::IsPotion().

Referenced by Spell::CheckCast(), and Spell::SendSpellCooldown().

◆ IsRefundable()

◆ IsRefundExpired()

bool Item::IsRefundExpired ( )
1269{
1270 return (GetPlayedTime() > 2 * HOUR);
1271}
constexpr auto HOUR
Definition Common.h:48
uint32 GetPlayedTime()
Definition Item.cpp:1261

References GetPlayedTime(), and HOUR.

Referenced by Player::RefundItem().

◆ IsSoulBound()

◆ IsWeaponVellum()

bool Item::IsWeaponVellum ( ) const
inline

◆ IsWrapped()

◆ LoadFromDB()

bool Item::LoadFromDB ( ObjectGuid::LowType  guid,
ObjectGuid  owner_guid,
Field *  fields,
uint32  entry 
)
virtual

Reimplemented in Bag.

414{
415 // 0 1 2 3 4 5 6 7 8 9 10
416 //result = CharacterDatabase.Query("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '{}'", guid);
417
418 // create item before any checks for store correct guid
419 // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
421
422 // Set entry, MUST be before proto check
423 SetEntry(entry);
424 SetObjectScale(1.0f);
425
426 ItemTemplate const* proto = GetTemplate();
427 if (!proto)
428 {
429 LOG_ERROR("entities.item", "Invalid entry {} for item {}. Refusing to load.", GetEntry(), GetGUID().ToString());
430 return false;
431 }
432
433 // set owner (not if item is only loaded for gbank/auction/mail
434 if (owner_guid)
435 SetOwnerGUID(owner_guid);
436
437 bool need_save = false; // need explicit save data at load fixes
438 SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>()));
439 SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid::Create<HighGuid::Player>(fields[1].Get<uint32>()));
440 SetCount(fields[2].Get<uint32>());
441
442 uint32 duration = fields[3].Get<uint32>();
444 // update duration if need, and remove if not need
445 if ((proto->Duration == 0) != (duration == 0))
446 {
448 need_save = true;
449 }
450
451 std::vector<std::string_view> tokens = Acore::Tokenize(fields[4].Get<std::string_view>(), ' ', false);
452 if (tokens.size() == MAX_ITEM_PROTO_SPELLS)
453 {
454 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
455 {
456 if (Optional<int32> charges = Acore::StringTo<int32>(tokens[i]))
457 SetSpellCharges(i, *charges);
458 else
459 LOG_ERROR("entities.item", "Invalid charge info '{}' for item {}, charge data not loaded.", tokens.at(i), GetGUID().ToString());
460 }
461 }
462
463 SetUInt32Value(ITEM_FIELD_FLAGS, fields[5].Get<uint32>());
464 // Remove bind flag for items vs NO_BIND set
465 if (IsSoulBound() && proto->Bonding == NO_BIND && sScriptMgr->CanApplySoulboundFlag(this, proto))
466 {
468 need_save = true;
469 }
470
471 std::string enchants = fields[6].Get<std::string>();
472
474 {
475 LOG_WARN("entities.item", "Invalid enchantment data '{}' for item {}. Forcing partial load.", fields[6].Get<std::string>(), GetGUID().ToString());
476 }
477
478 SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].Get<int16>());
479 // recalculate suffix factor
480 if (GetItemRandomPropertyId() < 0)
482
483 uint32 durability = fields[8].Get<uint16>();
485
486 // update max durability (and durability) if need
487 // xinef: do not overwrite durability for wrapped items!!
489 if (durability > proto->MaxDurability && !IsWrapped())
490 {
492 need_save = true;
493 }
494
495 SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, fields[9].Get<uint32>());
496 SetText(fields[10].Get<std::string>());
497
498 if (need_save) // normal item changed state set not work at loading
499 {
504 stmt->SetData(3, guid);
505 CharacterDatabase.Execute(stmt);
506 }
507
508 return true;
509}
@ CHAR_UPD_ITEM_INSTANCE_ON_LOAD
Definition CharacterDatabase.h:126
@ NO_BIND
Definition ItemTemplate.h:95
#define LOG_WARN(filterType__,...)
Definition Log.h:149
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:24
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:113
void UpdateItemSuffixFactor()
Definition Item.cpp:700
bool IsWrapped() const
Definition Item.h:263
void SetText(std::string const &text)
Definition Item.h:310
void SetOwnerGUID(ObjectGuid guid)
Definition Item.h:232
void SetInt32Value(uint16 index, int32 value)
Definition Object.cpp:635
void ApplyModFlag(uint16 index, uint32 flag, bool apply)
Definition Object.cpp:890
bool _LoadIntoDataField(std::string const &data, uint32 startOffset, uint32 count)
Definition Object.cpp:610
std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition Tokenize.cpp:20
uint32 Bonding
Definition ItemTemplate.h:663

References Object::_Create(), Object::_LoadIntoDataField(), Object::ApplyModFlag(), ItemTemplate::Bonding, CHAR_UPD_ITEM_INSTANCE_ON_LOAD, CharacterDatabase, ItemTemplate::Duration, Field::Get(), Object::GetEntry(), Object::GetGUID(), GetItemRandomPropertyId(), GetTemplate(), Object::GetUInt32Value(), IsSoulBound(), IsWrapped(), Item, ITEM_FIELD_CREATE_PLAYED_TIME, ITEM_FIELD_CREATOR, ITEM_FIELD_DURABILITY, ITEM_FIELD_DURATION, ITEM_FIELD_ENCHANTMENT_1_1, ITEM_FIELD_FLAG_SOULBOUND, ITEM_FIELD_FLAGS, ITEM_FIELD_GIFTCREATOR, ITEM_FIELD_MAXDURABILITY, ITEM_FIELD_RANDOM_PROPERTIES_ID, LOG_ERROR, LOG_WARN, MAX_ENCHANTMENT_OFFSET, MAX_ENCHANTMENT_SLOT, MAX_ITEM_PROTO_SPELLS, ItemTemplate::MaxDurability, NO_BIND, SetCount(), PreparedStatementBase::SetData(), Object::SetEntry(), Object::SetGuidValue(), Object::SetInt32Value(), Object::SetObjectScale(), SetOwnerGUID(), SetSpellCharges(), SetText(), Object::SetUInt32Value(), sScriptMgr, Acore::Tokenize(), and UpdateItemSuffixFactor().

Referenced by Player::_LoadItem(), Player::_LoadMailedItem(), mail_commandscript::HandleMailReturnCommand(), AuctionHouseMgr::LoadAuctionItems(), Bag::LoadFromDB(), and Guild::BankTab::LoadItemFromDB().

◆ RemoveFromObjectUpdate()

void Item::RemoveFromObjectUpdate ( )
overridevirtual

Implements Object.

1182{
1183 if (Player* owner = GetOwner())
1184 owner->GetMap()->RemoveUpdateObject(this);
1185}

References GetOwner().

◆ RemoveFromUpdateQueueOf()

void Item::RemoveFromUpdateQueueOf ( Player *  player)
759{
760 if (!IsInUpdateQueue())
761 return;
762
763 ASSERT(player);
764
765 if (player->GetGUID() != GetOwnerGUID())
766 {
767 LOG_DEBUG("entities.player.items", "Item::RemoveFromUpdateQueueOf - Owner's guid ({}) and player's guid ({}) don't match!", GetOwnerGUID().ToString(), player->GetGUID().ToString());
768 return;
769 }
770
771 if (player->m_itemUpdateQueueBlocked)
772 return;
773
774 player->m_itemUpdateQueue[uQueuePos] = nullptr;
775 uQueuePos = -1;
776}

References ASSERT, Object::GetGUID(), GetOwnerGUID(), IsInUpdateQueue(), LOG_DEBUG, Player::m_itemUpdateQueue, Player::m_itemUpdateQueueBlocked, ObjectGuid::ToString(), and uQueuePos.

Referenced by Player::CanEquipNewItem(), WorldSession::HandleSellItemOpcode(), and SetState().

◆ SaveRefundDataToDB()

void Item::SaveRefundDataToDB ( )
1188{
1189 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1190
1192 stmt->SetData(0, GetGUID().GetCounter());
1193 trans->Append(stmt);
1194
1195 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEM_REFUND_INSTANCE);
1196 stmt->SetData(0, GetGUID().GetCounter());
1197 stmt->SetData(1, GetRefundRecipient());
1198 stmt->SetData(2, GetPaidMoney());
1199 stmt->SetData(3, uint16(GetPaidExtendedCost()));
1200 trans->Append(stmt);
1201
1202 CharacterDatabase.CommitTransaction(trans);
1203}
@ CHAR_INS_ITEM_REFUND_INSTANCE
Definition CharacterDatabase.h:383
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition DatabaseEnvFwd.h:69
uint32 GetPaidExtendedCost()
Definition Item.h:350
uint32 GetPaidMoney()
Definition Item.h:349
ObjectGuid::LowType GetRefundRecipient()
Definition Item.h:348

References CHAR_DEL_ITEM_REFUND_INSTANCE, CHAR_INS_ITEM_REFUND_INSTANCE, CharacterDatabase, Object::GetGUID(), GetPaidExtendedCost(), GetPaidMoney(), GetRefundRecipient(), and PreparedStatementBase::SetData().

Referenced by Player::_StoreOrEquipNewItem().

◆ SaveToDB()

void Item::SaveToDB ( CharacterDatabaseTransaction  trans)
virtual

Reimplemented in Bag.

338{
339 bool isInTransaction = static_cast<bool>(trans);
340 if (!isInTransaction)
341 trans = CharacterDatabase.BeginTransaction();
342
344 switch (uState)
345 {
346 case ITEM_NEW:
347 case ITEM_CHANGED:
348 {
349 uint8 index = 0;
351 stmt->SetData( index, GetEntry());
352 stmt->SetData(++index, GetOwnerGUID().GetRawValue());
353 stmt->SetData(++index, GetGuidValue(ITEM_FIELD_CREATOR).GetCounter());
354 stmt->SetData(++index, GetGuidValue(ITEM_FIELD_GIFTCREATOR).GetCounter());
355 stmt->SetData(++index, GetCount());
357
358 std::ostringstream ssSpells;
359 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
360 ssSpells << GetSpellCharges(i) << ' ';
361 stmt->SetData(++index, ssSpells.str());
362
363 stmt->SetData(++index, GetUInt32Value(ITEM_FIELD_FLAGS));
364
365 stmt->SetData(++index, GetEnchantmentsString());
366
367 stmt->SetData (++index, GetItemRandomPropertyId());
370 stmt->SetData(++index, m_text);
371 stmt->SetData(++index, guid);
372
373 trans->Append(stmt);
374
375 if ((uState == ITEM_CHANGED) && IsWrapped())
376 {
377 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER);
378 stmt->SetData(0, GetOwnerGUID().GetRawValue());
379 stmt->SetData(1, guid);
380 trans->Append(stmt);
381 }
382 break;
383 }
384 case ITEM_REMOVED:
385 {
387 stmt->SetData(0, guid);
388 trans->Append(stmt);
389
390 if (IsWrapped())
391 {
392 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
393 stmt->SetData(0, guid);
394 trans->Append(stmt);
395 }
396
397 if (!isInTransaction)
398 CharacterDatabase.CommitTransaction(trans);
399
400 delete this;
401 return;
402 }
403 case ITEM_UNCHANGED:
404 break;
405 }
406
408
409 if (!isInTransaction)
410 CharacterDatabase.CommitTransaction(trans);
411}
@ CHAR_UPD_ITEM_INSTANCE
Definition CharacterDatabase.h:125
@ CHAR_UPD_GIFT_OWNER
Definition CharacterDatabase.h:130
@ CHAR_DEL_GIFT
Definition CharacterDatabase.h:131
@ CHAR_REP_ITEM_INSTANCE
Definition CharacterDatabase.h:124
@ ITEM_REMOVED
Definition Item.h:212
@ ITEM_UNCHANGED
Definition Item.h:209
std::string GetEnchantmentsString() const
Definition Item.cpp:914
int32 GetSpellCharges(uint8 index=0) const
Definition Item.h:318
LowType GetCounter() const
Definition ObjectGuid.h:149
uint32 LowType
Definition ObjectGuid.h:125

References CHAR_DEL_GIFT, CHAR_DEL_ITEM_INSTANCE, CHAR_REP_ITEM_INSTANCE, CHAR_UPD_GIFT_OWNER, CHAR_UPD_ITEM_INSTANCE, CharacterDatabase, GetCount(), ObjectGuid::GetCounter(), GetEnchantmentsString(), Object::GetEntry(), Object::GetGUID(), Object::GetGuidValue(), GetItemRandomPropertyId(), GetOwnerGUID(), ObjectGuid::GetRawValue(), GetSpellCharges(), Object::GetUInt32Value(), IsWrapped(), ITEM_CHANGED, ITEM_FIELD_CREATE_PLAYED_TIME, ITEM_FIELD_CREATOR, ITEM_FIELD_DURABILITY, ITEM_FIELD_DURATION, ITEM_FIELD_FLAGS, ITEM_FIELD_GIFTCREATOR, ITEM_NEW, ITEM_REMOVED, ITEM_UNCHANGED, m_text, MAX_ITEM_PROTO_SPELLS, PreparedStatementBase::SetData(), SetState(), and uState.

Referenced by Player::_LoadItem(), Player::_LoadMailedItem(), Player::_SaveInventory(), Player::AutoUnequipOffhandIfNeed(), AchievementMgr::CompletedAchievement(), WorldSession::HandleAuctionSellItem(), mail_commandscript::HandleMailReturnCommand(), WorldSession::HandleSendMail(), ToCloud9GrpcHandler::RemoveItemsWithGuidsFromPlayer(), ItemRecovery::Restore(), Bag::SaveToDB(), Player::SendItemRetrievalMail(), and MailDraft::SendReturnToSender().

◆ SendTimeUpdate()

void Item::SendTimeUpdate ( Player *  owner)
1088{
1090 if (!duration)
1091 return;
1092
1093 WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8 + 4));
1094 data << GetGUID();
1095 data << uint32(duration);
1096 owner->SendDirectMessage(&data);
1097}
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5886
Definition WorldPacket.h:26
@ SMSG_ITEM_TIME_UPDATE
Definition Opcodes.h:520

References Object::GetGUID(), Object::GetUInt32Value(), ITEM_FIELD_DURATION, Player::SendDirectMessage(), and SMSG_ITEM_TIME_UPDATE.

Referenced by Player::AddItemDurations().

◆ SendUpdateSockets()

void Item::SendUpdateSockets ( )
1075{
1076 WorldPacket data(SMSG_SOCKET_GEMS_RESULT, 8 + 4 + 4 + 4 + 4);
1077 data << GetGUID();
1080
1081 GetOwner()->SendDirectMessage(&data);
1082}
@ SMSG_SOCKET_GEMS_RESULT
Definition Opcodes.h:1321

References BONUS_ENCHANTMENT_SLOT, GetEnchantmentId(), Object::GetGUID(), GetOwner(), Player::SendDirectMessage(), SMSG_SOCKET_GEMS_RESULT, and SOCK_ENCHANTMENT_SLOT.

Referenced by WorldSession::HandleSocketOpcode().

◆ SetBinding()

◆ SetContainer()

void Item::SetContainer ( Bag *  container)
inline

◆ SetCount()

◆ SetEnchantment()

void Item::SetEnchantment ( EnchantmentSlot  slot,
uint32  id,
uint32  duration,
uint32  charges,
ObjectGuid  caster = ObjectGuid::Empty 
)
927{
928 // Better lost small time at check in comparison lost time at item save to DB.
929 if ((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges))
930 return;
931
932 Player* owner = GetOwner();
934 {
935 if (uint32 oldEnchant = GetEnchantmentId(slot))
937
938 if (id)
939 owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), caster, GetEntry(), id);
940 }
941
945 SetState(ITEM_CHANGED, owner);
946}
@ MAX_INSPECTED_ENCHANTMENT_SLOT
Definition Item.h:176
static ObjectGuid const Empty
Definition ObjectGuid.h:123
WorldSession * GetSession() const
Definition Player.h:2032
void SendEnchantmentLog(ObjectGuid target, ObjectGuid caster, uint32 itemId, uint32 enchantId)
Definition ItemHandler.cpp:1048

References ObjectGuid::Empty, ENCHANTMENT_CHARGES_OFFSET, ENCHANTMENT_DURATION_OFFSET, ENCHANTMENT_ID_OFFSET, GetEnchantmentCharges(), GetEnchantmentDuration(), GetEnchantmentId(), Object::GetEntry(), GetOwner(), GetOwnerGUID(), Player::GetSession(), ITEM_CHANGED, ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_OFFSET, MAX_INSPECTED_ENCHANTMENT_SLOT, WorldSession::SendEnchantmentLog(), SetState(), and Object::SetUInt32Value().

Referenced by Spell::EffectEnchantHeldItem(), Spell::EffectEnchantItemPerm(), Spell::EffectEnchantItemPrismatic(), Spell::EffectEnchantItemTmp(), Spell::EffectSummonChangeItem(), WorldSession::HandleSocketOpcode(), and SetItemRandomProperties().

◆ SetEnchantmentCharges()

◆ SetEnchantmentDuration()

void Item::SetEnchantmentDuration ( EnchantmentSlot  slot,
uint32  duration,
Player *  owner 
)
948{
949 if (GetEnchantmentDuration(slot) == duration)
950 return;
951
953 SetState(ITEM_CHANGED, owner);
954 // Cannot use GetOwner() here, has to be passed as an argument to avoid freeze due to hashtable locking
955}

References ENCHANTMENT_DURATION_OFFSET, GetEnchantmentDuration(), ITEM_CHANGED, ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_OFFSET, SetState(), and Object::SetUInt32Value().

Referenced by Player::RemoveEnchantmentDurations().

◆ SetInTrade()

void Item::SetInTrade ( bool  b = true)
inline
259{ mb_in_trade = b; }

References mb_in_trade.

Referenced by clearAcceptTradeMode(), and setAcceptTradeMode().

◆ SetItemRandomProperties()

void Item::SetItemRandomProperties ( int32  randomPropId)
663{
664 if (!randomPropId)
665 return;
666
667 if (randomPropId > 0)
668 {
669 ItemRandomPropertiesEntry const* item_rand = sItemRandomPropertiesStore.LookupEntry(randomPropId);
670 if (item_rand)
671 {
673 {
676 }
679 }
680 }
681 else
682 {
683 ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(-randomPropId);
684 if (item_rand)
685 {
688 {
692 }
693
696 }
697 }
698}
@ PROP_ENCHANTMENT_SLOT_0
Definition Item.h:178
uint32 GetItemSuffixFactor() const
Definition Item.h:296
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster=ObjectGuid::Empty)
Definition Item.cpp:926
std::array< uint32, MAX_ITEM_ENCHANTMENT_EFFECTS > Enchantment
Definition DBCStructure.h:1249
std::array< uint32, MAX_ITEM_ENCHANTMENT_EFFECTS > Enchantment
Definition DBCStructure.h:1260

References ItemRandomPropertiesEntry::Enchantment, ItemRandomSuffixEntry::Enchantment, Object::GetInt32Value(), GetItemSuffixFactor(), GetOwner(), ItemRandomPropertiesEntry::ID, ItemRandomSuffixEntry::ID, ITEM_CHANGED, ITEM_FIELD_RANDOM_PROPERTIES_ID, MAX_ENCHANTMENT_SLOT, PROP_ENCHANTMENT_SLOT_0, SetEnchantment(), Object::SetInt32Value(), SetState(), sItemRandomPropertiesStore, sItemRandomSuffixStore, and UpdateItemSuffixFactor().

Referenced by ToCloud9GrpcHandler::AddExistingItemToPlayer(), and CreateItem().

◆ SetNotRefundable()

void Item::SetNotRefundable ( Player *  owner,
bool  changestate = true,
CharacterDatabaseTransaction *  trans = nullptr 
)
1216{
1217 if (!IsRefundable())
1218 return;
1219
1221 // Following is not applicable in the trading procedure
1222 if (changestate)
1223 SetState(ITEM_CHANGED, owner);
1224
1226 SetPaidMoney(0);
1229
1231}
void DeleteRefundDataFromDB(CharacterDatabaseTransaction *trans)
Definition Item.cpp:1205
void SetPaidMoney(uint32 money)
Definition Item.h:346
void SetRefundRecipient(ObjectGuid::LowType pGuidLow)
Definition Item.h:345
bool IsRefundable() const
Definition Item.h:261
void SetPaidExtendedCost(uint32 iece)
Definition Item.h:347
void DeleteRefundReference(ObjectGuid itemGUID)
Definition Player.cpp:16033

References DeleteRefundDataFromDB(), Player::DeleteRefundReference(), Object::GetGUID(), IsRefundable(), ITEM_CHANGED, ITEM_FIELD_FLAG_REFUNDABLE, ITEM_FIELD_FLAGS, Object::RemoveFlag(), SetPaidExtendedCost(), SetPaidMoney(), SetRefundRecipient(), and SetState().

Referenced by Player::_StoreItem(), Player::DestroyItem(), Player::EquipItem(), WorldSession::HandleSendMail(), Player::RefundItem(), ToCloud9GrpcHandler::RemoveItemsWithGuidsFromPlayer(), Player::SendRefundInfo(), and UpdatePlayedTime().

◆ SetOwnerGUID()

◆ SetPaidExtendedCost()

void Item::SetPaidExtendedCost ( uint32  iece)
inline

◆ SetPaidMoney()

void Item::SetPaidMoney ( uint32  money)
inline

◆ SetRefundRecipient()

void Item::SetRefundRecipient ( ObjectGuid::LowType  pGuidLow)
inline

◆ SetSlot()

void Item::SetSlot ( uint8  slot)
inline

◆ SetSoulboundTradeable()

void Item::SetSoulboundTradeable ( AllowedLooterSet &  allowedLooters)
1274{
1276 allowedGUIDs = allowedLooters;
1277}
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:836

References allowedGUIDs, ITEM_FIELD_FLAG_BOP_TRADEABLE, ITEM_FIELD_FLAGS, and Object::SetFlag().

Referenced by Player::_LoadItem(), Player::_LoadMailedItem(), SendRollWonItemViaMail(), and Player::StoreNewItem().

◆ SetSpellCharges()

void Item::SetSpellCharges ( uint8  index,
int32  value 
)
inline

◆ SetState()

void Item::SetState ( ItemUpdateState  state,
Player *  forplayer = nullptr 
)
709{
710 if (uState == ITEM_NEW && state == ITEM_REMOVED)
711 {
712 // pretend the item never existed
713 if (forplayer)
714 {
715 RemoveFromUpdateQueueOf(forplayer);
716 forplayer->DeleteRefundReference(GetGUID());
717 }
718 delete this;
719 return;
720 }
721 if (state != ITEM_UNCHANGED)
722 {
723 // new items must stay in new state until saved
724 if (uState != ITEM_NEW)
725 uState = state;
726 if (forplayer)
727 AddToUpdateQueueOf(forplayer);
728 }
729 else
730 {
731 // unset in queue
732 // the item must be removed from the queue manually
733 uQueuePos = -1;
735 }
736}
void AddToUpdateQueueOf(Player *player)
Definition Item.cpp:738
void RemoveFromUpdateQueueOf(Player *player)
Definition Item.cpp:758

References AddToUpdateQueueOf(), Player::DeleteRefundReference(), Object::GetGUID(), ITEM_NEW, ITEM_REMOVED, ITEM_UNCHANGED, RemoveFromUpdateQueueOf(), uQueuePos, and uState.

Referenced by Player::_StoreItem(), ClearEnchantment(), ClearSoulboundTradeable(), Player::DestroyItem(), Player::DestroyItemCount(), Player::DurabilityPointsLoss(), Player::DurabilityRepair(), Spell::EffectOpenLock(), Player::EquipItem(), WorldSession::HandleAuctionSellItem(), WorldSession::HandleMailTakeItem(), WorldSession::HandleOpenWrappedItemCallback(), WorldSession::HandlePetitionBuyOpcode(), WorldSession::HandleSellItemOpcode(), WorldSession::HandleUseItemOpcode(), WorldSession::HandleWrapItemOpcode(), Player::MoveItemToInventory(), Player::RemoveItemFromBuyBackSlot(), ToCloud9GrpcHandler::RemoveItemsWithGuidsFromPlayer(), SaveToDB(), SetEnchantment(), SetEnchantmentCharges(), SetEnchantmentDuration(), SetItemRandomProperties(), SetNotRefundable(), Player::SplitItem(), Player::SwapItem(), Spell::TakeCastItem(), UpdateDuration(), UpdatePlayedTime(), and Player::VisualizeItem().

◆ SetText()

void Item::SetText ( std::string const &  text)
inline
310{ m_text = text; }

References m_text.

Referenced by WorldSession::HandleMailCreateTextItem(), and LoadFromDB().

◆ ToBag() [1/2]

Bag * Item::ToBag ( )
inline
250{ if (IsBag()) return reinterpret_cast<Bag*>(this); else return nullptr; }

References IsBag().

Referenced by Player::_LoadInventory(), Player::GetBagByPos(), debug_commandscript::HandleDebugGetItemStateCommand(), IsNotEmptyBag(), and Player::SwapItem().

◆ ToBag() [2/2]

Bag const * Item::ToBag ( ) const
inline
251{ if (IsBag()) return reinterpret_cast<Bag const*>(this); else return nullptr; }

References IsBag().

◆ UpdateDuration()

void Item::UpdateDuration ( Player *  owner,
uint32  diff 
)
320{
322 return;
323
324 LOG_DEBUG("entities.player.items", "Item::UpdateDuration Item (Entry: {} Duration {} Diff {})", GetEntry(), GetUInt32Value(ITEM_FIELD_DURATION), diff);
325
327 {
328 sScriptMgr->OnItemExpire(owner, GetTemplate());
329 owner->DestroyItem(GetBagSlot(), GetSlot(), true);
330 return;
331 }
332
334 SetState(ITEM_CHANGED, owner); // save new time in database
335}
void DestroyItem(uint8 bag, uint8 slot, bool update)
Definition PlayerStorage.cpp:3132

References Player::DestroyItem(), GetBagSlot(), Object::GetEntry(), GetSlot(), GetTemplate(), Object::GetUInt32Value(), ITEM_CHANGED, ITEM_FIELD_DURATION, LOG_DEBUG, SetState(), Object::SetUInt32Value(), and sScriptMgr.

Referenced by Player::UpdateItemDuration().

◆ UpdateItemSuffixFactor()

void Item::UpdateItemSuffixFactor ( )
701{
702 uint32 suffixFactor = GenerateEnchSuffixFactor(GetEntry());
703 if (GetItemSuffixFactor() == suffixFactor)
704 return;
706}
uint32 GenerateEnchSuffixFactor(uint32 item_id)
Definition ItemEnchantmentMgr.cpp:125

References GenerateEnchSuffixFactor(), Object::GetEntry(), GetItemSuffixFactor(), ITEM_FIELD_PROPERTY_SEED, and Object::SetUInt32Value().

Referenced by LoadFromDB(), and SetItemRandomProperties().

◆ UpdatePlayedTime()

void Item::UpdatePlayedTime ( Player *  owner)
1234{
1235 /* Here we update our played time
1236 We simply add a number to the current played time,
1237 based on the time elapsed since the last update hereof.
1238 */
1239 // Get current played time
1241 // Calculate time elapsed since last played time update
1242 time_t curtime = GameTime::GetGameTime().count();
1243 uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate);
1244 uint32 new_playtime = current_playtime + elapsed;
1245 // Check if the refund timer has expired yet
1246 if (new_playtime <= 2 * HOUR)
1247 {
1248 // No? Proceed.
1249 // Update the data field
1251 // Flag as changed to get saved to DB
1252 SetState(ITEM_CHANGED, owner);
1253 // Speaks for itself
1254 m_lastPlayedTimeUpdate = curtime;
1255 return;
1256 }
1257 // Yes
1258 SetNotRefundable(owner);
1259}
void SetNotRefundable(Player *owner, bool changestate=true, CharacterDatabaseTransaction *trans=nullptr)
Definition Item.cpp:1215

References GameTime::GetGameTime(), Object::GetUInt32Value(), HOUR, ITEM_CHANGED, ITEM_FIELD_CREATE_PLAYED_TIME, m_lastPlayedTimeUpdate, SetNotRefundable(), SetState(), and Object::SetUInt32Value().

Referenced by Player::_SaveInventory(), and Player::SendRefundInfo().

Member Data Documentation

◆ allowedGUIDs

◆ loot

◆ m_container

Bag* Item::m_container
private

◆ m_lastPlayedTimeUpdate

time_t Item::m_lastPlayedTimeUpdate
private

◆ m_lootGenerated

◆ m_paidExtendedCost

uint32 Item::m_paidExtendedCost
private

◆ m_paidMoney

uint32 Item::m_paidMoney
private

Referenced by GetPaidMoney(), Item(), and SetPaidMoney().

◆ m_refundRecipient

uint32 Item::m_refundRecipient
private

◆ m_slot

uint8 Item::m_slot
private

Referenced by GetSlot(), IsEquipped(), Item(), and SetSlot().

◆ m_text

std::string Item::m_text
private

Referenced by GetText(), SaveToDB(), and SetText().

◆ mb_in_trade

bool Item::mb_in_trade
private

Referenced by IsInTrade(), Item(), and SetInTrade().

◆ uQueuePos

◆ uState

ItemUpdateState Item::uState
private

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