fix(Core/Item): Random item properties generation (#2331)

This commit is contained in:
Shard
2019-10-28 08:08:37 +01:00
committed by Stoabrogga
parent 58a0ae5762
commit 97c55c6152
8 changed files with 21 additions and 20 deletions

View File

@@ -1013,7 +1013,7 @@ void Item::SendTimeUpdate(Player* owner)
owner->GetSession()->SendPacket(&data);
}
Item* Item::CreateItem(uint32 item, uint32 count, Player const* player)
Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, bool clone, uint32 randomPropertyId)
{
if (count < 1)
return NULL; //don't create item at zero count
@@ -1030,6 +1030,11 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player)
if (pItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), item, player))
{
pItem->SetCount(count);
if (!clone)
pItem->SetItemRandomProperties(randomPropertyId ? randomPropertyId : Item::GenerateItemRandomPropertyId(item));
else
if (randomPropertyId)
pItem->SetItemRandomProperties(randomPropertyId);
return pItem;
}
else
@@ -1042,7 +1047,8 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player)
Item* Item::CloneItem(uint32 count, Player const* player) const
{
Item* newItem = CreateItem(GetEntry(), count, player);
// player CAN be NULL in which case we must not update random properties because that accesses player's item update queue
Item * newItem = CreateItem(GetEntry(), count, player, true, player ? GetItemRandomPropertyId() : 0);
if (!newItem)
return NULL;
@@ -1050,9 +1056,6 @@ Item* Item::CloneItem(uint32 count, Player const* player) const
newItem->SetUInt32Value(ITEM_FIELD_GIFTCREATOR, GetUInt32Value(ITEM_FIELD_GIFTCREATOR));
newItem->SetUInt32Value(ITEM_FIELD_FLAGS, GetUInt32Value(ITEM_FIELD_FLAGS) & ~(ITEM_FIELD_FLAG_REFUNDABLE | ITEM_FIELD_FLAG_BOP_TRADEABLE));
newItem->SetUInt32Value(ITEM_FIELD_DURATION, GetUInt32Value(ITEM_FIELD_DURATION));
// player CAN be NULL in which case we must not update random properties because that accesses player's item update queue
if (player)
newItem->SetItemRandomProperties(GetItemRandomPropertyId());
return newItem;
}