mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[7360] Use defines instead harcoded item prototype array sizes.
This commit is contained in:
parent
4994611582
commit
b9326100ea
9 changed files with 37 additions and 26 deletions
|
|
@ -263,7 +263,7 @@ bool Item::Create( uint32 guidlow, uint32 itemid, Player const* owner)
|
||||||
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
|
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
|
||||||
SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability);
|
SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability);
|
||||||
|
|
||||||
for(int i = 0; i < 5; ++i)
|
for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||||
SetSpellCharges(i,itemProto->Spells[i].SpellCharges);
|
SetSpellCharges(i,itemProto->Spells[i].SpellCharges);
|
||||||
|
|
||||||
SetUInt32Value(ITEM_FIELD_FLAGS, itemProto->Flags);
|
SetUInt32Value(ITEM_FIELD_FLAGS, itemProto->Flags);
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ enum EnchantmentSlot
|
||||||
|
|
||||||
#define MAX_VISIBLE_ITEM_OFFSET 18 // 18 fields per visible item (creator(2) + enchantments(13) + properties(1) + seed(1) + pad(1))
|
#define MAX_VISIBLE_ITEM_OFFSET 18 // 18 fields per visible item (creator(2) + enchantments(13) + properties(1) + seed(1) + pad(1))
|
||||||
|
|
||||||
#define MAX_GEM_SOCKETS 3 // (BONUS_ENCHANTMENT_SLOT-SOCK_ENCHANTMENT_SLOT)
|
#define MAX_GEM_SOCKETS MAX_ITEM_PROTO_SOCKETS// (BONUS_ENCHANTMENT_SLOT-SOCK_ENCHANTMENT_SLOT) and item proto size, equal value expected
|
||||||
|
|
||||||
enum EnchantmentOffset
|
enum EnchantmentOffset
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -355,7 +355,7 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data )
|
||||||
}
|
}
|
||||||
data << pProto->ScalingStatDistribution; // scaling stats distribution
|
data << pProto->ScalingStatDistribution; // scaling stats distribution
|
||||||
data << pProto->ScalingStatValue; // some kind of flags used to determine stat values column
|
data << pProto->ScalingStatValue; // some kind of flags used to determine stat values column
|
||||||
for(int i = 0; i < 5; ++i)
|
for(int i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
|
||||||
{
|
{
|
||||||
data << pProto->Damage[i].DamageMin;
|
data << pProto->Damage[i].DamageMin;
|
||||||
data << pProto->Damage[i].DamageMax;
|
data << pProto->Damage[i].DamageMax;
|
||||||
|
|
@ -375,7 +375,7 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data )
|
||||||
data << pProto->AmmoType;
|
data << pProto->AmmoType;
|
||||||
data << pProto->RangedModRange;
|
data << pProto->RangedModRange;
|
||||||
|
|
||||||
for(int s = 0; s < 5; s++)
|
for(int s = 0; s < MAX_ITEM_PROTO_SPELLS; ++s)
|
||||||
{
|
{
|
||||||
// send DBC data for cooldowns in same way as it used in Spell::SendSpellCooldown
|
// send DBC data for cooldowns in same way as it used in Spell::SendSpellCooldown
|
||||||
// use `item_template` or if not set then only use spell cooldowns
|
// use `item_template` or if not set then only use spell cooldowns
|
||||||
|
|
@ -429,7 +429,7 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data )
|
||||||
data << pProto->Map; // Added in 1.12.x & 2.0.1 client branch
|
data << pProto->Map; // Added in 1.12.x & 2.0.1 client branch
|
||||||
data << pProto->BagFamily;
|
data << pProto->BagFamily;
|
||||||
data << pProto->TotemCategory;
|
data << pProto->TotemCategory;
|
||||||
for(int s = 0; s < 3; s++)
|
for(int s = 0; s < MAX_ITEM_PROTO_SOCKETS; ++s)
|
||||||
{
|
{
|
||||||
data << pProto->Socket[s].Color;
|
data << pProto->Socket[s].Color;
|
||||||
data << pProto->Socket[s].Content;
|
data << pProto->Socket[s].Content;
|
||||||
|
|
|
||||||
|
|
@ -491,6 +491,11 @@ struct _Socket
|
||||||
uint32 Content;
|
uint32 Content;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define MAX_ITEM_PROTO_DAMAGES 5
|
||||||
|
#define MAX_ITEM_PROTO_SOCKETS 3
|
||||||
|
#define MAX_ITEM_PROTO_SPELLS 5
|
||||||
|
#define MAX_ITEM_PROTO_STATS 10
|
||||||
|
|
||||||
struct ItemPrototype
|
struct ItemPrototype
|
||||||
{
|
{
|
||||||
uint32 ItemId;
|
uint32 ItemId;
|
||||||
|
|
@ -520,10 +525,10 @@ struct ItemPrototype
|
||||||
int32 Stackable; // 0: not allowed, -1: put in player coin info tab and don't limit stacking (so 1 slot)
|
int32 Stackable; // 0: not allowed, -1: put in player coin info tab and don't limit stacking (so 1 slot)
|
||||||
uint32 ContainerSlots;
|
uint32 ContainerSlots;
|
||||||
uint32 StatsCount;
|
uint32 StatsCount;
|
||||||
_ItemStat ItemStat[10];
|
_ItemStat ItemStat[MAX_ITEM_PROTO_STATS];
|
||||||
uint32 ScalingStatDistribution; // id from ScalingStatDistribution.dbc
|
uint32 ScalingStatDistribution; // id from ScalingStatDistribution.dbc
|
||||||
uint32 ScalingStatValue; // mask for selecting column in ScalingStatValues.dbc
|
uint32 ScalingStatValue; // mask for selecting column in ScalingStatValues.dbc
|
||||||
_Damage Damage[5];
|
_Damage Damage[MAX_ITEM_PROTO_DAMAGES];
|
||||||
uint32 Armor;
|
uint32 Armor;
|
||||||
uint32 HolyRes;
|
uint32 HolyRes;
|
||||||
uint32 FireRes;
|
uint32 FireRes;
|
||||||
|
|
@ -534,7 +539,7 @@ struct ItemPrototype
|
||||||
uint32 Delay;
|
uint32 Delay;
|
||||||
uint32 AmmoType;
|
uint32 AmmoType;
|
||||||
float RangedModRange;
|
float RangedModRange;
|
||||||
_Spell Spells[5];
|
_Spell Spells[MAX_ITEM_PROTO_SPELLS];
|
||||||
uint32 Bonding;
|
uint32 Bonding;
|
||||||
char* Description;
|
char* Description;
|
||||||
uint32 PageText;
|
uint32 PageText;
|
||||||
|
|
@ -553,7 +558,7 @@ struct ItemPrototype
|
||||||
uint32 Map; // id from Map.dbc
|
uint32 Map; // id from Map.dbc
|
||||||
uint32 BagFamily; // id from ItemBagFamily.dbc
|
uint32 BagFamily; // id from ItemBagFamily.dbc
|
||||||
uint32 TotemCategory; // id from TotemCategory.dbc
|
uint32 TotemCategory; // id from TotemCategory.dbc
|
||||||
_Socket Socket[3];
|
_Socket Socket[MAX_ITEM_PROTO_SOCKETS];
|
||||||
uint32 socketBonus; // id from SpellItemEnchantment.dbc
|
uint32 socketBonus; // id from SpellItemEnchantment.dbc
|
||||||
uint32 GemProperties; // id from GemProperties.dbc
|
uint32 GemProperties; // id from GemProperties.dbc
|
||||||
uint32 RequiredDisenchantSkill;
|
uint32 RequiredDisenchantSkill;
|
||||||
|
|
@ -634,7 +639,7 @@ struct ItemPrototype
|
||||||
if (Delay == 0)
|
if (Delay == 0)
|
||||||
return 0;
|
return 0;
|
||||||
float temp = 0;
|
float temp = 0;
|
||||||
for (int i=0;i<5;++i)
|
for (int i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
|
||||||
temp+=Damage[i].DamageMin + Damage[i].DamageMax;
|
temp+=Damage[i].DamageMin + Damage[i].DamageMax;
|
||||||
return temp*500/Delay;
|
return temp*500/Delay;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1477,7 +1477,7 @@ void ObjectMgr::LoadItemPrototypes()
|
||||||
bool req = proto->InventoryType!=INVTYPE_NON_EQUIP || proto->PageText;
|
bool req = proto->InventoryType!=INVTYPE_NON_EQUIP || proto->PageText;
|
||||||
if(!req)
|
if(!req)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 5; ++j)
|
for (int j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
|
||||||
{
|
{
|
||||||
if(proto->Spells[j].SpellId)
|
if(proto->Spells[j].SpellId)
|
||||||
{
|
{
|
||||||
|
|
@ -1542,7 +1542,13 @@ void ObjectMgr::LoadItemPrototypes()
|
||||||
const_cast<ItemPrototype*>(proto)->Stackable = 255;
|
const_cast<ItemPrototype*>(proto)->Stackable = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < 10; j++)
|
if(proto->StatsCount > MAX_ITEM_PROTO_STATS)
|
||||||
|
{
|
||||||
|
sLog.outErrorDb("Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).",i,proto->StatsCount,MAX_ITEM_PROTO_STATS);
|
||||||
|
const_cast<ItemPrototype*>(proto)->StatsCount = MAX_ITEM_PROTO_STATS;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < MAX_ITEM_PROTO_STATS; ++j)
|
||||||
{
|
{
|
||||||
// for ItemStatValue != 0
|
// for ItemStatValue != 0
|
||||||
if(proto->ItemStat[j].ItemStatValue && proto->ItemStat[j].ItemStatType >= MAX_ITEM_MOD)
|
if(proto->ItemStat[j].ItemStatValue && proto->ItemStat[j].ItemStatType >= MAX_ITEM_MOD)
|
||||||
|
|
@ -1552,7 +1558,7 @@ void ObjectMgr::LoadItemPrototypes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < 5; j++)
|
for (int j = 0; j < MAX_ITEM_PROTO_DAMAGES; ++j)
|
||||||
{
|
{
|
||||||
if(proto->Damage[j].DamageType >= MAX_SPELL_SCHOOL)
|
if(proto->Damage[j].DamageType >= MAX_SPELL_SCHOOL)
|
||||||
{
|
{
|
||||||
|
|
@ -1609,7 +1615,7 @@ void ObjectMgr::LoadItemPrototypes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// spell_3*,spell_4*,spell_5* is empty
|
// spell_3*,spell_4*,spell_5* is empty
|
||||||
for (int j = 2; j < 5; j++)
|
for (int j = 2; j < MAX_ITEM_PROTO_SPELLS; ++j)
|
||||||
{
|
{
|
||||||
if(proto->Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
|
if(proto->Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
|
||||||
{
|
{
|
||||||
|
|
@ -1627,7 +1633,7 @@ void ObjectMgr::LoadItemPrototypes()
|
||||||
// normal spell list
|
// normal spell list
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 5; j++)
|
for (int j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
|
||||||
{
|
{
|
||||||
if(proto->Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || proto->Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
|
if(proto->Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || proto->Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
|
||||||
{
|
{
|
||||||
|
|
@ -1696,7 +1702,7 @@ void ObjectMgr::LoadItemPrototypes()
|
||||||
if(proto->TotemCategory && !sTotemCategoryStore.LookupEntry(proto->TotemCategory))
|
if(proto->TotemCategory && !sTotemCategoryStore.LookupEntry(proto->TotemCategory))
|
||||||
sLog.outErrorDb("Item (Entry: %u) has wrong TotemCategory (%u)",i,proto->TotemCategory);
|
sLog.outErrorDb("Item (Entry: %u) has wrong TotemCategory (%u)",i,proto->TotemCategory);
|
||||||
|
|
||||||
for (int j = 0; j < 3; j++)
|
for (int j = 0; j < MAX_ITEM_PROTO_SOCKETS; j++)
|
||||||
{
|
{
|
||||||
if(proto->Socket[j].Color && (proto->Socket[j].Color & SOCKET_COLOR_ALL) != proto->Socket[j].Color)
|
if(proto->Socket[j].Color && (proto->Socket[j].Color & SOCKET_COLOR_ALL) != proto->Socket[j].Color)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6580,7 +6580,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl
|
||||||
if(slot >= INVENTORY_SLOT_BAG_END || !proto)
|
if(slot >= INVENTORY_SLOT_BAG_END || !proto)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < MAX_ITEM_PROTO_STATS; ++i)
|
||||||
{
|
{
|
||||||
uint32 statType = 0;
|
uint32 statType = 0;
|
||||||
int32 val = 0;
|
int32 val = 0;
|
||||||
|
|
@ -6913,7 +6913,7 @@ void Player::ApplyItemEquipSpell(Item *item, bool apply, bool form_change)
|
||||||
if(!proto)
|
if(!proto)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||||
{
|
{
|
||||||
_Spell const& spellData = proto->Spells[i];
|
_Spell const& spellData = proto->Spells[i];
|
||||||
|
|
||||||
|
|
@ -7026,7 +7026,7 @@ void Player::CastItemCombatSpell(Item *item,Unit* Target, WeaponAttackType attTy
|
||||||
if (!Target || Target == this )
|
if (!Target || Target == this )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||||
{
|
{
|
||||||
_Spell const& spellData = proto->Spells[i];
|
_Spell const& spellData = proto->Spells[i];
|
||||||
|
|
||||||
|
|
@ -7124,7 +7124,7 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
// item spells casted at use
|
// item spells casted at use
|
||||||
for(int i = 0; i < 5; ++i)
|
for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||||
{
|
{
|
||||||
_Spell const& spellData = proto->Spells[i];
|
_Spell const& spellData = proto->Spells[i];
|
||||||
|
|
||||||
|
|
@ -18241,7 +18241,7 @@ void Player::SendInstanceResetWarning(uint32 mapid, uint32 time)
|
||||||
|
|
||||||
void Player::ApplyEquipCooldown( Item * pItem )
|
void Player::ApplyEquipCooldown( Item * pItem )
|
||||||
{
|
{
|
||||||
for(int i = 0; i <5; ++i)
|
for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||||
{
|
{
|
||||||
_Spell const& spellData = pItem->GetProto()->Spells[i];
|
_Spell const& spellData = pItem->GetProto()->Spells[i];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi
|
||||||
if((m_caster->getClassMask() & CLASSMASK_WAND_USERS) != 0 && m_caster->GetTypeId()==TYPEID_PLAYER)
|
if((m_caster->getClassMask() & CLASSMASK_WAND_USERS) != 0 && m_caster->GetTypeId()==TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
if(Item* pItem = ((Player*)m_caster)->GetWeaponForAttack(RANGED_ATTACK))
|
if(Item* pItem = ((Player*)m_caster)->GetWeaponForAttack(RANGED_ATTACK))
|
||||||
m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetProto()->Damage->DamageType);
|
m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetProto()->Damage[0].DamageType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set health leech amount to zero
|
// Set health leech amount to zero
|
||||||
|
|
@ -2542,7 +2542,7 @@ void Spell::SendSpellCooldown()
|
||||||
ItemPrototype const* proto = m_CastItem->GetProto();
|
ItemPrototype const* proto = m_CastItem->GetProto();
|
||||||
if(proto)
|
if(proto)
|
||||||
{
|
{
|
||||||
for(int idx = 0; idx < 5; ++idx)
|
for(int idx = 0; idx < MAX_ITEM_PROTO_SPELLS; ++idx)
|
||||||
{
|
{
|
||||||
if(proto->Spells[idx].SpellId == m_spellInfo->Id)
|
if(proto->Spells[idx].SpellId == m_spellInfo->Id)
|
||||||
{
|
{
|
||||||
|
|
@ -3325,7 +3325,7 @@ void Spell::TakeCastItem()
|
||||||
bool expendable = false;
|
bool expendable = false;
|
||||||
bool withoutCharges = false;
|
bool withoutCharges = false;
|
||||||
|
|
||||||
for (int i = 0; i<5; i++)
|
for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||||
{
|
{
|
||||||
if (proto->Spells[i].SpellId)
|
if (proto->Spells[i].SpellId)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
|
||||||
|
|
||||||
if (pUser->isInCombat())
|
if (pUser->isInCombat())
|
||||||
{
|
{
|
||||||
for(int i = 0; i < 5; ++i)
|
for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||||
{
|
{
|
||||||
if (SpellEntry const *spellInfo = sSpellStore.LookupEntry(proto->Spells[i].SpellId))
|
if (SpellEntry const *spellInfo = sSpellStore.LookupEntry(proto->Spells[i].SpellId))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7359"
|
#define REVISION_NR "7360"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue