Skip to content

Commit

Permalink
[9403] Replace number with enum name where explicitly used in array/o…
Browse files Browse the repository at this point in the history
…ther checks

Signed-off-by: NoFantasy <nofantasy@nf.no>
  • Loading branch information
NoFantasy committed Feb 17, 2010
1 parent 242d2f2 commit 3a0ecc0
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 128 deletions.
2 changes: 1 addition & 1 deletion src/game/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,7 @@ bool Creature::LoadCreaturesAddon(bool reload)

Aura* AdditionalAura = CreateAura(AdditionalSpellInfo, cAura->effect_idx, NULL, this, this, 0);
AddAura(AdditionalAura);
sLog.outDebug("Spell: %u with Aura %u added to creature (GUIDLow: %u Entry: %u )", cAura->spell_id, AdditionalSpellInfo->EffectApplyAuraName[0],GetGUIDLow(),GetEntry());
sLog.outDebug("Spell: %u with Aura %u added to creature (GUIDLow: %u Entry: %u )", cAura->spell_id, AdditionalSpellInfo->EffectApplyAuraName[EFFECT_INDEX_0],GetGUIDLow(),GetEntry());
}
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/game/CreatureEventAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
{
//Note: checked only aura for effect 0, if need check aura for effect 1/2 then
// possible way: pack in event.buffed.amount 2 uint16 (ammount+effectIdx)
Aura* aura = m_creature->GetAura(event.buffed.spellId,0);
Aura* aura = m_creature->GetAura(event.buffed.spellId, EFFECT_INDEX_0);
if (!aura || aura->GetStackAmount() < event.buffed.amount)
return false;

Expand All @@ -309,7 +309,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction

//Note: checked only aura for effect 0, if need check aura for effect 1/2 then
// possible way: pack in event.buffed.amount 2 uint16 (ammount+effectIdx)
Aura* aura = pActionInvoker->GetAura(event.buffed.spellId,0);
Aura* aura = pActionInvoker->GetAura(event.buffed.spellId, EFFECT_INDEX_0);
if(!aura || aura->GetStackAmount() < event.buffed.amount)
return false;

Expand Down
2 changes: 1 addition & 1 deletion src/game/GridNotifiers.h
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ namespace MaNGOS
bool operator()(Unit* u)
{
if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
!(u->HasAura(i_spell, 0) || u->HasAura(i_spell, 1) || u->HasAura(i_spell, 2)))
!(u->HasAura(i_spell, EFFECT_INDEX_0) || u->HasAura(i_spell, EFFECT_INDEX_1) || u->HasAura(i_spell, EFFECT_INDEX_2)))
{
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/game/Level3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2909,7 +2909,7 @@ bool ChatHandler::HandleLookupSpellCommand(const char* args)
if(loc < MAX_LOCALE)
{
bool known = target && target->HasSpell(id);
bool learn = (spellInfo->Effect[0] == SPELL_EFFECT_LEARN_SPELL);
bool learn = (spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_LEARN_SPELL);

uint32 talentCost = GetTalentSpellCost(id);

Expand All @@ -2919,7 +2919,7 @@ bool ChatHandler::HandleLookupSpellCommand(const char* args)

// unit32 used to prevent interpreting uint8 as char at output
// find rank of learned spell for learning spell, or talent rank
uint32 rank = talentCost ? talentCost : sSpellMgr.GetSpellRank(learn ? spellInfo->EffectTriggerSpell[0] : id);
uint32 rank = talentCost ? talentCost : sSpellMgr.GetSpellRank(learn ? spellInfo->EffectTriggerSpell[EFFECT_INDEX_0] : id);

// send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
std::ostringstream ss;
Expand Down
4 changes: 2 additions & 2 deletions src/game/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7467,7 +7467,7 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val
sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1);
return false;
}
if(value2 > 2)
if(value2 > EFFECT_INDEX_2)
{
sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2);
return false;
Expand Down Expand Up @@ -7571,7 +7571,7 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val
sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1);
return false;
}
if(value2 > 2)
if(value2 > EFFECT_INDEX_2)
{
sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2);
return false;
Expand Down
22 changes: 11 additions & 11 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,7 @@ void Player::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attack
addRage = damage/rageconversion*2.5f;

// Berserker Rage effect
if(HasAura(18499,0))
if (HasAura(18499, EFFECT_INDEX_0))
addRage *= 1.3f;
}

Expand Down Expand Up @@ -13129,7 +13129,7 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver )

for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
if(itr->second->autocast && itr->second->IsFitToRequirements(this,zone,area))
if( !HasAura(itr->second->spellId,0) )
if (!HasAura(itr->second->spellId, EFFECT_INDEX_0) )
CastSpell(this,itr->second->spellId,true);
}

Expand Down Expand Up @@ -13319,7 +13319,7 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver

for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
if(itr->second->autocast && itr->second->IsFitToRequirements(this,zone,area))
if( !HasAura(itr->second->spellId,0) )
if (!HasAura(itr->second->spellId, EFFECT_INDEX_0))
CastSpell(this,itr->second->spellId,true);
}

