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

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

Static Public Member Functions

static ItemCreateItem (uint32 item, uint32 count, Player const *player=nullptr, bool clone=false, uint32 randomPropertyId=0)
 
static void DeleteFromDB (CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
 
static void DeleteFromInventoryDB (CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
 
static int32 GenerateItemRandomPropertyId (uint32 item_id)
 
- Static Public Member Functions inherited from Object
static ObjectGuid GetGUID (Object const *o)
 

Public Attributes

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

Private Attributes

std::string m_text
 
uint8 m_slot
 
Bagm_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)
 
std::string _ConcatFields (uint16 startIndex, uint16 size) const
 
bool _LoadIntoDataField (std::string const &data, uint32 startOffset, uint32 count)
 
uint32 GetUpdateFieldData (Player const *target, uint32 *&flags) const
 
void BuildMovementUpdate (ByteBuffer *data, uint16 flags) const
 
virtual void BuildValuesUpdate (uint8 updateType, ByteBuffer *data, Player *target)
 
virtual void AddToObjectUpdate ()=0
 
virtual void RemoveFromObjectUpdate ()=0
 
void AddToObjectUpdateIfNeeded ()
 
- 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 ( )
262{
265
267
269 m_slot = 0;
271 uQueuePos = -1;
272 m_container = nullptr;
273 m_lootGenerated = false;
274 mb_in_trade = false;
276
278 m_paidMoney = 0;
280}
@ ITEM_NEW
Definition: Item.h:211
@ TYPEID_ITEM
Definition: ObjectGuid.h:33
@ TYPEMASK_ITEM
Definition: ObjectGuid.h:47
@ ITEM_END
Definition: UpdateFields.h:73
@ UPDATEFLAG_LOWGUID
Definition: UpdateData.h:43
Seconds GetGameTime()
Definition: GameTime.cpp:38
int32 uQueuePos
Definition: Item.h:372
Bag * m_container
Definition: Item.h:370
bool mb_in_trade
Definition: Item.h:373
uint32 m_paidMoney
Definition: Item.h:376
time_t m_lastPlayedTimeUpdate
Definition: Item.h:374
uint32 m_paidExtendedCost
Definition: Item.h:377
bool m_lootGenerated
Definition: Item.h:321
uint32 m_refundRecipient
Definition: Item.h:375
uint8 m_slot
Definition: Item.h:369
ItemUpdateState uState
Definition: Item.h:371
uint16 m_objectType
Definition: Object.h:245
uint16 m_valuesCount
Definition: Object.h:259
uint16 m_updateFlag
Definition: Object.h:248
TypeID m_objectTypeId
Definition: Object.h:247

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.

1161{
1162 if (Player* owner = GetOwner())
1163 owner->GetMap()->AddUpdateObject(this);
1164}
Player * GetOwner() const
Definition: Item.cpp:549
Definition: Player.h:1081

References GetOwner().

◆ AddToUpdateQueueOf()

void Item::AddToUpdateQueueOf ( Player player)
745{
746 if (IsInUpdateQueue())
747 return;
748
749 ASSERT(player);
750
751 if (player->GetGUID() != GetOwnerGUID())
752 {
753 LOG_DEBUG("entities.player.items", "Item::AddToUpdateQueueOf - Owner's guid ({}) and player's guid ({}) don't match!", GetOwnerGUID().ToString(), player->GetGUID().ToString());
754 return;
755 }
756
757 if (player->m_itemUpdateQueueBlocked)
758 return;
759
760 player->m_itemUpdateQueue.push_back(this);
761 uQueuePos = player->m_itemUpdateQueue.size() - 1;
762}
#define ASSERT
Definition: Errors.h:68
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
std::string ToString(Type &&val, Params &&... params)
Definition: StringConvert.h:250
ObjectGuid GetOwnerGUID() const
Definition: Item.h:231
bool IsInUpdateQueue() const
Definition: Item.h:328
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:112
std::string ToString() const
Definition: ObjectGuid.cpp:47
std::vector< Item * > m_itemUpdateQueue
Definition: Player.h:2793
bool m_itemUpdateQueueBlocked
Definition: Player.h:2794

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,
UpdatePlayerSet  
)
overridevirtual

Reimplemented from Object.

1154{
1155 if (Player* owner = GetOwner())
1156 BuildFieldsUpdate(owner, data_map);
1157 ClearUpdateMask(false);
1158}
void BuildFieldsUpdate(Player *, UpdateDataMapType &)
Definition: Object.cpp:545
void ClearUpdateMask(bool remove)
Definition: Object.cpp:533

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

