OregonCore  revision fb2a440-git
Your Favourite TBC server
Item Class Reference

#include <Item.h>

+ Inheritance diagram for Item:

Public Member Functions

ItemCloneItem (uint32 count, Player const *player=NULL) const
 
 Item ()
 
virtual bool Create (uint32 guidlow, uint32 itemid, Player const *owner)
 
ItemTemplate const * GetProto () const
 
uint64 const & GetOwnerGUID () const
 
void SetOwnerGUID (uint64 guid)
 
PlayerGetOwner () const
 
void SetBinding (bool val)
 
bool IsSoulBound () const
 
bool IsBindedNotWith (Player const *player) const
 
bool IsBoundByEnchant () const
 
virtual void SaveToDB ()
 
virtual bool LoadFromDB (uint32 guid, uint64 owner_guid, Field *fields)
 
virtual void DeleteFromDB ()
 
void DeleteFromInventoryDB ()
 
bool IsLocked () const
 
bool IsBag () const
 
bool IsBroken () const
 
bool CanBeTraded () const
 
void SetInTrade (bool b=true)
 
bool IsInTrade () const
 
bool IsFitToSpellRequirements (SpellEntry const *spellInfo) const
 
bool IsLimitedToAnotherMapOrZone (uint32 cur_mapId, uint32 cur_zoneId) const
 
bool GemsFitSockets () const
 
uint32 GetCount () const
 
void SetCount (uint32 value)
 
uint32 GetMaxStackCount () const
 
uint8 GetGemCountWithID (uint32 GemID) const
 
uint8 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)
 
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
 
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=NULL)
 
void AddToUpdateQueueOf (Player *player)
 
void RemoveFromUpdateQueueOf (Player *player)
 
bool IsInUpdateQueue () const
 
uint16 GetQueuePos () const
 
void FSetState (ItemUpdateState state)
 
bool hasQuest (uint32 quest_id) const override
 
bool hasInvolvedQuest (uint32) const override
 
void BuildUpdate (UpdateDataMapType &) override
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
const bool & IsInWorld () const
 
virtual void AddToWorld ()
 
virtual void RemoveFromWorld ()
 
const uint64GetGUID () const
 
uint32 GetGUIDLow () const
 
uint32 GetGUIDMid () const
 
uint32 GetGUIDHigh () const
 
PackedGuid const & GetPackGUID () const
 
ObjectGuid const & GetObjectGUID () const
 
std::string GetGuidStr () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
void SetObjectScale (float scale)
 
uint8 GetTypeId () const
 
bool isType (uint16 mask) const
 
virtual void BuildCreateUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void SendUpdateToPlayer (Player *player)
 
void BuildValuesUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void BuildOutOfRangeUpdateBlock (UpdateData *data) const
 
void BuildMovementUpdateBlock (UpdateData *data, uint32 flags=0) const
 
virtual void DestroyForPlayer (Player *target, bool onDeath=false) const
 
const int32GetInt32Value (uint16 index) const
 
const uint32GetUInt32Value (uint16 index) const
 
const uint64GetUInt64Value (uint16 index) const
 
const float & GetFloatValue (uint16 index) const
 
uint8 GetByteValue (uint16 index, uint8 offset) const
 
ObjectGuid const & GetGuidValue (uint16 index) const
 
uint16 GetUInt16Value (uint16 index, uint8 offset) const
 
void SetInt32Value (uint16 index, int32 value)
 
void SetUInt32Value (uint16 index, uint32 value)
 
void SetUInt64Value (uint16 index, const 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 SetStatFloatValue (uint16 index, float value)
 
void SetStatInt32Value (uint16 index, int32 value)
 
bool AddUInt64Value (uint16 index, const uint64 &value)
 
bool RemoveUInt64Value (uint16 index, const uint64 &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 SetByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void RemoveByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void ToggleFlag (uint16 index, uint8 offset, uint8 flag)
 
bool HasByteFlag (uint16 index, uint8 offset, uint8 flag) const
 
void ApplyModFlag (uint16 index, uint32 flag, bool apply)
 
void SetFlag64 (uint16 index, uint64 newFlag)
 
void RemoveFlag64 (uint16 index, uint64 oldFlag)
 
void ToggleFlag64 (uint16 index, uint64 flag)
 
bool HasFlag64 (uint16 index, uint64 flag) const
 
void ApplyModFlag64 (uint16 index, uint64 flag, bool apply)
 
void ClearUpdateMask (bool remove)
 
bool LoadValues (const char *data)
 
uint16 GetValuesCount () const
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &) const
 
void ForceValuesUpdateAtIndex (uint32)
 
PlayerToPlayer ()
 
Player const * ToPlayer () const
 
CreatureToCreature ()
 
Creature const * ToCreature () const
 
UnitToUnit ()
 
Unit const * ToUnit () const
 
GameObjectToGameObject ()
 
GameObject const * ToGameObject () const
 
CorpseToCorpse ()
 
Corpse const * ToCorpse () const
 
DynamicObjectToDynObject ()
 
DynamicObject const * ToDynObject () const
 

Static Public Member Functions

static ItemCreateItem (uint32 item, uint32 count, Player const *player=NULL)
 
static int32 GenerateItemRandomPropertyId (uint32 item_id)
 

Public Attributes

Loot loot
 
bool m_lootGenerated
 

Private Attributes

uint8 m_slot
 
Bagm_container
 
ItemUpdateState uState
 
int16 uQueuePos
 
bool mb_in_trade
 

Additional Inherited Members

- Protected Member Functions inherited from Object
 Object ()
 
void _InitValues ()
 
void _Create (uint32 guidlow, uint32 entry, HighGuid guidhigh)
 
void _LoadIntoDataField (const char *data, uint32 startOffset, uint32 count)
 
virtual void _SetUpdateBits (UpdateMask *updateMask, Player *target) const
 
virtual void _SetCreateBits (UpdateMask *updateMask, Player *target) const
 
void _BuildMovementUpdate (ByteBuffer *data, uint8 updateFlags) const
 
void _BuildValuesUpdate (uint8 updatetype, ByteBuffer *data, UpdateMask *updateMask, Player *target) const
 
- Protected Attributes inherited from Object
uint16 m_objectType
 
uint8 m_objectTypeId
 
uint8 m_updateFlag
 
union {
   int32 *   m_int32Values
 
   uint32 *   m_uint32Values
 
   float *   m_floatValues
 
}; 
 
uint32m_uint32Values_mirror
 
uint16 m_valuesCount
 
bool m_objectUpdated
 

Detailed Description

Definition at line 196 of file Item.h.

Constructor & Destructor Documentation

Item::Item ( )

Definition at line 227 of file Item.cpp.

References ITEM_END, ITEM_NEW, m_container, m_lootGenerated, Object::m_objectType, Object::m_objectTypeId, m_slot, Object::m_updateFlag, Object::m_valuesCount, mb_in_trade, TYPEID_ITEM, TYPEMASK_ITEM, UPDATEFLAG_HIGHGUID, UPDATEFLAG_LOWGUID, uQueuePos, and uState.

Referenced by NewItemOrBag().

228 {
231  // 2.3.2 - 0x18
233 
235  m_slot = 0;
236  uState = ITEM_NEW;
237  uQueuePos = -1;
238  m_container = NULL;
239  m_lootGenerated = false;
240  mb_in_trade = false;
241 }
bool mb_in_trade
Definition: Item.h:380
bool m_lootGenerated
Definition: Item.h:340
Bag * m_container
Definition: Item.h:377
uint16 m_objectType
Definition: Object.h:424
ItemUpdateState uState
Definition: Item.h:378
uint8 m_objectTypeId
Definition: Object.h:426
uint8 m_updateFlag
Definition: Object.h:427
uint8 m_slot
Definition: Item.h:376
int16 uQueuePos
Definition: Item.h:379
uint16 m_valuesCount
Definition: Object.h:438
Definition: Item.h:188

Member Function Documentation

void Item::AddToUpdateQueueOf ( Player player)

Definition at line 688 of file Item.cpp.

References ASSERT, Object::GetGUID(), Object::GetGUIDLow(), GetOwnerGUID(), GUID_LOPART, IsInUpdateQueue(), Player::m_itemUpdateQueue, Player::m_itemUpdateQueueBlocked, sLog, and uQueuePos.

Referenced by AuctionHouseBot::addNewAuctions(), and SetState().

689 {
690  if (IsInUpdateQueue())
691  return;
692 
693  ASSERT(player != NULL);
694 
695  if (player->GetGUID() != GetOwnerGUID())
696  {
697  sLog.outDebug("Item::AddToUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow());
698  return;
699  }
700 
701  if (player->m_itemUpdateQueueBlocked)
702  return;
703 
704  player->m_itemUpdateQueue.push_back(this);
705  uQueuePos = player->m_itemUpdateQueue.size() - 1;
706 }
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
#define sLog
Log class singleton.
Definition: Log.h:187
uint32 GetGUIDLow() const
Definition: Object.h:166
std::vector< Item * > m_itemUpdateQueue
Definition: Player.h:2784
int16 uQueuePos
Definition: Item.h:379
#define ASSERT
Definition: Errors.h:29
bool IsInUpdateQueue() const
Definition: Item.h:350
uint64 const & GetOwnerGUID() const
Definition: Item.h:208
bool m_itemUpdateQueueBlocked
Definition: Player.h:2785
const uint64 & GetGUID() const
Definition: Object.h:162
void Item::BuildUpdate ( UpdateDataMapType data_map)
overridevirtual

Reimplemented from Object.

Definition at line 990 of file Item.cpp.

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

991 {
992  if (Player* owner = GetOwner())
993  BuildFieldsUpdate(owner, data_map);
994  ClearUpdateMask(false);
995 }
void ClearUpdateMask(bool remove)
Definition: Object.cpp:678
void BuildFieldsUpdate(Player *, UpdateDataMapType &) const
Definition: Object.cpp:690
Player * GetOwner() const
Definition: Item.cpp:465
Definition: Player.h:922
uint8 Item::CanBeMergedPartlyWith ( ItemTemplate const *  proto) const

Definition at line 774 of file Item.cpp.

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

Referenced by Player::_CanStoreItem_InBag(), Player::_CanStoreItem_InInventorySlots(), Player::_CanStoreItem_InSpecificSlot(), and Player::CanStoreItems().

775 {
776  // not allow merge looting currently items
777  if (m_lootGenerated)
779 
780  // check item type
781  if (GetEntry() != proto->ItemId)
783 
784  // check free space (full stacks can't be target of merge
785  if (GetCount() >= proto->Stackable)
787 
788  return EQUIP_ERR_OK;
789 }
uint32 GetCount() const
Definition: Item.h:251
bool m_lootGenerated
Definition: Item.h:340
uint32 GetEntry() const
Definition: Object.h:192
bool Item::CanBeTraded ( ) const

Definition at line 738 of file Item.cpp.

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

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

739 {
740  if (m_lootGenerated)
741  return false;
742 
743  if (IsSoulBound())
744  return false;
745 
746  if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()))
747  return false;
748 
749  if (Player* owner = GetOwner())
750  {
751  if (owner->CanUnequipItem(GetPos(), false) != EQUIP_ERR_OK)
752  return false;
753  if (owner->GetLootGUID() == GetGUID())
754  return false;
755  }
756 
757  if (IsBoundByEnchant())
758  return false;
759 
760  return true;
761 }
bool IsSoulBound() const
Definition: Item.h:219
bool m_lootGenerated
Definition: Item.h:340
uint16 GetPos() const
Definition: Item.h:279
bool IsBag() const
Definition: Item.h:229
Definition: Bag.h:27
Player * GetOwner() const
Definition: Item.cpp:465
bool IsBoundByEnchant() const
Definition: Item.cpp:763
static bool IsBagPos(uint16 pos)
Definition: Player.cpp:8667
Definition: Player.h:922
const uint64 & GetGUID() const
Definition: Object.h:162
void Item::ClearEnchantment ( EnchantmentSlot  slot)