Expand Down Expand Up @@ -18624,7 +18624,7 @@ void Player::ReportedAfkBy(Player* reporter)
return;

// check if player has 'Idle' or 'Inactive' debuff
if(m_bgData.bgAfkReporter.find(reporter->GetGUIDLow()) == m_bgData.bgAfkReporter.end() && !HasAura(43680, 0) && !HasAura(43681, 0) && reporter->CanReportAfkDueToLimit())
if(m_bgData.bgAfkReporter.find(reporter->GetGUIDLow()) == m_bgData.bgAfkReporter.end() && !HasAura(43680, EFFECT_INDEX_0) && !HasAura(43681, EFFECT_INDEX_0) && reporter->CanReportAfkDueToLimit())
{
m_bgData.bgAfkReporter.insert(reporter->GetGUIDLow());
// 3 players have to complain to apply debuff
Expand Down Expand Up @@ -19139,7 +19139,7 @@ void Player::learnQuestRewardedSpells(Quest const* quest)
return;

// prevent learn non first rank unknown profession and second specialization for same profession)
uint32 learned_0 = spellInfo->EffectTriggerSpell[0];
uint32 learned_0 = spellInfo->EffectTriggerSpell[EFFECT_INDEX_0];
if( sSpellMgr.GetSpellRank(learned_0) > 1 && !HasSpell(learned_0) )
{
// not have first rank learned (unlearned prof?)
Expand All @@ -19152,7 +19152,7 @@ void Player::learnQuestRewardedSpells(Quest const* quest)
return;

// specialization
if(learnedInfo->Effect[0]==SPELL_EFFECT_TRADE_SKILL && learnedInfo->Effect[1]==0)
if (learnedInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_TRADE_SKILL && learnedInfo->Effect[EFFECT_INDEX_1] == 0)
{
// search other specialization for same prof
for(PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
Expand All @@ -19165,7 +19165,7 @@ void Player::learnQuestRewardedSpells(Quest const* quest)
return;

// compare only specializations
if(itrInfo->Effect[0]!=SPELL_EFFECT_TRADE_SKILL || itrInfo->Effect[1]!=0)
if (itrInfo->Effect[EFFECT_INDEX_0] != SPELL_EFFECT_TRADE_SKILL || itrInfo->Effect[EFFECT_INDEX_1] != 0)
continue;

// compare same chain spells
Expand Down Expand Up @@ -19667,7 +19667,7 @@ uint32 Player::GetResurrectionSpellId()

// Reincarnation (passive spell) // prio: 1
// Glyph of Renewed Life remove reagent requiremnnt
if (prio < 1 && HasSpell(20608) && !HasSpellCooldown(21169) && (HasItemCount(17030,1) || HasAura(58059, 0)))
if (prio < 1 && HasSpell(20608) && !HasSpellCooldown(21169) && (HasItemCount(17030,1) || HasAura(58059, EFFECT_INDEX_0)))
spell_id = 21169;

return spell_id;
Expand Down Expand Up @@ -19889,7 +19889,7 @@ void Player::UpdateZoneDependentAuras( uint32 newZone )
SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAreaMapBounds(newZone);
for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
if(itr->second->autocast && itr->second->IsFitToRequirements(this,newZone,0))
if( !HasAura(itr->second->spellId,0) )
if (!HasAura(itr->second->spellId, EFFECT_INDEX_0))
CastSpell(this,itr->second->spellId,true);
}

Expand All @@ -19909,7 +19909,7 @@ void Player::UpdateAreaDependentAuras( uint32 newArea )
SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAreaMapBounds(newArea);
for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
if(itr->second->autocast && itr->second->IsFitToRequirements(this,m_zoneUpdateId,newArea))
if( !HasAura(itr->second->spellId,0) )
if (!HasAura(itr->second->spellId, EFFECT_INDEX_0))
CastSpell(this,itr->second->spellId,true);
}

Expand Down Expand Up @@ -20152,7 +20152,7 @@ bool Player::CanUseBattleGroundObject()
//i'm not sure if these two are correct, because invisible players should get visible when they click on flag
!HasStealthAura() && // not stealthed
!HasInvisibilityAura() && // not invisible
!HasAura(SPELL_RECENTLY_DROPPED_FLAG, 0) && // can't pickup
!HasAura(SPELL_RECENTLY_DROPPED_FLAG, EFFECT_INDEX_0) &&// can't pickup
isAlive() // live player
);
}
Expand Down
22 changes: 11 additions & 11 deletions src/game/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ bool IsQuestTameSpell(uint32 spellId)
if (!spellproto)
return false;