◆ CanBeMergedPartlyWith()

InventoryResult Item::CanBeMergedPartlyWith ( ItemTemplate const *  proto) const
868{
869 // not allow merge looting currently items
870 if (m_lootGenerated)
872
873 // check item type
874 if (GetEntry() != proto->ItemId)
876
877 // check free space (full stacks can't be target of merge
878 if (GetCount() >= proto->GetMaxStackSize())
880
881 return EQUIP_ERR_OK;
882}
@ 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:115

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
795{
796 if ((!mail || !IsBoundAccountWide()) && (IsSoulBound() && (!IsBOPTradable() || !trade)))
797 return false;
798
799 if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()))
800 return false;
801
802 if (Player* owner = GetOwner())
803 {
804 if (owner->CanUnequipItem(GetPos(), false) != EQUIP_ERR_OK)
805 return false;
806
807 // Xinef: check if item is looted now
808 if (owner->GetLootGUID() == GetGUID())
809 return false;
810 }
811
812 if (IsBoundByTempEnchant()) // pussywizard
813 return false;
814
815 if ((!mail || !IsBoundAccountWide()) && IsBoundByEnchant())
816 return false;
817
818 return true;
819}
Definition: Bag.h:28
bool IsBoundByTempEnchant() const
Definition: Item.cpp:858
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:847
bool IsBag() const
Definition: Item.h:254
ObjectGuid GetGUID() const
Definition: Object.h:113
static bool IsBagPos(uint16 pos)
Definition: PlayerStorage.cpp:590

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

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

◆ CheckSoulboundTradeExpire()

bool Item::CheckSoulboundTradeExpire ( )
1278{
1279 // called from owner's update - GetOwner() MUST be valid
1280 if (GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + 2 * HOUR < GetOwner()->GetTotalPlayedTime())
1281 {
1283 return true; // remove from tradeable list
1284 }
1285
1286 return false;
1287}
constexpr auto HOUR
Definition: Common.h:48
@ ITEM_FIELD_CREATE_PLAYED_TIME
Definition: UpdateFields.h:71
void ClearSoulboundTradeable(Player *currentOwner)
Definition: Item.cpp:1264
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:305

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

◆ ClearEnchantment()

void Item::ClearEnchantment ( EnchantmentSlot  slot)
961{
962 if (!GetEnchantmentId(slot))
963 return;
964
965 for (uint8 x = 0; x < MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS; ++x)
968}
std::uint8_t uint8
Definition: Define.h:109
#define MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS
Definition: DBCStructure.h:1837
#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:714
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:304
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:650

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)
1265{
1267 if (allowedGUIDs.empty())
1268 return;
1269
1270 allowedGUIDs.clear();
1271 SetState(ITEM_CHANGED, currentOwner);
1273 stmt->SetData(0, GetGUID().GetCounter());
1274 CharacterDatabase.Execute(stmt);
1275}
@ ITEM_FIELD_FLAG_BOP_TRADEABLE
Definition: ItemTemplate.h:117
@ ITEM_FIELD_FLAGS
Definition: UpdateFields.h:42
@ CHAR_DEL_ITEM_BOP_TRADE
Definition: CharacterDatabase.h:121
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: PreparedStatement.h:157
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:77
AllowedLooterSet allowedGUIDs
Definition: Item.h:378
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:860

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
1119{
1120 // player CAN be nullptr in which case we must not update random properties because that accesses player's item update queue
1121 Item* newItem = CreateItem(GetEntry(), count, player, true, player ? GetItemRandomPropertyId() : 0);
1122 if (!newItem)
1123 return nullptr;
1124
1129 return newItem;
1130}
@ 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:1087
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::HandleAuctionSellItem(), WorldSession::HandleSellItemOpcode(), and Player::SplitItem().

◆ Create()

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

Reimplemented in Bag.

283{
284 Object::_Create(guidlow, 0, HighGuid::Item);
285
286 SetEntry(itemid);
287 SetObjectScale(1.0f);
288
289 SetGuidValue(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : ObjectGuid::Empty);
290 SetGuidValue(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : ObjectGuid::Empty);
291
292 ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid);
293 if (!itemProto)
294 return false;
295
299
300 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
301 SetSpellCharges(i, itemProto->Spells[i].SpellCharges);
302
305 sScriptMgr->OnItemCreate(this, itemProto, owner);
306 return true;
307}
#define sObjectMgr
Definition: ObjectMgr.h:1635
#define MAX_ITEM_PROTO_SPELLS
Definition: ItemTemplate.h:615
@ 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
#define sScriptMgr
Definition: ScriptMgr.h:709
void SetSpellCharges(uint8 index, int32 value)
Definition: Item.h:318
int32 SpellCharges
Definition: ItemTemplate.h:593
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
void _Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
Definition: Object.cpp:134
void SetGuidValue(uint16 index, ObjectGuid value)
Definition: Object.cpp:723
void SetEntry(uint32 entry)
Definition: Object.h:116
virtual void SetObjectScale(float scale)
Definition: Object.h:119
static ObjectGuid const Empty
Definition: ObjectGuid.h:120

