diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Item.cpp | 2 | ||||
-rw-r--r-- | src/game/Item.h | 2 | ||||
-rw-r--r-- | src/game/ItemHandler.cpp | 6 | ||||
-rw-r--r-- | src/game/ItemPrototype.h | 15 | ||||
-rw-r--r-- | src/game/ObjectMgr.cpp | 18 | ||||
-rw-r--r-- | src/game/Player.cpp | 10 | ||||
-rw-r--r-- | src/game/Spell.cpp | 6 | ||||
-rw-r--r-- | src/game/SpellHandler.cpp | 2 | ||||
-rw-r--r-- | src/shared/revision_nr.h | 2 |
9 files changed, 37 insertions, 26 deletions
diff --git a/src/game/Item.cpp b/src/game/Item.cpp index ea8d77076eb..8454604a786 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -265,7 +265,7 @@ bool Item::Create( uint32 guidlow, uint32 itemid, Player const* owner) SetUInt32Value(ITEM_FIELD_MAXDURABILITY, 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); SetUInt32Value(ITEM_FIELD_FLAGS, itemProto->Flags); diff --git a/src/game/Item.h b/src/game/Item.h index 8e4fc410531..f30fb8dd461 100644 --- a/src/game/Item.h +++ b/src/game/Item.h @@ -167,7 +167,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_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 { diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index a845ce29b50..cde9eb74443 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -357,7 +357,7 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data ) } data << pProto->ScalingStatDistribution; // scaling stats distribution 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].DamageMax; @@ -377,7 +377,7 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data ) data << pProto->AmmoType; 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 // use `item_template` or if not set then only use spell cooldowns @@ -431,7 +431,7 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data ) data << pProto->Map; // Added in 1.12.x & 2.0.1 client branch data << pProto->BagFamily; 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].Content; diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h index 1087154c5e7..d7e923a2b77 100644 --- a/src/game/ItemPrototype.h +++ b/src/game/ItemPrototype.h @@ -493,6 +493,11 @@ struct _Socket 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 { uint32 ItemId; @@ -522,10 +527,10 @@ struct ItemPrototype int32 Stackable; // 0: not allowed, -1: put in player coin info tab and don't limit stacking (so 1 slot) uint32 ContainerSlots; uint32 StatsCount; - _ItemStat ItemStat[10]; + _ItemStat ItemStat[MAX_ITEM_PROTO_STATS]; uint32 ScalingStatDistribution; // id from ScalingStatDistribution.dbc uint32 ScalingStatValue; // mask for selecting column in ScalingStatValues.dbc - _Damage Damage[5]; + _Damage Damage[MAX_ITEM_PROTO_DAMAGES]; uint32 Armor; uint32 HolyRes; uint32 FireRes; @@ -536,7 +541,7 @@ struct ItemPrototype uint32 Delay; uint32 AmmoType; float RangedModRange; - _Spell Spells[5]; + _Spell Spells[MAX_ITEM_PROTO_SPELLS]; uint32 Bonding; char* Description; uint32 PageText; @@ -555,7 +560,7 @@ struct ItemPrototype uint32 Map; // id from Map.dbc uint32 BagFamily; // id from ItemBagFamily.dbc uint32 TotemCategory; // id from TotemCategory.dbc - _Socket Socket[3]; + _Socket Socket[MAX_ITEM_PROTO_SOCKETS]; uint32 socketBonus; // id from SpellItemEnchantment.dbc uint32 GemProperties; // id from GemProperties.dbc uint32 RequiredDisenchantSkill; @@ -636,7 +641,7 @@ struct ItemPrototype if (Delay == 0) return 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; return temp*500/Delay; } diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 14de27c69a8..dd68c703b9d 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1572,7 +1572,7 @@ void ObjectMgr::LoadItemPrototypes() bool req = proto->InventoryType!=INVTYPE_NON_EQUIP || proto->PageText; if(!req) { - for (int j = 0; j < 5; ++j) + for (int j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j) { if(proto->Spells[j].SpellId) { @@ -1637,7 +1637,13 @@ void ObjectMgr::LoadItemPrototypes() 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 if(proto->ItemStat[j].ItemStatValue && proto->ItemStat[j].ItemStatType >= MAX_ITEM_MOD) @@ -1647,7 +1653,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) { @@ -1704,7 +1710,7 @@ void ObjectMgr::LoadItemPrototypes() } // 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) { @@ -1722,7 +1728,7 @@ void ObjectMgr::LoadItemPrototypes() // normal spell list 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) { @@ -1791,7 +1797,7 @@ void ObjectMgr::LoadItemPrototypes() if(proto->TotemCategory && !sTotemCategoryStore.LookupEntry(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) { diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 850cdfdc0a9..d34f31e0489 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -6752,7 +6752,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl if(slot >= INVENTORY_SLOT_BAG_END || !proto) return; - for (int i = 0; i < 10; i++) + for (int i = 0; i < MAX_ITEM_PROTO_STATS; ++i) { uint32 statType = 0; int32 val = 0; @@ -7085,7 +7085,7 @@ void Player::ApplyItemEquipSpell(Item *item, bool apply, bool form_change) if(!proto) return; - for (int i = 0; i < 5; i++) + for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { _Spell const& spellData = proto->Spells[i]; @@ -7198,7 +7198,7 @@ void Player::CastItemCombatSpell(Item *item,Unit* Target, WeaponAttackType attTy if (!Target || Target == this ) return; - for (int i = 0; i < 5; i++) + for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { _Spell const& spellData = proto->Spells[i]; @@ -7296,7 +7296,7 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c int count = 0; // 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]; @@ -18797,7 +18797,7 @@ void Player::SendInstanceResetWarning(uint32 mapid, uint32 time) 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]; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index e4d57801161..1f77d5df611 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -337,7 +337,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(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 @@ -2454,7 +2454,7 @@ void Spell::SendSpellCooldown() ItemPrototype const* proto = m_CastItem->GetProto(); 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) { @@ -3201,7 +3201,7 @@ void Spell::TakeCastItem() bool expendable = 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) { diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 3c739a85bb0..449025f0346 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -97,7 +97,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) 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)) { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 3f3a2957e35..057f92297e7 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7359" + #define REVISION_NR "7360" #endif // __REVISION_NR_H__ |