Definition at line 847 of file Item.cpp.

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

Referenced by WorldSession::HandleCancelTempItemEnchantmentOpcode(), Player::RemoveAllEnchantments(), Player::RemoveItem(), and Player::SetVirtualItemSlot().

848 {
849  if (!GetEnchantmentId(slot))
850  return;
851 
852  for (uint8 x = 0; x < 3; ++x)
855 }
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:661
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
ACE_UINT8 uint8
Definition: Define.h:73
Player * GetOwner() const
Definition: Item.cpp:465
#define MAX_ENCHANTMENT_OFFSET
Definition: Item.h:174
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:313
Item * Item::CloneItem ( uint32  count,
Player const *  player = NULL 
) const

Definition at line 963 of file Item.cpp.

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

Referenced by Guild::_StoreItem(), Player::_StoreItem(), WorldSession::HandleGuildBankDepositItem(), WorldSession::HandleSellItemOpcode(), and Player::SplitItem().

964 {
965  Item* newItem = CreateItem(GetEntry(), count, player);
966  if (!newItem)
967  return NULL;
968 
974  return newItem;
975 }
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
void SetItemRandomProperties(int32 randomPropId)
Definition: Item.cpp:615
int32 GetItemRandomPropertyId() const
Definition: Item.h:298
Definition: Item.h:196
static Item * CreateItem(uint32 item, uint32 count, Player const *player=NULL)
Definition: Item.cpp:936
uint32 GetEntry() const
Definition: Object.h:192
bool Item::Create ( uint32  guidlow,
uint32  itemid,
Player const *  owner 
)
virtual

Reimplemented in Bag.

Definition at line 243 of file Item.cpp.

References Object::_Create(), Object::GetGUID(), HIGHGUID_ITEM, ITEM_FIELD_CONTAINED, ITEM_FIELD_DURABILITY, ITEM_FIELD_DURATION, ITEM_FIELD_MAXDURABILITY, ITEM_FIELD_OWNER, ITEM_FIELD_STACK_COUNT, MAX_ITEM_PROTO_SPELLS, Object::SetEntry(), Object::SetObjectScale(), SetSpellCharges(), Object::SetUInt32Value(), Object::SetUInt64Value(), and sObjectMgr.

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

244 {
245  Object::_Create(guidlow, 0, HIGHGUID_ITEM);
246 
247  SetEntry(itemid);
248  SetObjectScale(1.0f);
249 
250  SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0);
251  SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0);
252 
253  ItemTemplate const* itemProto = sObjectMgr.GetItemTemplate(itemid);
254  if (!itemProto)
255  return false;
256 
258  SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
259  SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability);
260 
261  for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
262  SetSpellCharges(i, itemProto->Spells[i].SpellCharges);
263 
264  SetUInt32Value(ITEM_FIELD_DURATION, abs(itemProto->Duration));
265 
266  return true;
267 }
void SetObjectScale(float scale)
Definition: Object.h:205
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
void SetEntry(uint32 entry)
Definition: Object.h:196
#define sObjectMgr
Definition: ObjectMgr.h:1285
void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
Definition: Object.cpp:125
ACE_UINT8 uint8
Definition: Define.h:73
#define MAX_ITEM_PROTO_SPELLS
void SetUInt64Value(uint16 index, const uint64 &value)
Definition: Object.cpp:798
void SetSpellCharges(uint8 index, int32 value)
Definition: Item.h:334
Item * Item::CreateItem ( uint32  item,
uint32  count,
Player const *  player = NULL 
)
static

Definition at line 936 of file Item.cpp.

References ASSERT, Create(), HIGHGUID_ITEM, NewItemOrBag(), SetCount(), sObjectMgr, and ItemTemplate::Stackable.

Referenced by AuctionHouseBot::addNewAuctions(), Player::CanEquipNewItem(), CloneItem(), Spell::EffectSummonChangeItem(), Player::EquipNewItem(), ChatHandler::HandleSendItemsCommand(), MailDraft::prepareItems(), WorldSession::SendExternalMails(), Battleground::SendRewardMarkByMail(), and Player::StoreNewItem().

