[11702] Alsways attempt generate randomProperty for item in at create if value not pre-selected.

This resolve all existed cases when we miss assign random property id.

Also move random property/suffix check from item creating to server load time.
This commit is contained in:
VladimirMangos 2011-06-30 18:07:01 +04:00
parent 67f9c26d51
commit cc11366d6b
6 changed files with 64 additions and 61 deletions

View file

@ -661,13 +661,6 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
if ((!itemProto->RandomProperty) && (!itemProto->RandomSuffix)) if ((!itemProto->RandomProperty) && (!itemProto->RandomSuffix))
return 0; return 0;
// item can have not null only one from field values
if ((itemProto->RandomProperty) && (itemProto->RandomSuffix))
{
sLog.outErrorDb("Item template %u have RandomProperty==%u and RandomSuffix==%u, but must have one from field =0", itemProto->ItemId, itemProto->RandomProperty, itemProto->RandomSuffix);
return 0;
}
// Random Property case // Random Property case
if (itemProto->RandomProperty) if (itemProto->RandomProperty)
{ {
@ -1081,7 +1074,7 @@ void Item::SendTimeUpdate(Player* owner)
owner->GetSession()->SendPacket(&data); owner->GetSession()->SendPacket(&data);
} }
Item* Item::CreateItem( uint32 item, uint32 count, Player const* player ) Item* Item::CreateItem( uint32 item, uint32 count, Player const* player, uint32 randomPropertyId)
{ {
if (count < 1) if (count < 1)
return NULL; //don't create item at zero count return NULL; //don't create item at zero count
@ -1097,6 +1090,9 @@ Item* Item::CreateItem( uint32 item, uint32 count, Player const* player )
if (pItem->Create(sObjectMgr.GenerateItemLowGuid(), item, player)) if (pItem->Create(sObjectMgr.GenerateItemLowGuid(), item, player))
{ {
pItem->SetCount(count); pItem->SetCount(count);
if (uint32 randId = randomPropertyId ? randomPropertyId : Item::GenerateItemRandomPropertyId(item))
pItem->SetItemRandomProperties(randId);
return pItem; return pItem;
} }
else else
@ -1107,7 +1103,7 @@ Item* Item::CreateItem( uint32 item, uint32 count, Player const* player )
Item* Item::CloneItem(uint32 count, Player const* player) const Item* Item::CloneItem(uint32 count, Player const* player) const
{ {
Item* newItem = CreateItem(GetEntry(), count, player); Item* newItem = CreateItem(GetEntry(), count, player, GetItemRandomPropertyId());
if (!newItem) if (!newItem)
return NULL; return NULL;
@ -1115,7 +1111,6 @@ Item* Item::CloneItem(uint32 count, Player const* player) const
newItem->SetGuidValue(ITEM_FIELD_GIFTCREATOR, GetGuidValue(ITEM_FIELD_GIFTCREATOR)); newItem->SetGuidValue(ITEM_FIELD_GIFTCREATOR, GetGuidValue(ITEM_FIELD_GIFTCREATOR));
newItem->SetUInt32Value(ITEM_FIELD_FLAGS, GetUInt32Value(ITEM_FIELD_FLAGS)); newItem->SetUInt32Value(ITEM_FIELD_FLAGS, GetUInt32Value(ITEM_FIELD_FLAGS));
newItem->SetUInt32Value(ITEM_FIELD_DURATION, GetUInt32Value(ITEM_FIELD_DURATION)); newItem->SetUInt32Value(ITEM_FIELD_DURATION, GetUInt32Value(ITEM_FIELD_DURATION));
newItem->SetItemRandomProperties(GetItemRandomPropertyId());
return newItem; return newItem;
} }

View file

@ -273,7 +273,7 @@ bool ItemCanGoIntoBag(ItemPrototype const *proto, ItemPrototype const *pBagProto
class MANGOS_DLL_SPEC Item : public Object class MANGOS_DLL_SPEC Item : public Object
{ {
public: public:
static Item* CreateItem(uint32 item, uint32 count, Player const* player = NULL); static Item* CreateItem(uint32 item, uint32 count, Player const* player = NULL, uint32 randomPropertyId = 0);
Item* CloneItem( uint32 count, Player const* player = NULL ) const; Item* CloneItem( uint32 count, Player const* player = NULL ) const;
Item(); Item();

View file

@ -2164,6 +2164,14 @@ void ObjectMgr::LoadItemPrototypes()
const_cast<ItemPrototype*>(proto)->RandomSuffix = 0; const_cast<ItemPrototype*>(proto)->RandomSuffix = 0;
} }
// item can have not null only one from field values
if (proto->RandomProperty && proto->RandomSuffix)
{
sLog.outErrorDb("Item (Entry: %u) have RandomProperty==%u and RandomSuffix==%u, but must have one from field = 0",
proto->ItemId, proto->RandomProperty, proto->RandomSuffix);
const_cast<ItemPrototype*>(proto)->RandomSuffix = 0;
}
if (proto->ItemSet && !sItemSetStore.LookupEntry(proto->ItemSet)) if (proto->ItemSet && !sItemSetStore.LookupEntry(proto->ItemSet))
{ {
sLog.outErrorDb("Item (Entry: %u) have wrong ItemSet (%u)", i, proto->ItemSet); sLog.outErrorDb("Item (Entry: %u) have wrong ItemSet (%u)", i, proto->ItemSet);
@ -2182,7 +2190,7 @@ void ObjectMgr::LoadItemPrototypes()
for (uint32 j = 0; j < sizeof(proto->BagFamily) * 8; ++j) for (uint32 j = 0; j < sizeof(proto->BagFamily) * 8; ++j)
{ {
uint32 mask = 1 << j; uint32 mask = 1 << j;
if((proto->BagFamily & mask)==0) if (!(proto->BagFamily & mask))
continue; continue;
ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j+1); ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j+1);
@ -2229,13 +2237,15 @@ void ObjectMgr::LoadItemPrototypes()
{ {
if (proto->Quality > ITEM_QUALITY_EPIC || proto->Quality < ITEM_QUALITY_UNCOMMON) if (proto->Quality > ITEM_QUALITY_EPIC || proto->Quality < ITEM_QUALITY_UNCOMMON)
{ {
ERROR_DB_STRICT_LOG("Item (Entry: %u) has unexpected RequiredDisenchantSkill (%u) for non-disenchantable quality (%u), reset it.",i,proto->RequiredDisenchantSkill,proto->Quality); ERROR_DB_STRICT_LOG("Item (Entry: %u) has unexpected RequiredDisenchantSkill (%u) for non-disenchantable quality (%u), reset it.",
i, proto->RequiredDisenchantSkill, proto->Quality);
const_cast<ItemPrototype*>(proto)->RequiredDisenchantSkill = -1; const_cast<ItemPrototype*>(proto)->RequiredDisenchantSkill = -1;
} }
else if (proto->Class != ITEM_CLASS_WEAPON && proto->Class != ITEM_CLASS_ARMOR) else if (proto->Class != ITEM_CLASS_WEAPON && proto->Class != ITEM_CLASS_ARMOR)
{ {
// some wrong data in wdb for unused items // some wrong data in wdb for unused items
ERROR_DB_STRICT_LOG("Item (Entry: %u) has unexpected RequiredDisenchantSkill (%u) for non-disenchantable item class (%u), reset it.",i,proto->RequiredDisenchantSkill,proto->Class); ERROR_DB_STRICT_LOG("Item (Entry: %u) has unexpected RequiredDisenchantSkill (%u) for non-disenchantable item class (%u), reset it.",
i, proto->RequiredDisenchantSkill, proto->Class);
const_cast<ItemPrototype*>(proto)->RequiredDisenchantSkill = -1; const_cast<ItemPrototype*>(proto)->RequiredDisenchantSkill = -1;
} }
} }

View file

@ -11114,13 +11114,11 @@ Item* Player::StoreNewItem( ItemPosCountVec const& dest, uint32 item, bool updat
for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr)
count += itr->count; count += itr->count;
Item *pItem = Item::CreateItem( item, count, this ); Item *pItem = Item::CreateItem(item, count, this, randomPropertyId);
if (pItem) if (pItem)
{ {
ItemAddedQuestCheck( item, count ); ItemAddedQuestCheck( item, count );
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, item, count); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, item, count);
if(randomPropertyId)
pItem->SetItemRandomProperties(randomPropertyId);
pItem = StoreItem( dest, pItem, update ); pItem = StoreItem( dest, pItem, update );
} }
return pItem; return pItem;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11701" #define REVISION_NR "11702"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__