TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
WorldPackets::Item::ItemInstance Struct Reference

#include <ItemPackets.h>

Public Member Functions

void Initialize (::Item const *item)
 
void Initialize (::LootItem const &lootItem)
 
void Initialize (::VoidStorageItem const *voidItem)
 
bool operator== (ItemInstance const &r) const
 
bool operator!= (ItemInstance const &r) const
 

Public Attributes

uint32 ItemID = 0
 
uint32 RandomPropertiesSeed = 0
 
uint32 RandomPropertiesID = 0
 
Optional< ItemBonusInstanceDataItemBonus
 
Optional< CompactArray< int32 > > Modifications
 

Member Function Documentation

void WorldPackets::Item::ItemInstance::Initialize ( ::Item const item)
249 {
250  ItemID = item->GetEntry();
251  RandomPropertiesSeed = item->GetItemSuffixFactor();
252  RandomPropertiesID = item->GetItemRandomPropertyId();
253  std::vector<uint32> const& bonusListIds = item->GetDynamicValues(ITEM_DYNAMIC_FIELD_BONUSLIST_IDS);
254  if (!bonusListIds.empty())
255  {
256  ItemBonus = boost::in_place();
257  ItemBonus->BonusListIDs.insert(ItemBonus->BonusListIDs.end(), bonusListIds.begin(), bonusListIds.end());
258  ItemBonus->Context = item->GetUInt32Value(ITEM_FIELD_CONTEXT);
259  }
260 
261  if (uint32 mask = item->GetUInt32Value(ITEM_FIELD_MODIFIERS_MASK))
262  {
263  Modifications = boost::in_place();
264 
265  for (size_t i = 0; mask != 0; mask >>= 1, ++i)
266  if ((mask & 1) != 0)
267  Modifications->Insert(i, item->GetModifier(ItemModifier(i)));
268  }
269 }
Optional< CompactArray< int32 > > Modifications
Definition: ItemPackets.h:50
Definition: UpdateFields.h:57
ItemModifier
Definition: Item.h:222
uint32 RandomPropertiesSeed
Definition: ItemPackets.h:47
uint32 RandomPropertiesID
Definition: ItemPackets.h:48
Optional< ItemBonusInstanceData > ItemBonus
Definition: ItemPackets.h:49
Definition: UpdateFields.h:64
uint32_t uint32
Definition: Define.h:150
uint32 ItemID
Definition: ItemPackets.h:46
Definition: UpdateFields.h:56

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldPackets::Item::ItemInstance::Initialize ( ::LootItem const lootItem)
Todo:

no Modifications

272 {
273  ItemID = lootItem.itemid;
274  RandomPropertiesSeed = lootItem.randomSuffix;
275  RandomPropertiesID = lootItem.randomPropertyId;
276  if (!lootItem.BonusListIDs.empty())
277  {
278  ItemBonus = boost::in_place();
279  ItemBonus->BonusListIDs = lootItem.BonusListIDs;
280  ItemBonus->Context = 0;
281  }
282 
284 }
uint32 RandomPropertiesSeed
Definition: ItemPackets.h:47
uint32 RandomPropertiesID
Definition: ItemPackets.h:48
Optional< ItemBonusInstanceData > ItemBonus
Definition: ItemPackets.h:49
uint32 ItemID
Definition: ItemPackets.h:46
void WorldPackets::Item::ItemInstance::Initialize ( ::VoidStorageItem const voidItem)
287 {
288  ItemID = voidItem->ItemEntry;
289  RandomPropertiesID = voidItem->ItemRandomPropertyId;
290  RandomPropertiesSeed = voidItem->ItemSuffixFactor;
291  if (voidItem->ItemUpgradeId)
292  {
293  Modifications = boost::in_place();
294  Modifications->Insert(ITEM_MODIFIER_UPGRADE_ID, voidItem->ItemUpgradeId);
295  }
296 
297  if (!voidItem->BonusListIDs.empty())
298  {
299  ItemBonus = boost::in_place();
300  ItemBonus->BonusListIDs = voidItem->BonusListIDs;
301  }
302 }
Optional< CompactArray< int32 > > Modifications
Definition: ItemPackets.h:50
uint32 RandomPropertiesSeed
Definition: ItemPackets.h:47
uint32 RandomPropertiesID
Definition: ItemPackets.h:48
Optional< ItemBonusInstanceData > ItemBonus
Definition: ItemPackets.h:49
Definition: Item.h:226
uint32 ItemID
Definition: ItemPackets.h:46
bool WorldPackets::Item::ItemInstance::operator!= ( ItemInstance const r) const
inline
53 { return !(*this == r); }
bool WorldPackets::Item::ItemInstance::operator== ( ItemInstance const r) const
305 {
306  if (ItemID != r.ItemID || RandomPropertiesID != r.RandomPropertiesID || RandomPropertiesSeed != r.RandomPropertiesSeed)
307  return false;
308 
309  if (ItemBonus.is_initialized() != r.ItemBonus.is_initialized() || Modifications.is_initialized() != r.Modifications.is_initialized())
310  return false;
311 
312  if (Modifications.is_initialized() && *Modifications != *r.Modifications)
313  return false;
314 
315  if (ItemBonus.is_initialized() && *ItemBonus != *r.ItemBonus)
316  return false;
317 
318  return true;
319 }
Optional< CompactArray< int32 > > Modifications
Definition: ItemPackets.h:50
uint32 RandomPropertiesSeed
Definition: ItemPackets.h:47
uint32 RandomPropertiesID
Definition: ItemPackets.h:48
Optional< ItemBonusInstanceData > ItemBonus
Definition: ItemPackets.h:49
uint32 ItemID
Definition: ItemPackets.h:46

Member Data Documentation

Optional<ItemBonusInstanceData> WorldPackets::Item::ItemInstance::ItemBonus
uint32 WorldPackets::Item::ItemInstance::ItemID = 0
Optional<CompactArray<int32> > WorldPackets::Item::ItemInstance::Modifications
uint32 WorldPackets::Item::ItemInstance::RandomPropertiesID = 0
uint32 WorldPackets::Item::ItemInstance::RandomPropertiesSeed = 0

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