937 {
938  if (count < 1)
939  return NULL; //don't create item at zero count
940 
941  ItemTemplate const* pProto = sObjectMgr.GetItemTemplate(item);
942  if (pProto)
943  {
944  if (count > pProto->Stackable)
945  count = pProto->Stackable;
946 
947  ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already");
948 
949  Item* pItem = NewItemOrBag(pProto);
950  if (pItem->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_ITEM), item, player))
951  {
952  pItem->SetCount(count);
953  return pItem;
954  }
955  else
956  delete pItem;
957  }
958  else
959  ASSERT(false);
960  return NULL;
961 }
void SetCount(uint32 value)
Definition: Item.h:255
#define sObjectMgr
Definition: ObjectMgr.h:1285
Item * NewItemOrBag(ItemTemplate const *proto)
Definition: Bag.h:70
virtual bool Create(uint32 guidlow, uint32 itemid, Player const *owner)
Definition: Item.cpp:243
Definition: Item.h:196
uint32 Stackable
#define ASSERT
Definition: Errors.h:29
void Item::DeleteFromDB ( )
virtual

Reimplemented in Bag.

Definition at line 450 of file Item.cpp.

References CharacterDatabase, Object::GetGUIDLow(), and Database::PExecute().

Referenced by Guild::_StoreItem(), and Bag::DeleteFromDB().

451 {
452  CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", GetGUIDLow());
453 }
uint32 GetGUIDLow() const
Definition: Object.h:166
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
void Item::DeleteFromInventoryDB ( )

Definition at line 455 of file Item.cpp.

References CharacterDatabase, Object::GetGUIDLow(), and Database::PExecute().

Referenced by Player::AutoUnequipOffhandIfNeed(), WorldSession::HandleAuctionSellItem(), WorldSession::HandleGuildBankDepositItem(), and WorldSession::HandleSendMail().

456 {
457  CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", GetGUIDLow());
458 }
uint32 GetGUIDLow() const
Definition: Object.h:166
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
void Item::FSetState ( ItemUpdateState  state)
inline
bool Item::GemsFitSockets ( ) const

Definition at line 857 of file Item.cpp.

References GemPropertiesEntry::color, _Socket::Color, SpellItemEnchantmentEntry::GemID, ItemTemplate::GemProperties, GetEnchantmentId(), GetProto(), SQLStorage::LookupEntry(), sGemPropertiesStore, sItemStorage, SOCK_ENCHANTMENT_SLOT, ItemTemplate::Socket, and sSpellItemEnchantmentStore.

Referenced by WorldSession::HandleSocketOpcode().

858 {
859  bool fits = true;
860  for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot)
861  {
863 
864  uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
865  if (!enchant_id)
866  {
867  if (SocketColor) fits &= false;
868  continue;
869  }
870 
871  SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
872  if (!enchantEntry)
873  {
874  if (SocketColor) fits &= false;
875  continue;
876  }
877 
878  uint8 GemColor = 0;
879 
880  uint32 gemid = enchantEntry->GemID;
881  if (gemid)
882  {
883  ItemTemplate const* gemProto = sItemStorage.LookupEntry<ItemTemplate>(gemid);
884  if (gemProto)
885  {
886  GemPropertiesEntry const* gemProperty = sGemPropertiesStore.LookupEntry(gemProto->GemProperties);
887  if (gemProperty)
888  GemColor = gemProperty->color;
889  }
890  }
891 
892  fits &= (GemColor & SocketColor) ? true : false;
893  }
894  return fits;
895 }
ItemTemplate const * GetProto() const
Definition: Item.cpp:460
SocketColor
_Socket Socket[3]
uint32 Color
ACE_UINT8 uint8
Definition: Define.h:73
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
SQLStorage sItemStorage
T const * LookupEntry(uint32 id) const
Definition: SQLStorage.h:52
DBCStorage< GemPropertiesEntry > sGemPropertiesStore(GemPropertiesEntryfmt)
EnchantmentSlot
Definition: Item.h:147
ACE_UINT32 uint32
Definition: Define.h:71
uint32 GemProperties
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:313
int32 Item::GenerateItemRandomPropertyId ( uint32  item_id)
static

Definition at line 569 of file Item.cpp.

References GetItemEnchantMod(), ItemRandomPropertiesEntry::ID, ItemRandomSuffixEntry::ID, ItemTemplate::ItemId, SQLStorage::LookupEntry(), ItemTemplate::RandomProperty, ItemTemplate::RandomSuffix, sItemRandomPropertiesStore, sItemRandomSuffixStore, sItemStorage, and sLog.

Referenced by Player::AddItem(), AuctionHouseBot::addNewAuctions(), Spell::DoCreateItem(), ChatHandler::HandleAddItemCommand(), LootItem::LootItem(), and Player::StoreNewItemInBestSlots().

570 {
571  ItemTemplate const* itemProto = sItemStorage.LookupEntry<ItemTemplate>(item_id);
572 
573  if (!itemProto)
574  return 0;
575 
576  // item must have one from this field values not null if it can have random enchantments
577  if ((!itemProto->RandomProperty) && (!itemProto->RandomSuffix))
578  return 0;
579 
580  // item can have not null only one from field values
581  if ((itemProto->RandomProperty) && (itemProto->RandomSuffix))
582  {
583  sLog.outErrorDb("Item template %u has RandomProperty == %u and RandomSuffix == %u, but must have one from field =0", itemProto->ItemId, itemProto->RandomProperty, itemProto->RandomSuffix);
584  return 0;
585  }
586 
587  // RandomProperty case
588  if (itemProto->RandomProperty)
589  {
590  uint32 randomPropId = GetItemEnchantMod(itemProto->RandomProperty);
591  ItemRandomPropertiesEntry const* random_id = sItemRandomPropertiesStore.LookupEntry(randomPropId);
592  if (!random_id)
593  {
594  sLog.outErrorDb("Enchantment id #%u used but it doesn't have a record in 'ItemRandomProperties.dbc'", randomPropId);
595  return 0;
596  }
597 
598  return random_id->ID;
599  }
600  // RandomSuffix case
601  else
602  {
603  uint32 randomPropId = GetItemEnchantMod(itemProto->RandomSuffix);
604  ItemRandomSuffixEntry const* random_id = sItemRandomSuffixStore.LookupEntry(randomPropId);
605  if (!random_id)
606  {
607  sLog.outErrorDb("Enchantment id #%u used but it doesn't have a record in sItemRandomSuffixStore.", randomPropId);
608  return 0;
609  }
610 
611  return -int32(random_id->ID);
612  }
613 }
uint32 GetItemEnchantMod(uint32 entry)
DBCStorage< ItemRandomSuffixEntry > sItemRandomSuffixStore(ItemRandomSuffixfmt)
#define sLog
Log class singleton.
Definition: Log.h:187
ACE_INT32 int32
Definition: Define.h:67
uint32 RandomSuffix
DBCStorage< ItemRandomPropertiesEntry > sItemRandomPropertiesStore(ItemRandomPropertiesfmt)
SQLStorage sItemStorage
T const * LookupEntry(uint32 id) const
Definition: SQLStorage.h:52
ACE_UINT32 uint32
Definition: Define.h:71
uint32 RandomProperty
Bag* Item::GetContainer ( )
inline

Definition at line 270 of file Item.h.

Referenced by Player::_SaveInventory(), and ChatHandler::HandleGetItemState().

271  {
272  return m_container;
273  }
Bag * m_container
Definition: Item.h:377
uint32 Item::GetCount ( ) const
inline

Definition at line 251 of file Item.h.

References ITEM_FIELD_STACK_COUNT.