return spellproto->Effect[0] == SPELL_EFFECT_THREAT
&& spellproto->Effect[1] == SPELL_EFFECT_APPLY_AURA && spellproto->EffectApplyAuraName[1] == SPELL_AURA_DUMMY;
return spellproto->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_THREAT
&& spellproto->Effect[EFFECT_INDEX_1] == SPELL_EFFECT_APPLY_AURA && spellproto->EffectApplyAuraName[EFFECT_INDEX_1] == SPELL_AURA_DUMMY;
}

SpellCastTargets::SpellCastTargets()
Expand Down Expand Up @@ -1362,9 +1362,9 @@ void Spell::SetTargetMap(uint32 effIndex, uint32 targetMode, UnitList& targetUni
// overwrite EffectChainTarget for non single target spell
if (Spell* currSpell = m_caster->GetCurrentSpell(CURRENT_GENERIC_SPELL))
if (currSpell->m_spellInfo->MaxAffectedTargets > 0 ||
currSpell->m_spellInfo->EffectChainTarget[0] > 0 ||
currSpell->m_spellInfo->EffectChainTarget[1] > 0 ||
currSpell->m_spellInfo->EffectChainTarget[2] > 0)
currSpell->m_spellInfo->EffectChainTarget[EFFECT_INDEX_0] > 0 ||
currSpell->m_spellInfo->EffectChainTarget[EFFECT_INDEX_1] > 0 ||
currSpell->m_spellInfo->EffectChainTarget[EFFECT_INDEX_2] > 0)
EffectChainTarget = 0; // no chain targets
}
break;
Expand Down Expand Up @@ -2900,7 +2900,7 @@ void Spell::update(uint32 difftime)
// check if the player caster has moved before the spell finished
if ((m_caster->GetTypeId() == TYPEID_PLAYER && m_timer != 0) &&
(m_castPositionX != m_caster->GetPositionX() || m_castPositionY != m_caster->GetPositionY() || m_castPositionZ != m_caster->GetPositionZ()) &&
(m_spellInfo->Effect[0] != SPELL_EFFECT_STUCK || !((Player*)m_caster)->m_movementInfo.HasMovementFlag(MOVEFLAG_FALLINGFAR)))
(m_spellInfo->Effect[EFFECT_INDEX_0] != SPELL_EFFECT_STUCK || !((Player*)m_caster)->m_movementInfo.HasMovementFlag(MOVEFLAG_FALLINGFAR)))
{
// always cancel for channeled spells
if( m_spellState == SPELL_STATE_CASTING )
Expand Down Expand Up @@ -3436,12 +3436,12 @@ void Spell::SendLogExecute()
data << uint32(count1); // count1 (effect count?)
for(uint32 i = 0; i < count1; ++i)
{
data << uint32(m_spellInfo->Effect[0]); // spell effect
data << uint32(m_spellInfo->Effect[EFFECT_INDEX_0]);// spell effect
uint32 count2 = 1;
data << uint32(count2); // count2 (target count?)
for(uint32 j = 0; j < count2; ++j)
{
switch(m_spellInfo->Effect[0])
switch(m_spellInfo->Effect[EFFECT_INDEX_0])
{
case SPELL_EFFECT_POWER_DRAIN:
if(Unit *unit = m_targets.getUnitTarget())
Expand Down Expand Up @@ -3482,7 +3482,7 @@ void Spell::SendLogExecute()
break;
case SPELL_EFFECT_CREATE_ITEM:
case SPELL_EFFECT_CREATE_ITEM_2:
data << uint32(m_spellInfo->EffectItemType[0]);
data << uint32(m_spellInfo->EffectItemType[EFFECT_INDEX_0]);
break;
case SPELL_EFFECT_SUMMON:
case SPELL_EFFECT_TRANS_DOOR:
Expand Down Expand Up @@ -4040,7 +4040,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if( m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->isMoving() )
{
// skip stuck spell to allow use it in falling case and apply spell limitations at movement
if( (!((Player*)m_caster)->m_movementInfo.HasMovementFlag(MOVEFLAG_FALLINGFAR) || m_spellInfo->Effect[0] != SPELL_EFFECT_STUCK) &&
if( (!((Player*)m_caster)->m_movementInfo.HasMovementFlag(MOVEFLAG_FALLINGFAR) || m_spellInfo->Effect[EFFECT_INDEX_0] != SPELL_EFFECT_STUCK) &&
(IsAutoRepeat() || (m_spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) != 0) )
return SPELL_FAILED_MOVING;
}
Expand Down Expand Up @@ -4113,7 +4113,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// If 0 spell effect empty - client not send target data (need use selection)
// TODO: check it on next client version
if (m_targets.m_targetMask == TARGET_FLAG_SELF &&
m_spellInfo->EffectImplicitTargetA[1] == TARGET_CHAIN_DAMAGE)
m_spellInfo->EffectImplicitTargetA[EFFECT_INDEX_1] == TARGET_CHAIN_DAMAGE)
{
if (target = m_caster->GetUnit(*m_caster, ((Player *)m_caster)->GetSelection()))
m_targets.setUnitTarget(target);
Expand Down

0 comments on commit 3a0ecc0

Please sign in to comment.