References Object::_Create(), ItemTemplate::Duration, ObjectGuid::Empty, Object::GetGUID(), 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, ItemTemplate::MaxDurability, Object::SetEntry(), Object::SetGuidValue(), Object::SetObjectScale(), SetSpellCharges(), Object::SetUInt32Value(), sObjectMgr, _Spell::SpellCharges, ItemTemplate::Spells, and sScriptMgr.

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

◆ CreateItem()

Item * Item::CreateItem ( uint32  item,
uint32  count,
Player const *  player = nullptr,
bool  clone = false,
uint32  randomPropertyId = 0 
)
static
1088{
1089 if (count < 1)
1090 return nullptr; //don't create item at zero count
1091
1092 ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item);
1093 if (pProto)
1094 {
1095 if (count > pProto->GetMaxStackSize())
1096 count = pProto->GetMaxStackSize();
1097
1098 ASSERT_NODEBUGINFO(count != 0 && "pProto->Stackable == 0 but checked at loading already");
1099
1100 Item* pItem = NewItemOrBag(pProto);
1101 if (pItem->Create(sObjectMgr->GetGenerator<HighGuid::Item>().Generate(), item, player))
1102 {
1103 pItem->SetCount(count);
1104 if (!clone)
1105 pItem->SetItemRandomProperties(randomPropertyId ? randomPropertyId : Item::GenerateItemRandomPropertyId(item));
1106 else if (randomPropertyId)
1107 pItem->SetItemRandomProperties(randomPropertyId);
1108 return pItem;
1109 }
1110 else
1111 delete pItem;
1112 }
1113 else
1114 ABORT();
1115 return nullptr;
1116}
#define ABORT
Definition: Errors.h:76
#define ASSERT_NODEBUGINFO
Definition: Errors.h:69
Item * NewItemOrBag(ItemTemplate const *proto)
Definition: Bag.h:67
virtual bool Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const *owner)
Definition: Item.cpp:282
void SetItemRandomProperties(int32 randomPropId)
Definition: Item.cpp:668
void SetCount(uint32 value)
Definition: Item.h:273
static int32 GenerateItemRandomPropertyId(uint32 item_id)
Definition: Item.cpp:622
uint32 GetMaxStackSize() const
Definition: ItemTemplate.h:729

References ABORT, ASSERT_NODEBUGINFO, Create(), GenerateItemRandomPropertyId(), ItemTemplate::GetMaxStackSize(), NewItemOrBag(), SetCount(), SetItemRandomProperties(), and sObjectMgr.

Referenced by Player::CanEquipNewItem(), CloneItem(), AchievementMgr::CompletedAchievement(), Spell::EffectSummonChangeItem(), Player::EquipNewItem(), item_commandscript::HandleItemRefundCommand(), item_commandscript::HandleItemRestoreCommand(), 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(), Player::SendItemRetrievalMail(), ObjectMgr::SendServerMail(), and Player::StoreNewItem().

◆ DeleteFromDB() [1/2]

void Item::DeleteFromDB ( CharacterDatabaseTransaction  trans)
virtual

Reimplemented in Bag.

527{
528 DeleteFromDB(trans, GetGUID().GetCounter());
529}
static void DeleteFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
Definition: Item.cpp:518

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

◆ DeleteFromDB() [2/2]

void Item::DeleteFromDB ( CharacterDatabaseTransaction  trans,
ObjectGuid::LowType  itemGuid 
)
static
519{
520 sScriptMgr->OnGlobalItemDelFromDB(trans, itemGuid);
522 stmt->SetData(0, itemGuid);
523 trans->Append(stmt);
524}
@ CHAR_DEL_ITEM_INSTANCE
Definition: CharacterDatabase.h:127

References CHAR_DEL_ITEM_INSTANCE, CharacterDatabase, PreparedStatementBase::SetData(), and sScriptMgr.

Referenced by Player::_LoadItem(), Guild::BankMoveItemData::_StoreItem(), DeleteFromDB(), Bag::DeleteFromDB(), and WorldSession::HandleAuctionSellItem().

◆ DeleteFromInventoryDB() [1/2]

void Item::DeleteFromInventoryDB ( CharacterDatabaseTransaction  trans)
540{
541 DeleteFromInventoryDB(trans, GetGUID().GetCounter());
542}
static void DeleteFromInventoryDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
Definition: Item.cpp:532

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

◆ DeleteFromInventoryDB() [2/2]

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

◆ DeleteRefundDataFromDB()

void Item::DeleteRefundDataFromDB ( CharacterDatabaseTransaction trans)
1191{
1192 if (trans)
1193 {
1195 stmt->SetData(0, GetGUID().GetCounter());
1196 (*trans)->Append(stmt);
1197 }
1198}
@ CHAR_DEL_ITEM_REFUND_INSTANCE
Definition: CharacterDatabase.h:374

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

Referenced by SetNotRefundable().

◆ FSetState()

void Item::FSetState ( ItemUpdateState  state)
inline

◆ GemsFitSockets()

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

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

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()

◆ GetDebugInfo()

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

Reimplemented from Object.

1290{
1291 std::stringstream sstr;
1292 sstr << Object::GetDebugInfo() << "\n"
1293 << std::boolalpha
1294 << "Owner: " << GetOwnerGUID().ToString() << " Count: " << GetCount()
1295 << " BagSlot: " << std::to_string(GetBagSlot()) << " Slot: " << std::to_string(GetSlot()) << " Equipped: " << IsEquipped();
1296 return sstr.str();
1297}
bool IsEquipped() const
Definition: Item.cpp:789
uint8 GetBagSlot() const
Definition: Item.cpp:784
virtual std::string GetDebugInfo() const
Definition: Object.cpp:1009

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

Referenced by Bag::GetDebugInfo().

◆ GetEnchantmentCharges()

◆ GetEnchantmentDuration()

◆ GetEnchantmentId()

◆ GetEnchantRequiredLevel()

uint32 Item::GetEnchantRequiredLevel ( ) const
834{
835 uint32 level = 0;
836
837 // Check all enchants for required level
838 for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot)
839 if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)))
840 if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id))
841 if (enchantEntry->requiredLevel > level)
842 level = enchantEntry->requiredLevel;
843
844 return level;
845}
@ PERM_ENCHANTMENT_SLOT
Definition: Item.h:169
@ MAX_ENCHANTMENT_SLOT
Definition: Item.h:183

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

◆ GetGemCountWithID()

uint8 Item::GetGemCountWithID ( uint32  GemID) const
1015{
1016 uint8 count = 0;
1017 for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
1018 {
1019 uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
1020 if (!enchant_id)
1021 continue;
1022
1023 SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
1024 if (!enchantEntry)
1025 continue;
1026
1027 if (GemID == enchantEntry->GemID)
1028 ++count;
1029 }
1030 return count;
1031}

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

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

◆ GetGemCountWithLimitCategory()

uint8 Item::GetGemCountWithLimitCategory ( uint32  limitCategory) const
1034{
1035 uint8 count = 0;
1036 for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
1037 {
1038 uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
1039 if (!enchant_id)
1040 continue;
1041
1042 SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
1043 if (!enchantEntry)
1044 continue;
1045
1046 ItemTemplate const* gemProto = sObjectMgr->GetItemTemplate(enchantEntry->GemID);
1047 if (!gemProto)
1048 continue;
1049
1050 if (gemProto->ItemLimitCategory == limitCategory)
1051 ++count;
1052 }
1053 return count;
1054}
uint32 ItemLimitCategory
Definition: ItemTemplate.h:687

References SpellItemEnchantmentEntry::GemID, GetEnchantmentId(), ItemTemplate::ItemLimitCategory, MAX_GEM_SOCKETS, 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 ( )
556{
557 return GetTemplate()->GetSkill();
558}
uint32 GetSkill() const
Definition: ItemTemplate.h:784

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

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

◆ GetSlot()

◆ GetSpell()

uint32 Item::GetSpell ( )
561{
562 ItemTemplate const* proto = GetTemplate();
563
564 switch (proto->Class)
565 {
567 switch (proto->SubClass)
568 {
570 return 196;
572 return 197;
574 return 264;
576 return 266;
578 return 198;
580 return 199;
582 return 200;
584 return 201;
586 return 202;
588 return 227;
590 return 1180;
592 return 2567;
594 return 3386;
596 return 5011;
598 return 5009;
599 default:
600 return 0;
601 }
602 case ITEM_CLASS_ARMOR:
603 switch (proto->SubClass)
604 {
606 return 9078;
608 return 9077;
610 return 8737;
612 return 750;
614 return 9116;
615 default:
616 return 0;
617 }
618 }
619 return 0;
620}
@ 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
545{
546 return sObjectMgr->GetItemTemplate(GetEntry());
547}

References Object::GetEntry(), and sObjectMgr.

Referenced by Player::_ApplyAllItemMods(), Player::_ApplyAllLevelScaleItemMods(), Player::_ApplyItemMods(), Player::_LoadItem(), Player::_RemoveAllItemMods(), Player::_SaveInventory(), Player::_StoreItem(), AddItemsSetItem(), Player::AddQuestAndCheckCompletion(), Player::ApplyEnchantment(), Player::ApplyEquipCooldown(), Player::ApplyItemEquipSpell(), Player::AutoUnequipOffhandIfNeed(), AuctionHouseObject::BuildListAuctionItems(), 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(), Spell::DoCreateItem(), WorldSession::DoLootRelease(), Spell::DoSpellHitOnUnit(), Player::DurabilityRepair(), Spell::EffectDisEnchant(), Spell::EffectEnchantItemPerm(), Spell::EffectFeedPet(), Spell::EffectMilling(), Spell::EffectOpenLock(), Spell::EffectProspecting(), Player::EquipItem(), EquippedOk(), GemsFitSockets(), AuctionHouseMgr::GetAuctionDeposit(), Player::GetAverageItemLevel(), Player::GetAverageItemLevelForDF(), Player::GetItemCount(), Bag::GetItemCount(), GetMaxStackCount(), GetScriptId(), Player::GetShield(), GetSkill(), GetSpell(), Unit::GetUnitBlockChance(), Player::GetWeaponForAttack(), WorldSession::HandleAuctionSellItem(), WorldSession::HandleAutoEquipItemOpcode(), debug_commandscript::HandleDebugItemExpireCommand(), WorldSession::HandleDestroyItemOpcode(), WorldSession::HandleOpenItemOpcode(), WorldSession::HandleOpenWrappedItemCallback(), WorldSession::HandleReadItem(), WorldSession::HandleSellItemOpcode(), WorldSession::HandleSendMail(), WorldSession::HandleSocketOpcode(), WorldSession::HandleUseItemOpcode(), WorldSession::HandleWrapItemOpcode(), Player::HasItemOrGemWithIdEquipped(), Player::HasItemOrGemWithLimitCategoryEquipped(), Player::HasItemTotemCategory(), hasQuest(), HasSocket(), IsArmorVellum(), IsBag(), IsBoundAccountWide(), IsConjuredConsumable(), IsCurrencyToken(), IsFitToSpellRequirements(), IsLimitedToAnotherMapOrZone(), IsPotion(), Unit::IsTriggeredAtSpellProcEvent(), Player::IsTwoHandUsed(), IsWeaponVellum(), LoadFromDB(), Bag::LoadFromDB(), WorldSession::recoveryItem(), Player::RemoveItem(), Player::SendEquipError(), Player::SendLoot(), Player::SetRegularAttackTime(), Player::StoreItem(), Player::StoreNewItem(), Spell::SummonGuardian(), Player::SwapItem(), Spell::TakeAmmo(), Spell::TakeCastItem(), Spell::TakeReagents(), Player::ToggleMetaGemsActive(), UpdateDuration(), Player::UpdateItemDuration(), Player::UpdateWeaponSkill(), Player::VisualizeItem(), and Spell::WriteAmmoToPacket().

◆ GetText()

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

References m_text.

◆ HasEnchantRequiredSkill()

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

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

◆ hasInvolvedQuest()

bool Item::hasInvolvedQuest ( uint32  ) const
inlineoverridevirtual

Reimplemented from Object.

336{ return false; }

◆ hasQuest()

bool Item::hasQuest ( uint32  quest_id) const
inlineoverridevirtual

Reimplemented from Object.

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

References GetTemplate(), and ItemTemplate::StartQuest.

◆ HasSocket()

bool Item::HasSocket ( ) const
1008{
1009 // There can only be one socket added, and it's always in slot `PRISMATIC_ENCHANTMENT_SLOT`.
1010 // Built-in sockets Socket from upgrade
1012}
@ PRISMATIC_ENCHANTMENT_SLOT
Definition: Item.h:175

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

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

◆ IsArmorVellum()

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

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
1133{
1134 // not binded item
1135 if (!IsSoulBound())
1136 return false;
1137
1138 // own item
1139 if (GetOwnerGUID() == player->GetGUID())
1140 return false;
1141
1142 if (IsBOPTradable())
1143 if (allowedGUIDs.find(player->GetGUID()) != allowedGUIDs.end())
1144 return false;
1145
1146 // BOA item case
1147 if (IsBoundAccountWide())
1148 return false;
1149
1150 return true;
1151}

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

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