Referenced by Player::_CanStoreItem_InBag(), Player::_CanStoreItem_InInventorySlots(), Guild::_CanStoreItem_InSpecificSlot(), Player::_CanStoreItem_InSpecificSlot(), Guild::_CanStoreItem_InTab(), Guild::_StoreItem(), Player::AddItemToBuyBackSlot(), AuctionHouseBot::addNewAuctionBuyerBotBid(), Guild::AppendDisplayGuildBankSlot(), AuctionEntry::BuildAuctionInfo(), Player::CanBankItem(), CanBeMergedPartlyWith(), Player::CanEquipItem(), Guild::CanStoreItem(), Player::CanStoreItem(), Player::CanStoreItems(), Player::CanTakeMoreSimilarItems(), Player::CanUnequipItem(), Spell::CheckItems(), Player::DestroyItem(), Player::DestroyItemCount(), WorldSession::DoLootRelease(), Spell::EffectProspecting(), Spell::EffectScriptEffect(), Player::EquipItem(), AuctionHouseMgr::GetAuctionDeposit(), Bag::GetItemCount(), WorldSession::HandleAuctionSellItem(), WorldSession::HandleBuybackItem(), WorldSession::HandleGetMail(), WorldSession::HandleGuildBankDepositItem(), WorldSession::HandleSellItemOpcode(), WorldSession::HandleSendMail(), WorldSession::HandleTakeItem(), Player::HasItemCount(), WorldSession::moveItems(), Player::MoveItemToInventory(), SaveToDB(), AuctionHouseMgr::SendAuctionWonMail(), Player::SendNewItem(), Player::SplitItem(), and Player::SwapItem().

252  {
254  }
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
uint8 Item::GetGemCountWithID ( uint32  GemID) const

Definition at line 897 of file Item.cpp.

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

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

898 {
899  uint8 count = 0;
900  for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot)
901  {
902  uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
903  if (!enchant_id)
904  continue;
905 
906  SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
907  if (!enchantEntry)
908  continue;
909 
910  if (GemID == enchantEntry->GemID)
911  ++count;
912  }
913  return count;
914 }
ACE_UINT8 uint8
Definition: Define.h:73
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
EnchantmentSlot
Definition: Item.h:147
ACE_UINT32 uint32
Definition: Define.h:71
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:313
uint32 Item::GetMaxStackCount ( ) const
inline
Player * Item::GetOwner ( ) const

Definition at line 465 of file Item.cpp.

References GetOwnerGUID(), and sObjectMgr.

Referenced by BuildUpdate(), CanBeTraded(), Spell::CheckItems(), ClearEnchantment(), Spell::EffectEnchantItemPerm(), Spell::EffectEnchantItemTmp(), SetEnchantment(), SetEnchantmentCharges(), and SetItemRandomProperties().

466 {
467  return sObjectMgr.GetPlayer(GetOwnerGUID());
468 }
#define sObjectMgr
Definition: ObjectMgr.h:1285
uint64 const & GetOwnerGUID() const
Definition: Item.h:208
uint16 Item::GetPos ( ) const
inline
ItemTemplate const * Item::GetProto ( ) const

Definition at line 460 of file Item.cpp.

References Object::GetEntry(), and sObjectMgr.

Referenced by Player::_ApplyAllItemMods(), Player::_ApplyItemMods(), Player::_CanStoreItem_InBag(), Player::_CanStoreItem_InSpecificSlot(), Player::_RemoveAllItemMods(), Player::_StoreItem(), AddItemsSetItem(), Player::AddItemToBuyBackSlot(), Player::AddQuestAndCheckCompletion(), Player::ApplyEnchantment(), Player::ApplyEquipCooldown(), Player::ApplyItemEquipSpell(), Player::AutoUnequipOffhandIfNeed(), AuctionHouseObject::BuildListAuctionItems(), Player::CanBankItem(), Player::CanEquipItem(), Player::CanStoreItems(), Player::CanUnequipItem(), Player::CanUseItem(), Player::CheckAmmoCompatibility(), Spell::CheckCast(), Spell::CheckItems(), Player::CorrectMetaGemEnchants(), Player::CreateCorpse(), Player::DestroyConjuredItems(), Player::DestroyItem(), Spell::DoCreateItem(), WorldSession::DoLootRelease(), Player::DurabilityRepair(), Spell::EffectDisEnchant(), Spell::EffectEnchantItemPerm(), Spell::EffectEnchantItemTmp(), Spell::EffectFeedPet(), Spell::EffectOpenLock(), Spell::EffectProspecting(), Spell::EffectScriptEffect(), Player::EnchantmentFitsRequirements(), Player::EquipItem(), Player::FindEquipSlot(), GemsFitSockets(), Unit::GetAPMultiplier(), AuctionHouseMgr::GetAuctionDeposit(), Bag::GetItemCount(), Player::GetItemCount(), Player::GetItemOrItemWithGemEquipped(), Player::GetShield(), GetSkill(), GetSpell(), Unit::GetUnitBlockChance(), Player::GetWeaponForAttack(), WorldSession::HandleAuctionSellItem(), Unit::HandleDummyAuraProc(), WorldSession::HandleGuildBankDepositItem(), WorldSession::HandleOpenItemOpcode(), WorldSession::HandleReadItem(), WorldSession::HandleSellItemOpcode(), WorldSession::HandleSendMail(), WorldSession::HandleSocketOpcode(), WorldSession::HandleTakeItem(), WorldSession::HandleUseItemOpcode(), WorldSession::HandleWrapItemOpcode(), Player::HasItemTotemCategory(), IsFitToSpellRequirements(), IsLimitedToAnotherMapOrZone(), Unit::IsTriggeredAtSpellProcEvent(), ScriptMgr::ItemHello(), ScriptMgr::ItemUse(), LoadFromDB(), AuctionHouseBot::LoadValues(), WorldSession::moveItems(), ScriptMgr::OnQuestAccept(), Player::RemoveItem(), AuctionHouseMgr::SendAuctionWonMail(), Player::SendEquipError(), Player::SendLoot(), Spell::SendSpellCooldown(), WorldSession::SendUpdateTrade(), Player::SetRegularAttackTime(), Unit::SpellDamageBonus(), Spell::SpellDamageWeaponDmg(), Spell::SummonGuardian(), Player::SwapItem(), Spell::TakeCastItem(), Spell::TakeReagents(), Player::ToggleMetaGemsActive(), Player::UpdateItemDuration(), Player::UpdateWeaponSkill(), Player::VisualizeItem(), and Spell::WriteAmmoToPacket().

461 {
462  return sObjectMgr.GetItemTemplate(GetEntry());
463 }
#define sObjectMgr
Definition: ObjectMgr.h:1285
uint32 GetEntry() const
Definition: Object.h:192
uint16 Item::GetQueuePos ( ) const
inline

Definition at line 354 of file Item.h.

Referenced by ChatHandler::HandleGetItemState().

355  {
356  return uQueuePos;
357  }
int16 uQueuePos
Definition: Item.h:379
uint32 Item::GetSkill ( )

Definition at line 470 of file Item.cpp.

References ItemTemplate::Class, GetProto(), ITEM_CLASS_ARMOR, ITEM_CLASS_WEAPON, MAX_ITEM_SUBCLASS_ARMOR, MAX_ITEM_SUBCLASS_WEAPON, SKILL_2H_AXES, SKILL_2H_MACES, SKILL_2H_SWORDS, SKILL_ASSASSINATION, SKILL_AXES, SKILL_BOWS, SKILL_CLOTH, SKILL_CROSSBOWS, SKILL_DAGGERS, SKILL_FISHING, SKILL_FIST_WEAPONS, SKILL_GUNS, SKILL_LEATHER, SKILL_MACES, SKILL_MAIL, SKILL_PLATE_MAIL, SKILL_POLEARMS, SKILL_SHIELD, SKILL_STAVES, SKILL_SWORDS, SKILL_THROWN, SKILL_WANDS, and ItemTemplate::SubClass.

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

