diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index fc05c3eee..65c2ad61c 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1397,7 +1397,7 @@ SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim) } bool bcontinue = true; - for(uint32 j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { if( (spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE ) || (spellInfo->Effect[j] == SPELL_EFFECT_INSTAKILL) || @@ -1449,7 +1449,7 @@ SpellEntry const *Creature::reachWithSpellCure(Unit *pVictim) } bool bcontinue = true; - for(uint32 j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { if( (spellInfo->Effect[j] == SPELL_EFFECT_HEAL ) ) { diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 44d1f1401..a2fb1b917 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -457,7 +457,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 // If cast flag CAST_AURA_NOT_PRESENT is active, check if target already has aura on them if(action.cast.castFlags & CAST_AURA_NOT_PRESENT) { - for(uint8 i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) if(target->HasAura(action.cast.spellId, i)) return; } diff --git a/src/game/DBCEnums.h b/src/game/DBCEnums.h index 541c764ec..ed1af0d7f 100644 --- a/src/game/DBCEnums.h +++ b/src/game/DBCEnums.h @@ -384,9 +384,11 @@ enum SummonPropFlags enum SpellEffectIndex { - EFFECT_INDEX_0 = 0, - EFFECT_INDEX_1 = 1, - EFFECT_INDEX_2 = 2 + EFFECT_INDEX_0 = 0, + EFFECT_INDEX_1 = 1, + EFFECT_INDEX_2 = 2 }; +#define MAX_EFFECT_INDEX 3 + #endif diff --git a/src/game/DBCStores.cpp b/src/game/DBCStores.cpp index 0b9e71997..fc9951d82 100644 --- a/src/game/DBCStores.cpp +++ b/src/game/DBCStores.cpp @@ -557,7 +557,7 @@ void LoadDBCStores(const std::string& dataPath) std::set spellPaths; for(uint32 i = 1; i < sSpellStore.GetNumRows (); ++i) if(SpellEntry const* sInfo = sSpellStore.LookupEntry (i)) - for(int j=0; j < 3; ++j) + for(int j=0; j < MAX_EFFECT_INDEX; ++j) if(sInfo->Effect[j]==123 /*SPELL_EFFECT_SEND_TAXI*/) spellPaths.insert(sInfo->EffectMiscValue[j]); diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index 4479f7d12..0ee21ac74 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -1394,28 +1394,28 @@ struct SpellEntry int32 EquippedItemClass; // 68 m_equippedItemClass (value) int32 EquippedItemSubClassMask; // 69 m_equippedItemSubclass (mask) int32 EquippedItemInventoryTypeMask; // 70 m_equippedItemInvTypes (mask) - uint32 Effect[3]; // 71-73 m_effect - int32 EffectDieSides[3]; // 74-76 m_effectDieSides - uint32 EffectBaseDice[3]; // 77-79 m_effectBaseDice - float EffectDicePerLevel[3]; // 80-82 m_effectDicePerLevel - float EffectRealPointsPerLevel[3]; // 83-85 m_effectRealPointsPerLevel - int32 EffectBasePoints[3]; // 86-88 m_effectBasePoints (don't must be used in spell/auras explicitly, must be used cached Spell::m_currentBasePoints) - uint32 EffectMechanic[3]; // 89-91 m_effectMechanic - uint32 EffectImplicitTargetA[3]; // 92-94 m_implicitTargetA - uint32 EffectImplicitTargetB[3]; // 95-97 m_implicitTargetB - uint32 EffectRadiusIndex[3]; // 98-100 m_effectRadiusIndex - spellradius.dbc - uint32 EffectApplyAuraName[3]; // 101-103 m_effectAura - uint32 EffectAmplitude[3]; // 104-106 m_effectAuraPeriod - float EffectMultipleValue[3]; // 107-109 m_effectAmplitude - uint32 EffectChainTarget[3]; // 110-112 m_effectChainTargets - uint32 EffectItemType[3]; // 113-115 m_effectItemType - int32 EffectMiscValue[3]; // 116-118 m_effectMiscValue - int32 EffectMiscValueB[3]; // 119-121 m_effectMiscValueB - uint32 EffectTriggerSpell[3]; // 122-124 m_effectTriggerSpell - float EffectPointsPerComboPoint[3]; // 125-127 m_effectPointsPerCombo - uint32 EffectSpellClassMaskA[3]; // 128-130 m_effectSpellClassMaskA - uint32 EffectSpellClassMaskB[3]; // 131-133 m_effectSpellClassMaskB - uint32 EffectSpellClassMaskC[3]; // 134-136 m_effectSpellClassMaskC + uint32 Effect[MAX_EFFECT_INDEX]; // 71-73 m_effect + int32 EffectDieSides[MAX_EFFECT_INDEX]; // 74-76 m_effectDieSides + uint32 EffectBaseDice[MAX_EFFECT_INDEX]; // 77-79 m_effectBaseDice + float EffectDicePerLevel[MAX_EFFECT_INDEX]; // 80-82 m_effectDicePerLevel + float EffectRealPointsPerLevel[MAX_EFFECT_INDEX]; // 83-85 m_effectRealPointsPerLevel + int32 EffectBasePoints[MAX_EFFECT_INDEX]; // 86-88 m_effectBasePoints (don't must be used in spell/auras explicitly, must be used cached Spell::m_currentBasePoints) + uint32 EffectMechanic[MAX_EFFECT_INDEX]; // 89-91 m_effectMechanic + uint32 EffectImplicitTargetA[MAX_EFFECT_INDEX]; // 92-94 m_implicitTargetA + uint32 EffectImplicitTargetB[MAX_EFFECT_INDEX]; // 95-97 m_implicitTargetB + uint32 EffectRadiusIndex[MAX_EFFECT_INDEX]; // 98-100 m_effectRadiusIndex - spellradius.dbc + uint32 EffectApplyAuraName[MAX_EFFECT_INDEX]; // 101-103 m_effectAura + uint32 EffectAmplitude[MAX_EFFECT_INDEX]; // 104-106 m_effectAuraPeriod + float EffectMultipleValue[MAX_EFFECT_INDEX]; // 107-109 m_effectAmplitude + uint32 EffectChainTarget[MAX_EFFECT_INDEX]; // 110-112 m_effectChainTargets + uint32 EffectItemType[MAX_EFFECT_INDEX]; // 113-115 m_effectItemType + int32 EffectMiscValue[MAX_EFFECT_INDEX]; // 116-118 m_effectMiscValue + int32 EffectMiscValueB[MAX_EFFECT_INDEX]; // 119-121 m_effectMiscValueB + uint32 EffectTriggerSpell[MAX_EFFECT_INDEX]; // 122-124 m_effectTriggerSpell + float EffectPointsPerComboPoint[MAX_EFFECT_INDEX]; // 125-127 m_effectPointsPerCombo + uint32 EffectSpellClassMaskA[3]; // 128-130 m_effectSpellClassMaskA, effect 0 + uint32 EffectSpellClassMaskB[3]; // 131-133 m_effectSpellClassMaskB, effect 1 + uint32 EffectSpellClassMaskC[3]; // 134-136 m_effectSpellClassMaskC, effect 2 uint32 SpellVisual[2]; // 137-138 m_spellVisualID uint32 SpellIconID; // 139 m_spellIconID uint32 activeIconID; // 140 m_activeIconID @@ -1439,7 +1439,7 @@ struct SpellEntry uint32 DmgClass; // 219 m_defenseType uint32 PreventionType; // 220 m_preventionType //uint32 StanceBarOrder; // 221 m_stanceBarOrder not used - float DmgMultiplier[3]; // 222-224 m_effectChainAmplitude + float DmgMultiplier[MAX_EFFECT_INDEX]; // 222-224 m_effectChainAmplitude //uint32 MinFactionId; // 225 m_minFactionID not used //uint32 MinReputation; // 226 m_minReputation not used //uint32 RequiredAuraVision; // 227 m_requiredAuraVision not used diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index fb703f82d..38e6582cf 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -3594,7 +3594,7 @@ bool ChatHandler::HandleAuraCommand(const char* args) SpellEntry const *spellInfo = sSpellStore.LookupEntry( spellID ); if(spellInfo) { - for(uint32 i = 0;i<3;++i) + for(uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) { uint8 eff = spellInfo->Effect[i]; if (eff>=TOTAL_SPELL_EFFECTS) diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 23708fdac..03bb370c8 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -792,7 +792,7 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* CreatureDataAddonAura& cAura = const_cast(addon->auras[i]); cAura.spell_id = (uint32)val[2*j+0]; cAura.effect_idx = (uint32)val[2*j+1]; - if ( cAura.effect_idx > 2 ) + if (cAura.effect_idx >= MAX_EFFECT_INDEX) { sLog.outErrorDb("Creature (%s: %u) has wrong effect %u for spell %u in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.effect_idx,cAura.spell_id,table); continue; @@ -816,7 +816,7 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* // fill terminator element (after last added) CreatureDataAddonAura& endAura = const_cast(addon->auras[i]); endAura.spell_id = 0; - endAura.effect_idx = 0; + endAura.effect_idx = EFFECT_INDEX_0; } void ObjectMgr::LoadCreatureAddons(SQLStorage& creatureaddons, char const* entryName, char const* comment) @@ -2138,7 +2138,7 @@ void ObjectMgr::LoadItemRequiredTarget() if (bounds.first != bounds.second) break; - for (int j = 0; j < 3; ++j) + for (int j = 0; j < MAX_EFFECT_INDEX; ++j) { if (pSpellInfo->EffectImplicitTargetA[j] == TARGET_CHAIN_DAMAGE || pSpellInfo->EffectImplicitTargetB[j] == TARGET_CHAIN_DAMAGE || @@ -3648,7 +3648,7 @@ void ObjectMgr::LoadQuests() if(!qinfo->ReqCreatureOrGOId[j]) { bool found = false; - for(int k = 0; k < 3; ++k) + for(int k = 0; k < MAX_EFFECT_INDEX; ++k) { if ((spellInfo->Effect[k] == SPELL_EFFECT_QUEST_COMPLETE && uint32(spellInfo->EffectMiscValue[k]) == qinfo->QuestId) || spellInfo->Effect[k] == SPELL_EFFECT_SEND_EVENT) @@ -3914,7 +3914,7 @@ void ObjectMgr::LoadQuests() if(!spellInfo) continue; - for(int j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { if(spellInfo->Effect[j] != SPELL_EFFECT_QUEST_COMPLETE) continue; diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 769ebcaa9..22e07e12b 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1166,7 +1166,7 @@ void Pet::_LoadAuras(uint32 timediff) continue; } - if(effindex >= 3) + if(effindex >= MAX_EFFECT_INDEX) { sLog.outError("Invalid effect index (spellid %u, effindex %u), ignore.",spellid,effindex); continue; @@ -1236,7 +1236,7 @@ void Pet::_SaveAuras() { // skip all auras from spell that apply at cast SPELL_AURA_MOD_SHAPESHIFT or pet area auras. uint8 i; - for (i = 0; i < 3; ++i) + for (i = 0; i < MAX_EFFECT_INDEX; ++i) if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH || spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_OWNER || spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PET ) diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index 131a34f4b..82e010c44 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -184,7 +184,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) return; } - for(uint32 i = 0; i < 3;++i) + for(int i = 0; i < MAX_EFFECT_INDEX;++i) { if(spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA || spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED) return; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index fe9fddf8e..3a66d4595 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -3279,7 +3279,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo RemoveAurasDueToSpell(spell_id); // remove pet auras - for(int i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) if(PetAura const* petSpell = sSpellMgr.GetPetAura(spell_id, i)) RemovePetAura(petSpell); @@ -4256,7 +4256,7 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) { int32 delta = (int32(getLevel()) - startLevel + 1)*MINUTE; - for(int i =0; i < 3; ++i) + for(int i =0; i < MAX_EFFECT_INDEX; ++i) { if(Aura* Aur = GetAura(SPELL_ID_PASSIVE_RESURRECTION_SICKNESS,i)) { @@ -7078,7 +7078,7 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply if(form_change) // check aura active state from other form { bool found = false; - for (int k=0; k < 3; ++k) + for (int k=0; k < MAX_EFFECT_INDEX; ++k) { spellEffectPair spair = spellEffectPair(spellInfo->Id, k); for (AuraMap::const_iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair); ++iter) @@ -15305,7 +15305,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) remaincharges = 0; - for(uint32 i=0; iEffect[i] == SPELL_EFFECT_LEARN_SPELL && !HasSpell(spellInfo->EffectTriggerSpell[i])) { @@ -19240,7 +19240,7 @@ void Player::SendAurasForTarget(Unit *target) Unit::VisibleAuraMap const *visibleAuras = target->GetVisibleAuras(); for(Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr) { - for(uint32 j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { if(Aura *aura = target->GetAura(itr->second, j)) { diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index cd8b58d81..67db3e923 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -375,7 +375,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi UpdateOriginalCasterPointer(); - for(int i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) m_currentBasePoints[i] = m_spellInfo->EffectBasePoints[i]; m_spellState = SPELL_STATE_NULL; @@ -410,7 +410,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi if(m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && !(m_spellInfo->AttributesEx2 & SPELL_ATTR_EX2_CANT_REFLECTED)) { - for(int j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { if (m_spellInfo->Effect[j] == 0) continue; @@ -467,7 +467,7 @@ void Spell::FillTargetMap() { // TODO: ADD the correct target FILLS!!!!!! - for(uint32 i = 0; i < 3; ++i) + for(uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) { // not call for empty effect. // Also some spells use not used effect targets for store targets for dummy effect in triggered spells @@ -1159,7 +1159,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) // Apply additional spell effects to target CastPreCastSpells(unit); - for(uint32 effectNumber = 0; effectNumber < 3; ++effectNumber) + for(int effectNumber = 0; effectNumber < MAX_EFFECT_INDEX; ++effectNumber) { if (effectMask & (1 << effectNumber)) { @@ -1192,7 +1192,7 @@ void Spell::DoAllEffectOnTarget(GOTargetInfo *target) if(!go) return; - for(uint32 effectNumber = 0; effectNumber < 3; ++effectNumber) + for(int effectNumber = 0; effectNumber < MAX_EFFECT_INDEX; ++effectNumber) if (effectMask & (1 << effectNumber)) HandleEffects(NULL, NULL, go, effectNumber); @@ -1211,7 +1211,7 @@ void Spell::DoAllEffectOnTarget(ItemTargetInfo *target) if(!target->item || !effectMask) return; - for(uint32 effectNumber = 0; effectNumber < 3; ++effectNumber) + for(int effectNumber = 0; effectNumber < MAX_EFFECT_INDEX; ++effectNumber) if (effectMask & (1 << effectNumber)) HandleEffects(NULL, target->item, NULL, effectNumber); } @@ -1771,7 +1771,7 @@ void Spell::SetTargetMap(uint32 effIndex, uint32 targetMode, UnitList& targetUni Unit* target = m_targets.getUnitTarget(); if(!target) target = m_caster; - uint32 count = CalculateDamage(2,m_caster); // stored in dummy effect, affected by mods + uint32 count = CalculateDamage(EFFECT_INDEX_2,m_caster); // stored in dummy effect, affected by mods FillRaidOrPartyHealthPriorityTargets(targetUnitMap, m_caster, target, radius, count, true, false, true); } @@ -2812,7 +2812,7 @@ void Spell::_handle_immediate_phase() HandleThreatSpells(m_spellInfo->Id); m_needSpellLog = IsNeedSendToClient(); - for(uint32 j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { if(m_spellInfo->Effect[j] == 0) continue; @@ -2849,7 +2849,7 @@ void Spell::_handle_immediate_phase() DoAllEffectOnTarget(&(*ihit)); // process ground - for(uint32 j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { // persistent area auras target only the ground if(m_spellInfo->Effect[j] == SPELL_EFFECT_PERSISTENT_AREA_AURA) @@ -4090,7 +4090,7 @@ SpellCastResult Spell::CheckCast(bool strict) // this case can be triggered if rank not found (too low-level target for first rank) if (m_caster->GetTypeId() == TYPEID_PLAYER && !IsPassiveSpell(m_spellInfo->Id) && !m_CastItem) { - for(int i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { // check only spell that apply positive auras if (IsPositiveEffect(m_spellInfo->Id, i) && m_spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && @@ -4135,7 +4135,7 @@ SpellCastResult Spell::CheckCast(bool strict) } // check pet presents - for(int j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { if(m_spellInfo->EffectImplicitTargetA[j] == TARGET_PET) { @@ -4172,7 +4172,7 @@ SpellCastResult Spell::CheckCast(bool strict) bool target_hostile_checked = false; bool target_friendly = false; bool target_friendly_checked = false; - for(int k = 0; k < 3; ++k) + for(int k = 0; k < MAX_EFFECT_INDEX; ++k) { if (IsExplicitPositiveTarget(m_spellInfo->EffectImplicitTargetA[k])) { @@ -4289,7 +4289,7 @@ SpellCastResult Spell::CheckCast(bool strict) // Database based targets from spell_target_script if (m_UniqueTargetInfo.empty()) // skip second CheckCast apply (for delayed spells for example) { - for(uint8 j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT || (m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT && m_spellInfo->EffectImplicitTargetA[j] != TARGET_SELF) || @@ -4455,7 +4455,7 @@ SpellCastResult Spell::CheckCast(bool strict) return castResult; } - for (int i = 0; i < 3; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { // for effects of spells that have only one target switch(m_spellInfo->Effect[i]) @@ -4865,7 +4865,7 @@ SpellCastResult Spell::CheckCast(bool strict) } } - for (int i = 0; i < 3; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { switch(m_spellInfo->EffectApplyAuraName[i]) { @@ -5042,7 +5042,7 @@ SpellCastResult Spell::CheckPetCast(Unit* target) target = m_targets.getUnitTarget(); bool need = false; - for(uint32 i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { if (m_spellInfo->EffectImplicitTargetA[i] == TARGET_CHAIN_DAMAGE || m_spellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_FRIEND || @@ -5075,7 +5075,7 @@ SpellCastResult Spell::CheckPetCast(Unit* target) else { bool duelvsplayertar = false; - for(int j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { //TARGET_DUELVSPLAYER is positive AND negative duelvsplayertar |= (m_spellInfo->EffectImplicitTargetA[j] == TARGET_DUELVSPLAYER); @@ -5110,7 +5110,7 @@ SpellCastResult Spell::CheckCasterAuras() const // We use bitmasks so the loop is done only once and not on every aura check below. if ( m_spellInfo->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY ) { - for(int i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { if (m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_SCHOOL_IMMUNITY) school_immune |= uint32(m_spellInfo->EffectMiscValue[i]); @@ -5211,7 +5211,7 @@ bool Spell::CanAutoCast(Unit* target) { uint64 targetguid = target->GetGUID(); - for(uint32 j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { if(m_spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AURA) { @@ -5447,7 +5447,7 @@ SpellCastResult Spell::CheckItems() { // such items should only fail if there is no suitable effect at all - see Rejuvenation Potions for example SpellCastResult failReason = SPELL_CAST_OK; - for (int i = 0; i < 3; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { // skip check, pet not required like checks, and for TARGET_PET m_targets.getUnitTarget() is not the real target but the caster if (m_spellInfo->EffectImplicitTargetA[i] == TARGET_PET) @@ -5610,7 +5610,7 @@ SpellCastResult Spell::CheckItems() } // special checks for spell effects - for(int i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { switch (m_spellInfo->Effect[i]) { @@ -5892,7 +5892,7 @@ void Spell::DelayedChannel() Unit* unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); if (unit) { - for (int j = 0; j < 3; ++j) + for (int j = 0; j < MAX_EFFECT_INDEX; ++j) if( ihit->effectMask & (1 << j) ) unit->DelayAura(m_spellInfo->Id, j, delaytime); } @@ -5900,7 +5900,7 @@ void Spell::DelayedChannel() } } - for(int j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { // partially interrupt persistent area auras DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id, j); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index d39887453..6facdb731 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -573,7 +573,7 @@ Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoi uint32 triggeredSpellId = spellproto->EffectTriggerSpell[eff]; if(SpellEntry const* triggeredSpellInfo = sSpellStore.LookupEntry(triggeredSpellId)) - for (int i = 0; i < 3; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) if (triggeredSpellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_ENEMY) return new SingleEnemyTargetAura(spellproto, eff, currentBasePoints, target, caster, castItem); @@ -1117,7 +1117,7 @@ bool Aura::_RemoveAura() bool lastaura = true; // find other aura in same slot (current already removed from list) - for(uint8 i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i); for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr) @@ -3135,7 +3135,7 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real) if(itr->second->state == PLAYERSPELL_REMOVED) continue; SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); if (spellInfo && spellInfo->SpellFamilyName == SPELLFAMILY_WARRIOR && spellInfo->SpellIconID == 139) - Rage_val += m_target->CalculateSpellDamage(spellInfo, 0, spellInfo->EffectBasePoints[EFFECT_INDEX_0], m_target) * 10; + Rage_val += m_target->CalculateSpellDamage(spellInfo, EFFECT_INDEX_0, spellInfo->EffectBasePoints[EFFECT_INDEX_0], m_target) * 10; } } @@ -7506,7 +7506,7 @@ void Aura::PeriodicDummyTick() if (rage == 0) return; int32 mod = (rage < 100) ? rage : 100; - int32 points = m_target->CalculateSpellDamage(spell, 1, spell->EffectBasePoints[EFFECT_INDEX_1], m_target); + int32 points = m_target->CalculateSpellDamage(spell, EFFECT_INDEX_1, spell->EffectBasePoints[EFFECT_INDEX_1], m_target); int32 regen = m_target->GetMaxHealth() * (mod * points / 10) / 1000; m_target->CastCustomSpell(m_target, 22845, ®en, NULL, NULL, true, NULL, this); m_target->SetPower(POWER_RAGE, rage-mod); @@ -7642,7 +7642,7 @@ void Aura::PeriodicDummyTick() { // Increases your attack power by $s1 for every $s2 armor value you have. // Calculate AP bonus (from 1 efect of this spell) - int32 apBonus = m_modifier.m_amount * m_target->GetArmor() / m_target->CalculateSpellDamage(spell, 1, spell->EffectBasePoints[EFFECT_INDEX_1], m_target); + int32 apBonus = m_modifier.m_amount * m_target->GetArmor() / m_target->CalculateSpellDamage(spell, EFFECT_INDEX_1, spell->EffectBasePoints[EFFECT_INDEX_1], m_target); m_target->CastCustomSpell(m_target, 61217, &apBonus, &apBonus, NULL, true, NULL, this); return; } diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 0ccae77fa..46313cdd2 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -399,7 +399,7 @@ void Spell::EffectSchoolDMG(uint32 effect_idx) // Shockwave ${$m3/100*$AP} else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000800000000000)) { - int32 pct = m_caster->CalculateSpellDamage(m_spellInfo, 2, m_spellInfo->EffectBasePoints[EFFECT_INDEX_2], unitTarget); + int32 pct = m_caster->CalculateSpellDamage(m_spellInfo, EFFECT_INDEX_2, m_spellInfo->EffectBasePoints[EFFECT_INDEX_2], unitTarget); if (pct > 0) damage+= int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * pct / 100); break; @@ -718,7 +718,7 @@ void Spell::EffectSchoolDMG(uint32 effect_idx) { // Add main hand dps * effect[2] amount float average = (m_caster->GetFloatValue(UNIT_FIELD_MINDAMAGE) + m_caster->GetFloatValue(UNIT_FIELD_MAXDAMAGE)) / 2; - int32 count = m_caster->CalculateSpellDamage(m_spellInfo, 2, m_spellInfo->EffectBasePoints[EFFECT_INDEX_2], unitTarget); + int32 count = m_caster->CalculateSpellDamage(m_spellInfo, EFFECT_INDEX_2, m_spellInfo->EffectBasePoints[EFFECT_INDEX_2], unitTarget); damage += count * int32(average * IN_MILISECONDS) / m_caster->GetAttackTime(BASE_ATTACK); } // Shield of Righteousness @@ -1274,7 +1274,7 @@ void Spell::EffectDummy(uint32 i) { switch(i) { - case 0: + case EFFECT_INDEX_0: { uint32 spellID = m_spellInfo->CalculateSimpleValue(EFFECT_INDEX_0); uint32 reqAuraID = m_spellInfo->CalculateSimpleValue(EFFECT_INDEX_1); @@ -1283,7 +1283,7 @@ void Spell::EffectDummy(uint32 i) m_caster->CastSpell(m_caster, spellID, true, NULL); return; } - case 1: + case EFFECT_INDEX_1: return; // additional data for dummy[0] } return; @@ -4594,7 +4594,7 @@ void Spell::EffectWeaponDmg(uint32 i) // multiple weapon dmg effect workaround // execute only the last weapon damage // and handle all effects at once - for (uint32 j = 0; j < 3; ++j) + for (int j = 0; j < MAX_EFFECT_INDEX; ++j) { switch(m_spellInfo->Effect[j]) { @@ -4602,7 +4602,7 @@ void Spell::EffectWeaponDmg(uint32 i) case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: - if (j < i) // we must calculate only at last weapon effect + if (j < int(i)) // we must calculate only at last weapon effect return; break; } @@ -4640,7 +4640,7 @@ void Spell::EffectWeaponDmg(uint32 i) } } if (stack) - spell_bonus += stack * CalculateDamage(2, unitTarget); + spell_bonus += stack * CalculateDamage(EFFECT_INDEX_2, unitTarget); if (!stack || stack < spellInfo->StackAmount) // Devastate causing Sunder Armor Effect // and no need to cast over max stack amount @@ -4745,7 +4745,7 @@ void Spell::EffectWeaponDmg(uint32 i) if (count) { // Effect 1(for Blood-Caked Strike)/3(other) damage is bonus - float bonus = count * CalculateDamage(m_spellInfo->SpellIconID == 1736 ? 0 : 2, unitTarget) / 100.0f; + float bonus = count * CalculateDamage(m_spellInfo->SpellIconID == 1736 ? EFFECT_INDEX_0 : EFFECT_INDEX_2, unitTarget) / 100.0f; // Blood Strike, Blood-Caked Strike and Obliterate store bonus*2 if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0002000000400000) || m_spellInfo->SpellIconID == 1736) @@ -4786,7 +4786,7 @@ void Spell::EffectWeaponDmg(uint32 i) } int32 fixed_bonus = 0; - for (int j = 0; j < 3; ++j) + for (int j = 0; j < MAX_EFFECT_INDEX; ++j) { switch(m_spellInfo->Effect[j]) { diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 022861d58..d8442ff0f 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -405,7 +405,7 @@ void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket) { // except own aura spells bool allow = false; - for(int k = 0; k < 3; ++k) + for(int k = 0; k < MAX_EFFECT_INDEX; ++k) { if (spellInfo->EffectApplyAuraName[k] == SPELL_AURA_MOD_POSSESS || spellInfo->EffectApplyAuraName[k] == SPELL_AURA_MOD_POSSESS_PET) diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 6650c300a..ebf7de3d8 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -104,7 +104,7 @@ uint16 GetSpellAuraMaxTicks(SpellEntry const* spellInfo) if(DotDuration > 30000) DotDuration = 30000; - for (int j = 0; j < 3; ++j) + for (int j = 0; j < MAX_EFFECT_INDEX; ++j) { if (spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AURA && ( spellInfo->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_DAMAGE || @@ -198,7 +198,7 @@ SpellSpecific GetSpellSpecific(uint32 spellId) { bool food = false; bool drink = false; - for(int i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { switch(spellInfo->EffectApplyAuraName[i]) { @@ -550,7 +550,7 @@ bool IsPositiveEffect(uint32 spellId, uint32 effIndex) if(spellTriggeredProto) { // non-positive targets of main spell return early - for(int i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { // if non-positive trigger cast targeted to positive target this main cast is non-positive // this will place this spell auras as debuffs @@ -685,7 +685,7 @@ bool IsPositiveSpell(uint32 spellId) // spells with atleast one negative effect are considered negative // some self-applied spells have negative effects but in self casting case negative check ignored. - for (int i = 0; i < 3; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) if (!IsPositiveEffect(spellId, i)) return false; return true; @@ -831,7 +831,7 @@ void SpellMgr::LoadSpellTargetPositions() } bool found = false; - for(int i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { if( spellInfo->EffectImplicitTargetA[i]==TARGET_TABLE_X_Y_Z_COORDINATES || spellInfo->EffectImplicitTargetB[i]==TARGET_TABLE_X_Y_Z_COORDINATES ) { @@ -1282,7 +1282,7 @@ bool SpellMgr::canStackSpellRanks(SpellEntry const *spellInfo) return false; // All stance spells. if any better way, change it. - for (int i = 0; i < 3; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { switch(spellInfo->SpellFamilyName) { @@ -1758,7 +1758,7 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons spellInfo_1->SpellIconID != 0 && spellInfo_2->SpellIconID != 0) { bool isModifier = false; - for (int i = 0; i < 3; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellInfo_1->EffectApplyAuraName[i] == SPELL_AURA_ADD_FLAT_MODIFIER || spellInfo_1->EffectApplyAuraName[i] == SPELL_AURA_ADD_PCT_MODIFIER || @@ -1781,7 +1781,7 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons return false; bool dummy_only = true; - for (int i = 0; i < 3; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellInfo_1->Effect[i] != spellInfo_2->Effect[i] || spellInfo_1->EffectItemType[i] != spellInfo_2->EffectItemType[i] || @@ -2089,7 +2089,7 @@ void SpellMgr::LoadSpellLearnSkills() if(!entry) continue; - for(int i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { if(entry->Effect[i]==SPELL_EFFECT_SKILL) { @@ -2178,7 +2178,7 @@ void SpellMgr::LoadSpellLearnSpells() if (!entry) continue; - for(int i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { if(entry->Effect[i]==SPELL_EFFECT_LEARN_SPELL) { @@ -2261,7 +2261,7 @@ void SpellMgr::LoadSpellScriptTarget() } bool targetfound = false; - for (int i = 0; i < 3; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { if( spellProto->EffectImplicitTargetA[i] == TARGET_SCRIPT || spellProto->EffectImplicitTargetB[i] == TARGET_SCRIPT || @@ -2565,7 +2565,7 @@ void SpellMgr::LoadPetDefaultSpells() if(!spellEntry) continue; - for(int k = 0; k < 3; ++k) + for(int k = 0; k < MAX_EFFECT_INDEX; ++k) { if(spellEntry->Effect[k]==SPELL_EFFECT_SUMMON || spellEntry->Effect[k]==SPELL_EFFECT_SUMMON_PET) { diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 90b140977..e85c13a13 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -130,7 +130,7 @@ WeaponAttackType GetWeaponAttackType(SpellEntry const *spellInfo); inline bool IsSpellHaveEffect(SpellEntry const *spellInfo, SpellEffects effect) { - for(int i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) if(SpellEffects(spellInfo->Effect[i])==effect) return true; return false; @@ -138,7 +138,7 @@ inline bool IsSpellHaveEffect(SpellEntry const *spellInfo, SpellEffects effect) inline bool IsSpellHaveAura(SpellEntry const *spellInfo, AuraType aura) { - for(int i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) if(AuraType(spellInfo->EffectApplyAuraName[i])==aura) return true; return false; @@ -146,7 +146,7 @@ inline bool IsSpellHaveAura(SpellEntry const *spellInfo, AuraType aura) inline bool IsSpellLastAuraEffect(SpellEntry const *spellInfo, int effecIdx) { - for(int i = effecIdx+1; i < 3; ++i) + for(int i = effecIdx+1; i < MAX_EFFECT_INDEX; ++i) if(spellInfo->EffectApplyAuraName[i]) return false; return true; @@ -259,7 +259,7 @@ inline bool IsCasterSourceTarget(uint32 target) inline bool IsSpellWithCasterSourceTargetsOnly(SpellEntry const* spellInfo) { - for(int i = 0; i < 3; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { uint32 targetA = spellInfo->EffectImplicitTargetA[i]; if(targetA && !IsCasterSourceTarget(targetA)) @@ -401,7 +401,7 @@ inline uint32 GetAllSpellMechanicMask(SpellEntry const* spellInfo) uint32 mask = 0; if (spellInfo->Mechanic) mask |= 1 << (spellInfo->Mechanic - 1); - for (int i=0; i< 3; ++i) + for (int i=0; i< MAX_EFFECT_INDEX; ++i) if (spellInfo->EffectMechanic[i]) mask |= 1 << (spellInfo->EffectMechanic[i]-1); return mask; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 2403315df..1b8207f8d 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -2744,7 +2744,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) // Chance resist mechanic (select max value from every mechanic spell effect) int32 resist_mech = 0; // Get effects mechanic and chance - for(int eff = 0; eff < 3; ++eff) + for(int eff = 0; eff < MAX_EFFECT_INDEX; ++eff) { int32 effect_mech = GetEffectMechanic(spell, eff); if (effect_mech) @@ -2887,7 +2887,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) // Chance resist mechanic (select max value from every mechanic spell effect) int32 resist_mech = 0; // Get effects mechanic and chance - for(int eff = 0; eff < 3; ++eff) + for(int eff = 0; eff < MAX_EFFECT_INDEX; ++eff) { int32 effect_mech = GetEffectMechanic(spell, eff); if (effect_mech) @@ -3962,12 +3962,12 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) bool is_triggered_by_spell = false; // prevent triggering aura of removing aura that triggered it - for(int j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) if (i_spellProto->EffectTriggerSpell[j] == spellId) is_triggered_by_spell = true; // prevent triggered aura of removing aura that triggering it (triggered effect early some aura of parent spell - for(int j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) if (spellProto->EffectTriggerSpell[j] == i_spellId) is_triggered_by_spell = true; @@ -4301,13 +4301,13 @@ void Unit::RemoveSingleAuraByCasterSpell(uint32 spellId, uint32 effindex, uint64 void Unit::RemoveAurasDueToSpell(uint32 spellId, Aura* except) { - for (int i = 0; i < 3; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) RemoveAura(spellId,i,except); } void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId) { - for (int k=0; k < 3; ++k) + for (int k=0; k < MAX_EFFECT_INDEX; ++k) { spellEffectPair spair = spellEffectPair(spellId, k); for (AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);) @@ -4547,7 +4547,7 @@ Aura* Unit::GetAura(AuraType type, uint32 family, uint64 familyFlag, uint32 fami bool Unit::HasAura(uint32 spellId) const { - for (int i = 0; i < 3 ; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX ; ++i) { AuraMap::const_iterator iter = m_Auras.find(spellEffectPair(spellId, i)); if (iter != m_Auras.end()) @@ -6553,7 +6553,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu return false; } - int32 extra_attack_power = CalculateSpellDamage(windfurySpellEntry, 1, windfurySpellEntry->EffectBasePoints[EFFECT_INDEX_1], pVictim); + int32 extra_attack_power = CalculateSpellDamage(windfurySpellEntry, EFFECT_INDEX_1, windfurySpellEntry->EffectBasePoints[EFFECT_INDEX_1], pVictim); // Off-Hand case if ( castItem->GetSlot() == EQUIPMENT_SLOT_OFFHAND ) @@ -8829,7 +8829,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 // effect 1 m_amount int32 maxPercent = (*i)->GetModifier()->m_amount; // effect 0 m_amount - int32 stepPercent = CalculateSpellDamage((*i)->GetSpellProto(), 0, (*i)->GetSpellProto()->EffectBasePoints[EFFECT_INDEX_0], this); + int32 stepPercent = CalculateSpellDamage((*i)->GetSpellProto(), EFFECT_INDEX_0, (*i)->GetSpellProto()->EffectBasePoints[EFFECT_INDEX_0], this); // count affliction effects and calc additional damage in percentage int32 modPercent = 0; AuraMap const& victimAuras = pVictim->GetAuras(); @@ -9093,7 +9093,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 uint32 CastingTime = !IsChanneledSpell(spellProto) ? GetSpellCastTime(spellProto) : GetSpellDuration(spellProto); CastingTime = GetCastingTimeForBonus( spellProto, damagetype, CastingTime ); // 50% for damage and healing spells for leech spells from damage bonus and 0% from healing - for(int j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { if (spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH || (spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && @@ -9536,7 +9536,7 @@ int32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, int32 uint32 CastingTime = !IsChanneledSpell(spellProto) ? GetSpellCastTime(spellProto) : GetSpellDuration(spellProto); CastingTime = GetCastingTimeForBonus( spellProto, damagetype, CastingTime ); // 50% for damage and healing spells for leech spells from damage bonus and 0% from healing - for(int j = 0; j < 3; ++j) + for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { if( spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH || spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH ) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4802ea963..ec88ac11d 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 "9407" + #define REVISION_NR "9408" #endif // __REVISION_NR_H__