◆ IsBOPTradable()

bool Item::IsBOPTradable ( ) const
inline
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:889

References Object::HasFlag(), ITEM_FIELD_FLAG_BOP_TRADEABLE, and ITEM_FIELD_FLAGS.

Referenced by Player::_LoadItem(), CanBeTraded(), IsBindedNotWith(), and Player::MoveItemToInventory().

◆ 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
848{
849 // Check all enchants for soulbound
850 for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot)
851 if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)))
852 if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id))
853 if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
854 return true;
855 return false;
856}
@ 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
859{
861 if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id))
862 if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
863 return true;
864 return false;
865}
@ 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
340{ return GetTemplate()->IsConjuredConsumable(); }
bool IsConjuredConsumable() const
Definition: ItemTemplate.h:822

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

◆ IsCurrencyToken()

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

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

◆ IsEquipped()

◆ IsFitToSpellRequirements()

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

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::_ApplyWeaponDependentAuraCritMod(), Player::_ApplyWeaponDependentAuraDamageMod(), Spell::CheckItems(), Player::HasItemFitToSpellRequirements(), Aura::IsProcTriggeredOnEvent(), 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
1057{
1058 ItemTemplate const* proto = GetTemplate();
1059 return proto && ((proto->Map && proto->Map != cur_mapId) || (proto->Area && proto->Area != cur_zoneId));
1060}
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
@ ITEM_FIELD_FLAG_UNLOCKED
Definition: ItemTemplate.h:111

References Object::HasFlag(), ITEM_FIELD_FLAG_UNLOCKED, and ITEM_FIELD_FLAGS.

Referenced by Spell::CheckCast(), and WorldSession::HandleOpenItemOpcode().

◆ IsNotEmptyBag()

bool Item::IsNotEmptyBag ( ) const

◆ IsPotion()

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

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

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

◆ IsRefundable()

◆ IsRefundExpired()

bool Item::IsRefundExpired ( )
1254{
1255 return (GetPlayedTime() > 2 * HOUR);
1256}
uint32 GetPlayedTime()
Definition: Item.cpp:1246

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.

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

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_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(), AuctionHouseMgr::LoadAuctionItems(), Bag::LoadFromDB(), and Guild::BankTab::LoadItemFromDB().

◆ RemoveFromObjectUpdate()

void Item::RemoveFromObjectUpdate ( )
overridevirtual

Implements Object.

1167{
1168 if (Player* owner = GetOwner())
1169 owner->GetMap()->RemoveUpdateObject(this);
1170}

References GetOwner().

◆ RemoveFromUpdateQueueOf()

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

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

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

◆ SaveRefundDataToDB()

void Item::SaveRefundDataToDB ( )
1173{
1174 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1175
1177 stmt->SetData(0, GetGUID().GetCounter());
1178 trans->Append(stmt);
1179
1180 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEM_REFUND_INSTANCE);
1181 stmt->SetData(0, GetGUID().GetCounter());
1182 stmt->SetData(1, GetRefundRecipient());
1183 stmt->SetData(2, GetPaidMoney());
1184 stmt->SetData(3, uint16(GetPaidExtendedCost()));
1185 trans->Append(stmt);
1186
1187 CharacterDatabase.CommitTransaction(trans);
1188}
@ CHAR_INS_ITEM_REFUND_INSTANCE
Definition: CharacterDatabase.h:375
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:69
uint32 GetPaidExtendedCost()
Definition: Item.h:349
uint32 GetPaidMoney()
Definition: Item.h:348
ObjectGuid::LowType GetRefundRecipient()
Definition: Item.h:347

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.