471 {
472  const static uint32 item_weapon_skills[MAX_ITEM_SUBCLASS_WEAPON] =
473  {
479  };
480 
481  const static uint32 item_armor_skills[MAX_ITEM_SUBCLASS_ARMOR] =
482  {
484  };
485 
486  ItemTemplate const* proto = GetProto();
487 
488  switch (proto->Class)
489  {
490  case ITEM_CLASS_WEAPON:
491  if (proto->SubClass >= MAX_ITEM_SUBCLASS_WEAPON)
492  return 0;
493  else
494  return item_weapon_skills[proto->SubClass];
495 
496  case ITEM_CLASS_ARMOR:
497  if (proto->SubClass >= MAX_ITEM_SUBCLASS_ARMOR)
498  return 0;
499  else
500  return item_armor_skills[proto->SubClass];
501 
502  default:
503  return 0;
504  }
505 }
ItemTemplate const * GetProto() const
Definition: Item.cpp:460
#define MAX_ITEM_SUBCLASS_ARMOR
ACE_UINT32 uint32
Definition: Define.h:71
#define MAX_ITEM_SUBCLASS_WEAPON
uint32 Item::GetSpell ( )

Definition at line 507 of file Item.cpp.

References ItemTemplate::Class, GetProto(), 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.

508 {
509  ItemTemplate const* proto = GetProto();
510 
511  switch (proto->Class)
512  {
513  case ITEM_CLASS_WEAPON:
514  switch (proto->SubClass)
515  {
517  return 196;
519  return 197;
521  return 264;
523  return 266;
525  return 198;
527  return 199;
529  return 200;
531  return 201;
533  return 202;
535  return 227;
537  return 1180;
539  return 2567;
541  return 3386;
543  return 5011;
545  return 5009;
546  default:
547  return 0;
548  }
549  case ITEM_CLASS_ARMOR:
550  switch (proto->SubClass)
551  {
553  return 9078;
555  return 9077;
557  return 8737;
559  return 750;
561  return 9116;
562  default:
563  return 0;
564  }
565  }
566  return 0;
567 }
ItemTemplate const * GetProto() const
Definition: Item.cpp:460
int32 Item::GetSpellCharges ( uint8  index = 0) const
inline
ItemUpdateState Item::GetState ( ) const
inline

Definition at line 343 of file Item.h.

Referenced by Player::_SaveInventory(), ChatHandler::HandleGetItemState(), and WorldSession::HandleWrapItemOpcode().

344  {
345  return uState;
346  }
ItemUpdateState uState
Definition: Item.h:378
bool Item::hasInvolvedQuest ( uint32  ) const
inlineoverridevirtual

Reimplemented from Object.

Definition at line 368 of file Item.h.

369  {
370  return false;
371  }
bool Item::hasQuest ( uint32  quest_id) const
inlineoverridevirtual

Reimplemented from Object.

Definition at line 363 of file Item.h.

References ItemTemplate::StartQuest.

364  {
365  ItemTemplate const* itemProto = GetProto();
366  return itemProto && itemProto->StartQuest == quest_id;
367  }
ItemTemplate const * GetProto() const
Definition: Item.cpp:460
uint32 StartQuest
bool Item::IsBindedNotWith ( Player const *  player) const

Definition at line 977 of file Item.cpp.

References Object::GetGUID(), GetOwnerGUID(), and IsSoulBound().

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

978 {
979  // not binded item
980  if (!IsSoulBound())
981  return false;
982 
983  // own item
984  if (GetOwnerGUID() == player->GetGUID())
985  return false;
986 
987  return true;
988 }
bool IsSoulBound() const
Definition: Item.h:219
uint64 const & GetOwnerGUID() const
Definition: Item.h:208
bool Item::IsBoundByEnchant ( ) const

Definition at line 763 of file Item.cpp.

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

Referenced by CanBeTraded().

764 {
765  // Check all enchants for soulbound
766  for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot)
767  if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)))
768  if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id))
769  if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
770  return true;
771  return false;
772 }
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
EnchantmentSlot
Definition: Item.h:147
ACE_UINT32 uint32
Definition: Define.h:71
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:313
bool Item::IsFitToSpellRequirements ( SpellEntry const *  spellInfo) const

Definition at line 791 of file Item.cpp.

References ItemTemplate::Class, SpellEntry::EquippedItemClass, SpellEntry::EquippedItemInventoryTypeMask, SpellEntry::EquippedItemSubClassMask, GetProto(), ItemTemplate::InventoryType, and ItemTemplate::SubClass.

Referenced by Player::_ApplyWeaponDependentAuraCritMod(), Player::_ApplyWeaponDependentAuraDamageMod(), Spell::CheckItems(), Spell::EffectTriggerSpell(), Player::HasItemFitToSpellReqirements(), and Player::UpdateExpertise().

792 {
793  ItemTemplate const* proto = GetProto();
794 
795  if (spellInfo->EquippedItemClass != -1) // -1 == any item class
796  {
797  if (spellInfo->EquippedItemClass != int32(proto->Class))
798  return false; // wrong item class
799 
800  if (spellInfo->EquippedItemSubClassMask != 0) // 0 == any subclass
801  {
802  if ((spellInfo->EquippedItemSubClassMask & (1 << proto->SubClass)) == 0)
803  return false; // subclass not present in mask
804  }
805  }
806 
807  if (spellInfo->EquippedItemInventoryTypeMask != 0) // 0 == any inventory type
808  {
809  if ((spellInfo->EquippedItemInventoryTypeMask & (1 << proto->InventoryType)) == 0)
810  return false; // inventory type not present in mask
811  }
812 
813  return true;
814 }
ItemTemplate const * GetProto() const
Definition: Item.cpp:460
uint32 InventoryType
ACE_INT32 int32
Definition: Define.h:67
bool Item::IsInBag ( ) const
inline

Definition at line 288 of file Item.h.

Referenced by IsEquipped().

289  {
290  return m_container != NULL;
291  }
Bag * m_container
Definition: Item.h:377
bool Item::IsInTrade ( ) const
inline

Definition at line 242 of file Item.h.

Referenced by Player::CanStoreItems().

243  {
244  return mb_in_trade;
245  }
bool mb_in_trade
Definition: Item.h:380
bool Item::IsInUpdateQueue ( ) const
inline

Definition at line 350 of file Item.h.

Referenced by AddToUpdateQueueOf(), ChatHandler::HandleGetItemState(), and RemoveFromUpdateQueueOf().

351  {
352  return uQueuePos != -1;
353  }
int16 uQueuePos
Definition: Item.h:379
bool Item::IsLimitedToAnotherMapOrZone ( uint32  cur_mapId,
uint32  cur_zoneId 
) const

Definition at line 916 of file Item.cpp.

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

Referenced by Player::_LoadInventory(), and Player::DestroyZoneLimitedItem().

917 {
918  ItemTemplate const* proto = GetProto();
919  return proto && ((proto->Map && proto->Map != cur_mapId) || (proto->Area && proto->Area != cur_zoneId));
920 }
ItemTemplate const * GetProto() const
Definition: Item.cpp:460
bool Item::IsLocked ( ) const
inline

Definition at line 228 of file Item.h.

References ITEM_FIELD_FLAGS, and ITEM_FLAG_UNLOCKED.

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

bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:305
bool Item::IsSoulBound ( ) const
inline
bool Item::LoadFromDB ( uint32  guid,
uint64  owner_guid,
Field fields 
)
virtual

Reimplemented in Bag.

Definition at line 369 of file Item.cpp.

References Object::_Create(), Object::_LoadIntoDataField(), Object::ApplyModFlag(), ItemTemplate::Bonding, CharacterDatabase, ItemTemplate::Duration, Database::Execute(), GetItemRandomPropertyId(), GetProto(), Object::GetUInt32Value(), HIGHGUID_ITEM, HIGHGUID_PLAYER, IsSoulBound(), ITEM_FIELD_CREATOR, ITEM_FIELD_DURABILITY, ITEM_FIELD_DURATION, ITEM_FIELD_ENCHANTMENT, ITEM_FIELD_FLAGS, ITEM_FIELD_GIFTCREATOR, ITEM_FIELD_ITEM_TEXT_ID, ITEM_FIELD_MAXDURABILITY, ITEM_FIELD_RANDOM_PROPERTIES_ID, ITEM_FLAG_SOULBOUND, MAKE_NEW_GUID, MAX_ENCHANTMENT_OFFSET, MAX_ENCHANTMENT_SLOT, MAX_ITEM_PROTO_SPELLS, ItemTemplate::MaxDurability, NO_BIND, SetCount(), Object::SetEntry(), Object::SetInt32Value(), Object::SetObjectScale(), SetOwnerGUID(), SetSpellCharges(), Object::SetUInt32Value(), Object::SetUInt64Value(), StrSplit(), and UpdateItemSuffixFactor().

