mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-02 18:43:48 +00:00
fix(Core/Item): Random item properties generation (#2331)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user