337{
338 bool isInTransaction = static_cast<bool>(trans);
339 if (!isInTransaction)
340 trans = CharacterDatabase.BeginTransaction();
341
343 switch (uState)
344 {
345 case ITEM_NEW:
346 case ITEM_CHANGED:
347 {
348 uint8 index = 0;
350 stmt->SetData( index, GetEntry());
351 stmt->SetData(++index, GetOwnerGUID().GetCounter());
352 stmt->SetData(++index, GetGuidValue(ITEM_FIELD_CREATOR).GetCounter());
353 stmt->SetData(++index, GetGuidValue(ITEM_FIELD_GIFTCREATOR).GetCounter());
354 stmt->SetData(++index, GetCount());
356
357 std::ostringstream ssSpells;
358 for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
359 ssSpells << GetSpellCharges(i) << ' ';
360 stmt->SetData(++index, ssSpells.str());
361
362 stmt->SetData(++index, GetUInt32Value(ITEM_FIELD_FLAGS));
363
364 std::ostringstream ssEnchants;
365 for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)
366 {
367 ssEnchants << GetEnchantmentId(EnchantmentSlot(i)) << ' ';
368 ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << ' ';
369 ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << ' ';
370 }
371 stmt->SetData(++index, ssEnchants.str());
372
373 stmt->SetData (++index, GetItemRandomPropertyId());
376 stmt->SetData(++index, m_text);
377 stmt->SetData(++index, guid);
378
379 trans->Append(stmt);
380
381 if ((uState == ITEM_CHANGED) && IsWrapped())
382 {
383 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER);
384 stmt->SetData(0, GetOwnerGUID().GetCounter());
385 stmt->SetData(1, guid);
386 trans->Append(stmt);
387 }
388 break;
389 }
390 case ITEM_REMOVED:
391 {
393 stmt->SetData(0, guid);
394 trans->Append(stmt);
395
396 if (IsWrapped())
397 {
398 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
399 stmt->SetData(0, guid);
400 trans->Append(stmt);
401 }
402
403 if (!isInTransaction)
404 CharacterDatabase.CommitTransaction(trans);
405
406 delete this;
407 return;
408 }
409 case ITEM_UNCHANGED:
410 break;
411 }
412
414
415 if (!isInTransaction)
416 CharacterDatabase.CommitTransaction(trans);
417}
@ ITEM_REMOVED
Definition: Item.h:212
@ ITEM_UNCHANGED
Definition: Item.h:209
@ CHAR_UPD_ITEM_INSTANCE
Definition: CharacterDatabase.h:125
@ CHAR_UPD_GIFT_OWNER
Definition: CharacterDatabase.h:129
@ CHAR_DEL_GIFT
Definition: CharacterDatabase.h:130
@ CHAR_REP_ITEM_INSTANCE
Definition: CharacterDatabase.h:124
int32 GetSpellCharges(uint8 index=0) const
Definition: Item.h:317
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const
Definition: Item.h:305
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const
Definition: Item.h:306
LowType GetCounter() const
Definition: ObjectGuid.h:145
uint32 LowType
Definition: ObjectGuid.h:122

References CHAR_DEL_GIFT, CHAR_DEL_ITEM_INSTANCE, CHAR_REP_ITEM_INSTANCE, CHAR_UPD_GIFT_OWNER, CHAR_UPD_ITEM_INSTANCE, CharacterDatabase, GetCount(), ObjectGuid::GetCounter(), GetEnchantmentCharges(), GetEnchantmentDuration(), GetEnchantmentId(), Object::GetEntry(), Object::GetGUID(), Object::GetGuidValue(), GetItemRandomPropertyId(), GetOwnerGUID(), 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_ENCHANTMENT_SLOT, MAX_ITEM_PROTO_SPELLS, PreparedStatementBase::SetData(), SetState(), and uState.

Referenced by Player::_LoadItem(), Player::_LoadMailedItem(), Player::_SaveInventory(), Player::AutoUnequipOffhandIfNeed(), AchievementMgr::CompletedAchievement(), WorldSession::HandleAuctionSellItem(), WorldSession::HandleSendMail(), Bag::SaveToDB(), and MailDraft::SendReturnToSender().

◆ SendTimeUpdate()

void Item::SendTimeUpdate ( Player owner)
1076{
1078 if (!duration)
1079 return;
1080
1081 WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8 + 4));
1082 data << GetGUID();
1083 data << uint32(duration);
1084 owner->GetSession()->SendPacket(&data);
1085}
@ SMSG_ITEM_TIME_UPDATE
Definition: Opcodes.h:520
WorldSession * GetSession() const
Definition: Player.h:1998
Definition: WorldPacket.h:26
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:214

References Object::GetGUID(), Player::GetSession(), Object::GetUInt32Value(), ITEM_FIELD_DURATION, WorldSession::SendPacket(), and SMSG_ITEM_TIME_UPDATE.

Referenced by Player::AddItemDurations().

◆ SendUpdateSockets()

void Item::SendUpdateSockets ( )
1063{
1064 WorldPacket data(SMSG_SOCKET_GEMS_RESULT, 8 + 4 + 4 + 4 + 4);
1065 data << GetGUID();
1068
1069 GetOwner()->GetSession()->SendPacket(&data);
1070}
@ BONUS_ENCHANTMENT_SLOT
Definition: Item.h:174
@ SMSG_SOCKET_GEMS_RESULT
Definition: Opcodes.h:1321