Referenced by Player::_LoadInventory(), Player::_LoadMailedItems(), Player::DeleteFromDB(), AuctionHouseMgr::LoadAuctionItems(), Bag::LoadFromDB(), and Guild::LoadGuildBankFromDB().

370 {
371  // 0 1 2 3 4 5 6 7 8 9 10
372  //result = CharacterDatabase.PQuery("SELECT itemEntry, creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, itemTextId FROM item_instance WHERE guid = '%u'", guid);
373 
374  // create item before any checks for store correct guid
375  // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
376  Object::_Create(guid, 0, HIGHGUID_ITEM);
377 
378  // Set entry, MUST be before proto check
379  SetEntry(fields[0].GetUInt32());
380  SetObjectScale(1.0f);
381 
382  ItemTemplate const* proto = GetProto();
383  if (!proto)
384  return false;
385 
386  // set owner (not if item is only loaded for gbank/auction/mail)
387  if (owner_guid)
388  SetOwnerGUID(owner_guid);
389 
390  bool need_save = false; // need explicit save data at load fixes
391  SetUInt64Value(ITEM_FIELD_CREATOR, MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER));
393  SetCount(fields[3].GetUInt32());
394 
395  uint32 duration = fields[4].GetUInt32();
397  // update duration if need, and remove if not need
398  if ((proto->Duration == 0) != (duration == 0))
399  {
400  SetUInt32Value(ITEM_FIELD_DURATION, abs(proto->Duration)); //why is abs needed here?
401  need_save = true;
402  }
403 
404  Tokens tokens = StrSplit(fields[5].GetCppString(), " ");
405  if (tokens.size() == MAX_ITEM_PROTO_SPELLS)
406  for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
407  SetSpellCharges(i, atoi(tokens[i].c_str()));
408 
409  SetUInt32Value(ITEM_FIELD_FLAGS, fields[6].GetUInt32());
410  // Remove bind flag for items vs NO_BIND set
411  if (IsSoulBound() && proto->Bonding == NO_BIND)
412  {
414  need_save = true;
415  }
416 
418  SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[8].GetInt16());
419 
420  // recalculate suffix factor
421  if (GetItemRandomPropertyId() < 0)
423 
424  uint32 durability = fields[9].GetUInt16();
426  // update max durability (and durability) if need
428  if (durability > proto->MaxDurability)
429  {
431  need_save = true;
432  }
433 
434  SetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID, fields[10].GetUInt32());
435 
436  if (need_save) // normal item changed state set not work at loading
437  {
438  std::ostringstream ss;
439  ss << "UPDATE item_instance SET duration = " << GetUInt32Value(ITEM_FIELD_DURATION)
440  << ", flags = " << GetUInt32Value(ITEM_FIELD_FLAGS)
441  << ", durability = " << GetUInt32Value(ITEM_FIELD_DURABILITY)
442  << " WHERE guid = " << guid;
443 
444  CharacterDatabase.Execute(ss.str().c_str());
445  }
446 
447  return true;
448 }
ItemTemplate const * GetProto() const
Definition: Item.cpp:460
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
std::vector< std::string > Tokens
Definition: Util.h:26
bool IsSoulBound() const
Definition: Item.h:219
void SetInt32Value(uint16 index, int32 value)
Definition: Object.cpp:760
void SetObjectScale(float scale)
Definition: Object.h:205
bool Execute(const char *sql)
Definition: Database.cpp:420
void _LoadIntoDataField(const char *data, uint32 startOffset, uint32 count)
Definition: Object.cpp:721
Tokens StrSplit(const std::string &src, const std::string &sep)
Definition: Util.cpp:58
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
void SetCount(uint32 value)
Definition: Item.h:255
void SetEntry(uint32 entry)
Definition: Object.h:196
void SetOwnerGUID(uint64 guid)
Definition: Item.h:212
int32 GetItemRandomPropertyId() const
Definition: Item.h:298
void UpdateItemSuffixFactor()
Definition: Item.cpp:653
void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
Definition: Object.cpp:125
ACE_UINT8 uint8
Definition: Define.h:73
#define MAKE_NEW_GUID(l, e, h)
Definition: ObjectGuid.h:80
#define MAX_ENCHANTMENT_OFFSET
Definition: Item.h:174
#define MAX_ITEM_PROTO_SPELLS
void SetUInt64Value(uint16 index, const uint64 &value)
Definition: Object.cpp:798
uint32 MaxDurability
void SetSpellCharges(uint8 index, int32 value)
Definition: Item.h:334
void ApplyModFlag(uint16 index, uint32 flag, bool apply)
Definition: Object.h:329
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
ACE_UINT32 uint32
Definition: Define.h:71
void Item::RemoveFromUpdateQueueOf ( Player player)

Definition at line 708 of file Item.cpp.

References ASSERT, Object::GetGUID(), Object::GetGUIDLow(), GetOwnerGUID(), GUID_LOPART, IsInUpdateQueue(), Player::m_itemUpdateQueue, Player::m_itemUpdateQueueBlocked, sLog, and uQueuePos.

Referenced by AuctionHouseBot::addNewAuctions(), WorldSession::HandleSellItemOpcode(), WorldSession::HandleWrapItemOpcode(), and SetState().

709 {
710  if (!IsInUpdateQueue())
711  return;
712 
713  ASSERT(player != NULL)
714 
715  if (player->GetGUID() != GetOwnerGUID())
716  {
717  sLog.outDebug("Item::RemoveFromUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow());
718  return;
719  }
720 
721  if (player->m_itemUpdateQueueBlocked)
722  return;
723 
724  player->m_itemUpdateQueue[uQueuePos] = NULL;
725  uQueuePos = -1;
726 }
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
#define sLog
Log class singleton.
Definition: Log.h:187
uint32 GetGUIDLow() const
Definition: Object.h:166
std::vector< Item * > m_itemUpdateQueue
Definition: Player.h:2784
int16 uQueuePos
Definition: Item.h:379
#define ASSERT
Definition: Errors.h:29
bool IsInUpdateQueue() const
Definition: Item.h:350
uint64 const & GetOwnerGUID() const
Definition: Item.h:208
bool m_itemUpdateQueueBlocked
Definition: Player.h:2785
const uint64 & GetGUID() const
Definition: Object.h:162
void Item::SaveToDB ( )
virtual

Reimplemented in Bag.

Definition at line 286 of file Item.cpp.

References CharacterDatabase, Database::Execute(), GetCount(), GetEnchantmentCharges(), GetEnchantmentDuration(), GetEnchantmentId(), Object::GetEntry(), Object::GetGUIDLow(), GetItemRandomPropertyId(), GetOwnerGUID(), GetSpellCharges(), Object::GetUInt32Value(), Object::GetUInt64Value(), GUID_LOPART, Object::HasFlag(), ITEM_CHANGED, ITEM_FIELD_CREATOR, ITEM_FIELD_DURABILITY, ITEM_FIELD_DURATION, ITEM_FIELD_FLAGS, ITEM_FIELD_GIFTCREATOR, ITEM_FIELD_ITEM_TEXT_ID, ITEM_FLAG_WRAPPED, ITEM_NEW, ITEM_REMOVED, ITEM_UNCHANGED, MAX_ENCHANTMENT_SLOT, MAX_ITEM_PROTO_SPELLS, Database::PExecute(), SetState(), and uState.

Referenced by Player::_LoadInventory(), Player::_LoadMailedItems(), Player::_SaveInventory(), Guild::_StoreItem(), AuctionHouseBot::addNewAuctions(), Player::AutoUnequipOffhandIfNeed(), Player::DeleteFromDB(), WorldSession::HandleAuctionSellItem(), WorldSession::HandleGuildBankDepositItem(), WorldSession::HandleSendMail(), WorldSession::HandleWrapItemOpcode(), Bag::SaveToDB(), and MailDraft::SendReturnToSender().

287 {
288  uint32 guid = GetGUIDLow();
289  switch (uState)
290  {
291  case ITEM_NEW:
292  {
293  std::ostringstream ss;
294  ss << "REPLACE INTO item_instance (guid,owner_guid,itemEntry,creatorGuid,giftCreatorGuid,count,duration,charges,flags,enchantments,randomPropertyId,durability,itemTextId) VALUES (";
295  ss << guid << ",";
296  ss << GUID_LOPART(GetOwnerGUID()) << ",";
297  ss << GetEntry() << ",";
300  ss << GetCount() << ",";
301  ss << GetUInt32Value(ITEM_FIELD_DURATION) << ",'";
302  for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
303  ss << GetSpellCharges(i) << " ";
304 
305  ss << "'," << GetUInt32Value(ITEM_FIELD_FLAGS) << ",'";
306  for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)
307  {
308  ss << GetEnchantmentId(EnchantmentSlot(i)) << " ";
309  ss << GetEnchantmentDuration(EnchantmentSlot(i)) << " ";
310  ss << GetEnchantmentCharges(EnchantmentSlot(i)) << " ";
311  }
312 
313  ss << "'," << GetItemRandomPropertyId() << ",";
316 
317  CharacterDatabase.Execute(ss.str().c_str());
318  }
319  break;
320  case ITEM_CHANGED:
321  {
322  std::ostringstream ss;
323  ss << "UPDATE item_instance SET owner_guid = " << GUID_LOPART(GetOwnerGUID());
324  ss << ", itemEntry = " << GetEntry();
325  ss << ", creatorGuid = " << GUID_LOPART(GetUInt64Value(ITEM_FIELD_CREATOR));
326  ss << ", giftCreatorGuid = " << GUID_LOPART(GetUInt64Value(ITEM_FIELD_GIFTCREATOR));
327  ss << ", count = " << GetCount();
328  ss << ", duration = " << GetUInt32Value(ITEM_FIELD_DURATION);
329  ss << ", charges = '";
330  for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
331  ss << GetSpellCharges(i) << " ";
332 
333  ss << "', flags = " << GetUInt32Value(ITEM_FIELD_FLAGS);
334  ss << ", enchantments = '";
335  for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)
336  {
337  ss << GetEnchantmentId(EnchantmentSlot(i)) << " ";
338  ss << GetEnchantmentDuration(EnchantmentSlot(i)) << " ";
339  ss << GetEnchantmentCharges(EnchantmentSlot(i)) << " ";
340  }
341 
342  ss << "', randomPropertyId = " << GetItemRandomPropertyId();
343  ss << ", durability = " << GetUInt32Value(ITEM_FIELD_DURABILITY);
344  ss << ", itemTextId = " << GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID);
345  ss << " WHERE guid = " << guid;
346 
347  CharacterDatabase.Execute(ss.str().c_str());
348 
350  CharacterDatabase.PExecute("UPDATE character_gifts SET guid = '%u' WHERE item_guid = '%u'", GUID_LOPART(GetOwnerGUID()), GetGUIDLow());
351  }
352  break;
353  case ITEM_REMOVED:
354  {
356  CharacterDatabase.PExecute("DELETE FROM item_text WHERE id = '%u'", GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID));
357  CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", guid);
359  CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", GetGUIDLow());
360  delete this;
361  return;
362  }
363  case ITEM_UNCHANGED:
364  break;
365  }
367 }
uint32 GetCount() const
Definition: Item.h:251
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:661
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
int32 GetSpellCharges(uint8 index=0) const
Definition: Item.h:330
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
bool Execute(const char *sql)
Definition: Database.cpp:420
const uint64 & GetUInt64Value(uint16 index) const
Definition: Object.h:240
uint32 GetGUIDLow() const
Definition: Object.h:166
int32 GetItemRandomPropertyId() const
Definition: Item.h:298
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const
Definition: Item.h:317
ItemUpdateState uState
Definition: Item.h:378
ACE_UINT8 uint8
Definition: Define.h:73
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
#define MAX_ITEM_PROTO_SPELLS
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const
Definition: Item.h:321
EnchantmentSlot
Definition: Item.h:147
uint32 GetEntry() const
Definition: Object.h:192
Definition: Item.h:188
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:305
ACE_UINT32 uint32
Definition: Define.h:71
uint64 const & GetOwnerGUID() const
Definition: Item.h:208
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:313
void Item::SendTimeUpdate ( Player owner)

Definition at line 925 of file Item.cpp.

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

Referenced by Player::AddItemDurations().

926 {
928  return;
929 
930  WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8 + 4));
931  data << (uint64)GetGUID();
933  owner->GetSession()->SendPacket(&data);
934 }
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
void SendPacket(WorldPacket const *packet)
ACE_UINT64 uint64
Definition: Define.h:70
WorldSession * GetSession() const
Definition: Player.h:1944
ACE_UINT32 uint32
Definition: Define.h:71
const uint64 & GetGUID() const
Definition: Object.h:162
void Item::SetBinding ( bool  val)
inline
void Item::SetContainer ( Bag container)
inline

Definition at line 283 of file Item.h.

Referenced by Player::_LoadInventory(), Player::_StoreItem(), Bag::RemoveItem(), Bag::StoreItem(), and Player::VisualizeItem().

284  {
285  m_container = container;
286  }
Bag * m_container
Definition: Item.h:377
void Item::SetEnchantment ( EnchantmentSlot  slot,
uint32  id,
uint32  duration,
uint32  charges 
)

Definition at line 816 of file Item.cpp.

References ENCHANTMENT_CHARGES_OFFSET, ENCHANTMENT_DURATION_OFFSET, ENCHANTMENT_ID_OFFSET, GetEnchantmentCharges(), GetEnchantmentDuration(), GetEnchantmentId(), GetOwner(), ITEM_CHANGED, ITEM_FIELD_ENCHANTMENT, MAX_ENCHANTMENT_OFFSET, SetState(), and Object::SetUInt32Value().

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

817 {
818  // Better lost small time at check in comparison lost time at item save to DB.
819  if ((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges))
820  return;
821 
826 }
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:661
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const
Definition: Item.h:317
Player * GetOwner() const
Definition: Item.cpp:465
#define MAX_ENCHANTMENT_OFFSET
Definition: Item.h:174
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const
Definition: Item.h:321
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:313
void Item::SetEnchantmentCharges ( EnchantmentSlot  slot,
uint32  charges 
)

Definition at line 838 of file Item.cpp.

References ENCHANTMENT_CHARGES_OFFSET, GetEnchantmentCharges(), GetOwner(), ITEM_CHANGED, ITEM_FIELD_ENCHANTMENT, MAX_ENCHANTMENT_OFFSET, SetState(), and Object::SetUInt32Value().

Referenced by Player::SetVirtualItemSlot().

839 {
840  if (GetEnchantmentCharges(slot) == charges)
841  return;
842 
845 }
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:661
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
Player * GetOwner() const
Definition: Item.cpp:465
#define MAX_ENCHANTMENT_OFFSET
Definition: Item.h:174
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const
Definition: Item.h:321
void Item::SetEnchantmentDuration ( EnchantmentSlot  slot,
uint32  duration,
Player owner 
)

Definition at line 828 of file Item.cpp.

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

Referenced by Player::RemoveEnchantmentDurations().