References BONUS_ENCHANTMENT_SLOT, GetEnchantmentId(), Object::GetGUID(), GetOwner(), Player::GetSession(), WorldSession::SendPacket(), 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 
)
921{
922 // Better lost small time at check in comparison lost time at item save to DB.
923 if ((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges))
924 return;
925
926 Player* owner = GetOwner();
928 {
929 if (uint32 oldEnchant = GetEnchantmentId(slot))
931
932 if (id)
933 owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), caster, GetEntry(), id);
934 }
935
939 SetState(ITEM_CHANGED, owner);
940}
@ MAX_INSPECTED_ENCHANTMENT_SLOT
Definition: Item.h:176
void SendEnchantmentLog(ObjectGuid target, ObjectGuid caster, uint32 itemId, uint32 enchantId)
Definition: ItemHandler.cpp:1222

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 
)
942{
943 if (GetEnchantmentDuration(slot) == duration)
944 return;
945
947 SetState(ITEM_CHANGED, owner);
948 // Cannot use GetOwner() here, has to be passed as an argument to avoid freeze due to hashtable locking
949}

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)
669{
670 if (!randomPropId)
671 return;
672
673 if (randomPropId > 0)
674 {
675 ItemRandomPropertiesEntry const* item_rand = sItemRandomPropertiesStore.LookupEntry(randomPropId);
676 if (item_rand)
677 {
679 {
682 }
685 }
686 }
687 else
688 {
689 ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(-randomPropId);
690 if (item_rand)
691 {
694 {
698 }
699
702 }
703 }
704}
@ 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:920
std::array< uint32, MAX_ITEM_ENCHANTMENT_EFFECTS > Enchantment
Definition: DBCStructure.h:1209
std::array< uint32, MAX_ITEM_ENCHANTMENT_EFFECTS > Enchantment
Definition: DBCStructure.h:1221

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 CreateItem().

◆ SetNotRefundable()

void Item::SetNotRefundable ( Player owner,
bool  changestate = true,
CharacterDatabaseTransaction trans = nullptr 
)
1201{
1202 if (!IsRefundable())
1203 return;
1204
1206 // Following is not applicable in the trading procedure
1207 if (changestate)
1208 SetState(ITEM_CHANGED, owner);
1209
1211 SetPaidMoney(0);
1214
1216}
void DeleteRefundDataFromDB(CharacterDatabaseTransaction *trans)
Definition: Item.cpp:1190
void SetPaidMoney(uint32 money)
Definition: Item.h:345
void SetRefundRecipient(ObjectGuid::LowType pGuidLow)
Definition: Item.h:344
bool IsRefundable() const
Definition: Item.h:261
void SetPaidExtendedCost(uint32 iece)
Definition: Item.h:346
void DeleteRefundReference(ObjectGuid itemGUID)
Definition: Player.cpp:15544

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(), 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)
1259{
1261 allowedGUIDs = allowedLooters;
1262}
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:845

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

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

◆ SetSpellCharges()

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

◆ SetState()

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

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(), 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
309{ 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]

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

References IsBag().

◆ UpdateDuration()

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

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 ( )
707{
708 uint32 suffixFactor = GenerateEnchSuffixFactor(GetEntry());
709 if (GetItemSuffixFactor() == suffixFactor)
710 return;
712}
uint32 GenerateEnchSuffixFactor(uint32 item_id)
Definition: ItemEnchantmentMgr.cpp:124

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

Referenced by LoadFromDB(), and SetItemRandomProperties().

◆ UpdatePlayedTime()

void Item::UpdatePlayedTime ( Player owner)
1219{
1220 /* Here we update our played time
1221 We simply add a number to the current played time,
1222 based on the time elapsed since the last update hereof.
1223 */
1224 // Get current played time
1226 // Calculate time elapsed since last played time update
1227 time_t curtime = GameTime::GetGameTime().count();
1228 uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate);
1229 uint32 new_playtime = current_playtime + elapsed;
1230 // Check if the refund timer has expired yet
1231 if (new_playtime <= 2 * HOUR)
1232 {
1233 // No? Proceed.
1234 // Update the data field
1236 // Flag as changed to get saved to DB
1237 SetState(ITEM_CHANGED, owner);
1238 // Speaks for itself
1239 m_lastPlayedTimeUpdate = curtime;
1240 return;
1241 }
1242 // Yes
1243 SetNotRefundable(owner);
1244}
void SetNotRefundable(Player *owner, bool changestate=true, CharacterDatabaseTransaction *trans=nullptr)
Definition: Item.cpp:1200

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