829 {
830  if (GetEnchantmentDuration(slot) == duration)
831  return;
832 
834  SetState(ITEM_CHANGED, owner);
835  // Cannot use GetOwner() here, has to be passed as an argument to avoid freeze due to hashtable locking
836 }
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:661
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const
Definition: Item.h:317
#define MAX_ENCHANTMENT_OFFSET
Definition: Item.h:174
void Item::SetInTrade ( bool  b = true)
inline

Definition at line 238 of file Item.h.

Referenced by WorldSession::HandleAcceptTradeOpcode().

239  {
240  mb_in_trade = b;
241  }
bool mb_in_trade
Definition: Item.h:380
void Item::SetItemRandomProperties ( int32  randomPropId)

Definition at line 615 of file Item.cpp.

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

Referenced by AuctionHouseBot::addNewAuctions(), and CloneItem().

616 {
617  if (!randomPropId)
618  return;
619 
620  if (randomPropId > 0)
621  {
622  ItemRandomPropertiesEntry const* item_rand = sItemRandomPropertiesStore.LookupEntry(randomPropId);
623  if (item_rand)
624  {
626  {
629  }
631  SetEnchantment(EnchantmentSlot(i), item_rand->enchant_id[i - PROP_ENCHANTMENT_SLOT_2], 0, 0);
632  }
633  }
634  else
635  {
636  ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(-randomPropId);
637  if (item_rand)
638  {
639  if (GetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID) != -int32(item_rand->ID) ||
641  {
645  }
646 
648  SetEnchantment(EnchantmentSlot(i), item_rand->enchant_id[i - PROP_ENCHANTMENT_SLOT_0], 0, 0);
649  }
650  }
651 }
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:661
uint32 GetItemSuffixFactor() const
Definition: Item.h:302
void SetInt32Value(uint16 index, int32 value)
Definition: Object.cpp:760
DBCStorage< ItemRandomSuffixEntry > sItemRandomSuffixStore(ItemRandomSuffixfmt)
ACE_INT32 int32
Definition: Define.h:67
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges)
Definition: Item.cpp:816
void UpdateItemSuffixFactor()
Definition: Item.cpp:653
DBCStorage< ItemRandomPropertiesEntry > sItemRandomPropertiesStore(ItemRandomPropertiesfmt)
Player * GetOwner() const
Definition: Item.cpp:465
EnchantmentSlot
Definition: Item.h:147
const int32 & GetInt32Value(uint16 index) const
Definition: Object.h:228
ACE_UINT32 uint32
Definition: Define.h:71
void Item::SetOwnerGUID ( uint64  guid)
inline

Definition at line 212 of file Item.h.

References ITEM_FIELD_OWNER.

Referenced by Player::_StoreItem(), Player::EquipItem(), and LoadFromDB().

213  {
215  }
void SetUInt64Value(uint16 index, const uint64 &value)
Definition: Object.cpp:798
void Item::SetSlot ( uint8  slot)
inline

Definition at line 275 of file Item.h.

Referenced by Player::_LoadInventory(), Player::_StoreItem(), Player::DestroyItem(), Player::RemoveItem(), Bag::StoreItem(), and Player::VisualizeItem().

276  {
277  m_slot = slot;
278  }
uint8 m_slot
Definition: Item.h:376
void Item::SetSpellCharges ( uint8  index,
int32  value 
)
inline

Definition at line 334 of file Item.h.

References ITEM_FIELD_SPELL_CHARGES.

Referenced by Create(), LoadFromDB(), and Spell::TakeCastItem().

335  {
337  }
void SetInt32Value(uint16 index, int32 value)
Definition: Object.cpp:760
etc mysql my cnf *Then change max_allowed_packet to a bigger value
void Item::SetState ( ItemUpdateState  state,
Player forplayer = NULL 
)

Definition at line 661 of file Item.cpp.

References AddToUpdateQueueOf(), ITEM_NEW, ITEM_REMOVED, ITEM_UNCHANGED, RemoveFromUpdateQueueOf(), uQueuePos, and uState.

Referenced by Player::_LoadInventory(), Player::_StoreItem(), ClearEnchantment(), Player::DestroyItem(), Player::DestroyItemCount(), Player::DurabilityPointsLoss(), Player::DurabilityRepair(), Player::EquipItem(), WorldSession::HandleGuildBankDepositItem(), WorldSession::HandleOpenItemOpcode(), WorldSession::HandlePetitionBuyOpcode(), WorldSession::HandleSellItemOpcode(), WorldSession::HandleUseItemOpcode(), WorldSession::HandleWrapItemOpcode(), Player::RemoveItemFromBuyBackSlot(), SaveToDB(), SetEnchantment(), SetEnchantmentCharges(), SetEnchantmentDuration(), SetItemRandomProperties(), Player::SplitItem(), Player::SwapItem(), Spell::TakeCastItem(), UpdateDuration(), and Player::VisualizeItem().

662 {
663  if (uState == ITEM_NEW && state == ITEM_REMOVED)
664  {
665  // pretend the item never existed
666  if (forplayer)
667  RemoveFromUpdateQueueOf(forplayer);
668  delete this;
669  return;
670  }
671  if (state != ITEM_UNCHANGED)
672  {
673  // new items must stay in new state until saved
674  if (uState != ITEM_NEW)
675  uState = state;
676  if (forplayer)
677  AddToUpdateQueueOf(forplayer);
678  }
679  else
680  {
681  // unset in queue
682  // the item must be removed from the queue manually
683  uQueuePos = -1;
685  }
686 }
void AddToUpdateQueueOf(Player *player)
Definition: Item.cpp:688
ItemUpdateState uState
Definition: Item.h:378
void RemoveFromUpdateQueueOf(Player *player)
Definition: Item.cpp:708
int16 uQueuePos
Definition: Item.h:379
Definition: Item.h:188
void Item::UpdateDuration ( Player owner,
uint32  diff 
)

Definition at line 269 of file Item.cpp.

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

Referenced by Player::UpdateItemDuration().

270 {
272  return;
273 
274  sLog.outDebug("Item::UpdateDuration Item (Entry: %u Duration %u Diff %u)", GetEntry(), GetUInt32Value(ITEM_FIELD_DURATION), diff);
275 
276  if (GetUInt32Value(ITEM_FIELD_DURATION) <= diff)
277  {
278  owner->DestroyItem(GetBagSlot(), GetSlot(), true);
279  return;
280  }
281 
283  SetState(ITEM_CHANGED, owner); // save new time in database
284 }
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:661
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
#define sLog
Log class singleton.
Definition: Log.h:187
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
void DestroyItem(uint8 bag, uint8 slot, bool update)
Definition: Player.cpp:10668
uint8 GetSlot() const
Definition: Item.h:266
uint32 GetEntry() const
Definition: Object.h:192
uint8 GetBagSlot() const
Definition: Item.cpp:728
void Item::UpdateItemSuffixFactor ( )

Definition at line 653 of file Item.cpp.

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

Referenced by LoadFromDB(), and SetItemRandomProperties().

654 {
655  uint32 suffixFactor = GenerateEnchSuffixFactor(GetEntry());
656  if (GetItemSuffixFactor() == suffixFactor)
657  return;
659 }
uint32 GetItemSuffixFactor() const
Definition: Item.h:302
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
uint32 GetEntry() const
Definition: Object.h:192
uint32 GenerateEnchSuffixFactor(uint32 item_id)
ACE_UINT32 uint32
Definition: Define.h:71

Member Data Documentation

Bag* Item::m_container
private

Definition at line 377 of file Item.h.

Referenced by GetBagSlot(), and Item().

uint8 Item::m_slot
private

Definition at line 376 of file Item.h.

Referenced by IsEquipped(), and Item().

bool Item::mb_in_trade
private

Definition at line 380 of file Item.h.

Referenced by Item().

int16 Item::uQueuePos
private

Definition at line 379 of file Item.h.

Referenced by AddToUpdateQueueOf(), Item(), RemoveFromUpdateQueueOf(), and SetState().

ItemUpdateState Item::uState
private

Definition at line 378 of file Item.h.

Referenced by Item(), SaveToDB(), and SetState().


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