Skip to content

Commit

Permalink
[9411] More SpellEffectIndex using in apropriate cases
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirMangos committed Feb 19, 2010
1 parent f50653e commit 881a467
Show file tree
Hide file tree
Showing 26 changed files with 199 additions and 196 deletions.
6 changes: 3 additions & 3 deletions src/game/AchievementMgr.cpp
Expand Up @@ -163,7 +163,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri
criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.spell_id);
return false;
}
if (aura.effect_idx >= 3)
if (aura.effect_idx >= MAX_EFFECT_INDEX)
{
sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have wrong spell effect index in value2 (%u), ignore.",
criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.effect_idx);
Expand Down Expand Up @@ -276,15 +276,15 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou
// flag set == must be same team, not set == different team
return (((Player*)target)->GetTeam() == source->GetTeam()) == (player_dead.own_team_flag != 0);
case ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA:
return source->HasAura(aura.spell_id,aura.effect_idx);
return source->HasAura(aura.spell_id,SpellEffectIndex(aura.effect_idx));
case ACHIEVEMENT_CRITERIA_REQUIRE_S_AREA:
{
uint32 zone_id,area_id;
source->GetZoneAndAreaId(zone_id,area_id);
return area.id==zone_id || area.id==area_id;
}
case ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA:
return target && target->HasAura(aura.spell_id,aura.effect_idx);
return target && target->HasAura(aura.spell_id,SpellEffectIndex(aura.effect_idx));
case ACHIEVEMENT_CRITERIA_REQUIRE_VALUE:
return miscvalue1 >= value.minvalue;
case ACHIEVEMENT_CRITERIA_REQUIRE_T_LEVEL:
Expand Down
2 changes: 1 addition & 1 deletion src/game/Creature.cpp
Expand Up @@ -1358,7 +1358,7 @@ bool Creature::IsImmunedToSpell(SpellEntry const* spellInfo)
return Unit::IsImmunedToSpell(spellInfo);
}

bool Creature::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const
bool Creature::IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const
{
if (GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->EffectMechanic[index] - 1)))
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/game/Creature.h
Expand Up @@ -206,7 +206,7 @@ struct CreatureData
struct CreatureDataAddonAura
{
uint32 spell_id;
uint8 effect_idx;
SpellEffectIndex effect_idx;
};

// from `creature_addon` table
Expand Down Expand Up @@ -413,7 +413,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
bool IsOutOfThreatArea(Unit* pVictim) const;
bool IsImmunedToSpell(SpellEntry const* spellInfo);
// redefine Unit::IsImmunedToSpell
bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const;
bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const;
// redefine Unit::IsImmunedToSpellEffect
bool isElite() const
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/CreatureEventAI.cpp
Expand Up @@ -458,7 +458,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if(action.cast.castFlags & CAST_AURA_NOT_PRESENT)
{
for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
if(target->HasAura(action.cast.spellId, i))
if(target->HasAura(action.cast.spellId, SpellEffectIndex(i)))
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/game/DBCStructure.h
Expand Up @@ -1454,8 +1454,8 @@ struct SpellEntry
//uint32 SpellDifficultyId; // 239 3.3.0

// helpers
int32 CalculateSimpleValue(uint8 eff) const { return EffectBasePoints[eff]+int32(EffectBaseDice[eff]); }
uint32 const* GetEffectSpellClassMask(uint8 effect) const
int32 CalculateSimpleValue(SpellEffectIndex eff) const { return EffectBasePoints[eff]+int32(EffectBaseDice[eff]); }
uint32 const* GetEffectSpellClassMask(SpellEffectIndex effect) const
{
return EffectSpellClassMaskA + effect * 3;
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/DynamicObject.cpp
Expand Up @@ -55,7 +55,7 @@ void DynamicObject::RemoveFromWorld()
Object::RemoveFromWorld();
}

bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, float x, float y, float z, int32 duration, float radius )
bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius )
{
WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask());
SetMap(caster->GetMap());
Expand Down
6 changes: 3 additions & 3 deletions src/game/DynamicObject.h
Expand Up @@ -33,11 +33,11 @@ class DynamicObject : public WorldObject
void AddToWorld();
void RemoveFromWorld();

bool Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, float x, float y, float z, int32 duration, float radius);
bool Create(uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius);
void Update(uint32 p_time);
void Delete();
uint32 GetSpellId() const { return m_spellId; }
uint32 GetEffIndex() const { return m_effIndex; }
SpellEffectIndex GetEffIndex() const { return m_effIndex; }
uint32 GetDuration() const { return m_aliveDuration; }
uint64 GetCasterGUID() const { return GetUInt64Value(DYNAMICOBJECT_CASTER); }
Unit* GetCaster() const;
Expand All @@ -59,7 +59,7 @@ class DynamicObject : public WorldObject
bool isActiveObject() const { return m_isActiveObject; }
protected:
uint32 m_spellId;
uint32 m_effIndex;
SpellEffectIndex m_effIndex;
int32 m_aliveDuration;
float m_radius; // radius apply persistent effect, 0 = no persistent effect
AffectedSet m_affected;
Expand Down
2 changes: 1 addition & 1 deletion src/game/GridNotifiersImpl.h
Expand Up @@ -172,7 +172,7 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target)
return;

SpellEntry const *spellInfo = sSpellStore.LookupEntry(i_dynobject.GetSpellId());
uint32 eff_index = i_dynobject.GetEffIndex();
SpellEffectIndex eff_index = i_dynobject.GetEffIndex();
// Check target immune to spell or aura
if (target->IsImmunedToSpell(spellInfo) || target->IsImmunedToSpellEffect(spellInfo, eff_index))
return;
Expand Down
2 changes: 1 addition & 1 deletion src/game/Level3.cpp
Expand Up @@ -3603,7 +3603,7 @@ bool ChatHandler::HandleAuraCommand(const char* args)
eff == SPELL_EFFECT_APPLY_AURA ||
eff == SPELL_EFFECT_PERSISTENT_AREA_AURA )
{
Aura *Aur = CreateAura(spellInfo, i, NULL, target);
Aura *Aur = CreateAura(spellInfo, SpellEffectIndex(i), NULL, target);
target->AddAura(Aur);
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/game/ObjectMgr.cpp
Expand Up @@ -790,8 +790,8 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const*
for(uint32 j = 0; j < val.size()/2; ++j)
{
CreatureDataAddonAura& cAura = const_cast<CreatureDataAddonAura&>(addon->auras[i]);
cAura.spell_id = (uint32)val[2*j+0];
cAura.effect_idx = (uint32)val[2*j+1];
cAura.spell_id = uint32(val[2*j+0]);
cAura.effect_idx = SpellEffectIndex(val[2*j+1]);
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);
Expand Down Expand Up @@ -7386,7 +7386,7 @@ bool PlayerCondition::Meets(Player const * player) const
case CONDITION_NONE:
return true; // empty condition, always met
case CONDITION_AURA:
return player->HasAura(value1, value2);
return player->HasAura(value1, SpellEffectIndex(value2));
case CONDITION_ITEM:
return player->HasItemCount(value1, value2);
case CONDITION_ITEM_EQUIPPED:
Expand Down Expand Up @@ -7418,7 +7418,7 @@ bool PlayerCondition::Meets(Player const * player) const
return false;
}
case CONDITION_NO_AURA:
return !player->HasAura(value1, value2);
return !player->HasAura(value1, SpellEffectIndex(value2));
case CONDITION_ACTIVE_EVENT:
return sGameEventMgr.IsActiveEvent(value1);
case CONDITION_AREA_FLAG:
Expand Down Expand Up @@ -7467,9 +7467,9 @@ 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 > EFFECT_INDEX_2)
if(value2 >= MAX_EFFECT_INDEX)
{
sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2);
sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..%u), skipped", value2, MAX_EFFECT_INDEX-1);
return false;
}
break;
Expand Down Expand Up @@ -7571,9 +7571,9 @@ 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 > EFFECT_INDEX_2)
if(value2 > MAX_EFFECT_INDEX)
{
sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2);
sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..%u), skipped", value2, MAX_EFFECT_INDEX-1);
return false;
}
break;
Expand Down
4 changes: 2 additions & 2 deletions src/game/Pet.cpp
Expand Up @@ -1152,7 +1152,7 @@ void Pet::_LoadAuras(uint32 timediff)
Field *fields = result->Fetch();
uint64 caster_guid = fields[0].GetUInt64();
uint32 spellid = fields[1].GetUInt32();
uint32 effindex = fields[2].GetUInt32();
SpellEffectIndex effindex = SpellEffectIndex(fields[2].GetUInt32());
uint32 stackcount= fields[3].GetUInt32();
int32 damage = (int32)fields[4].GetUInt32();
int32 maxduration = (int32)fields[5].GetUInt32();
Expand Down Expand Up @@ -1194,7 +1194,7 @@ void Pet::_LoadAuras(uint32 timediff)
if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto))
continue;

for(uint32 i=0; i<stackcount; ++i)
for(uint32 i=0; i < stackcount; ++i)
{
Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL);

Expand Down
28 changes: 14 additions & 14 deletions src/game/Player.cpp
Expand Up @@ -274,7 +274,7 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi)
return ss;
}

SpellModifier::SpellModifier( SpellModOp _op, SpellModType _type, int32 _value, SpellEntry const* spellEntry, uint8 eff, int16 _charges /*= 0*/ ) : op(_op), type(_type), charges(_charges), value(_value), spellId(spellEntry->Id), lastAffected(NULL)
SpellModifier::SpellModifier( SpellModOp _op, SpellModType _type, int32 _value, SpellEntry const* spellEntry, SpellEffectIndex eff, int16 _charges /*= 0*/ ) : op(_op), type(_type), charges(_charges), value(_value), spellId(spellEntry->Id), lastAffected(NULL)
{
uint32 const* ptr = spellEntry->GetEffectSpellClassMask(eff);
mask = uint64(ptr[0]) | (uint64(ptr[1]) << 32);
Expand Down Expand Up @@ -3280,7 +3280,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo

// remove pet auras
for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
if(PetAura const* petSpell = sSpellMgr.GetPetAura(spell_id, i))
if(PetAura const* petSpell = sSpellMgr.GetPetAura(spell_id, SpellEffectIndex(i)))
RemovePetAura(petSpell);

// free talent points
Expand Down Expand Up @@ -4256,9 +4256,9 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
{
int32 delta = (int32(getLevel()) - startLevel + 1)*MINUTE;

for(int i =0; i < MAX_EFFECT_INDEX; ++i)
for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
{
if(Aura* Aur = GetAura(SPELL_ID_PASSIVE_RESURRECTION_SICKNESS,i))
if(Aura* Aur = GetAura(SPELL_ID_PASSIVE_RESURRECTION_SICKNESS,SpellEffectIndex(i)))
{
Aur->SetAuraDuration(delta*IN_MILISECONDS);
Aur->SendAuraUpdate(false);
Expand Down Expand Up @@ -7080,7 +7080,7 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply
bool found = false;
for (int k=0; k < MAX_EFFECT_INDEX; ++k)
{
spellEffectPair spair = spellEffectPair(spellInfo->Id, k);
spellEffectPair spair = spellEffectPair(spellInfo->Id, SpellEffectIndex(k));
for (AuraMap::const_iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair); ++iter)
{
if(!item || iter->second->GetCastItemGUID() == item->GetGUID())
Expand Down Expand Up @@ -15266,21 +15266,21 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
Field *fields = result->Fetch();
uint64 caster_guid = fields[0].GetUInt64();
uint32 spellid = fields[1].GetUInt32();
uint32 effindex = fields[2].GetUInt32();
SpellEffectIndex effindex = SpellEffectIndex(fields[2].GetUInt32());
uint32 stackcount = fields[3].GetUInt32();
int32 damage = fields[4].GetInt32();
int32 maxduration = fields[5].GetInt32();
int32 remaintime = fields[6].GetInt32();
int32 remaincharges = fields[7].GetInt32();

SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid);
if(!spellproto)
if (!spellproto)
{
sLog.outError("Unknown aura (spellid %u, effindex %u), ignore.",spellid,effindex);
continue;
}

if(effindex >= 3)
if (effindex >= MAX_EFFECT_INDEX)
{
sLog.outError("Invalid effect index (spellid %u, effindex %u), ignore.",spellid,effindex);
continue;
Expand All @@ -15296,19 +15296,19 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
}

// prevent wrong values of remaincharges
if(spellproto->procCharges)
if (spellproto->procCharges)
{
if(remaincharges <= 0 || remaincharges > (int32)spellproto->procCharges)
if (remaincharges <= 0 || remaincharges > (int32)spellproto->procCharges)
remaincharges = spellproto->procCharges;
}
else
remaincharges = 0;


for(uint32 i=0; i < stackcount; ++i)
for(uint32 i = 0; i < stackcount; ++i)
{
Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL);
if(!damage)
if (!damage)
damage = aura->GetModifier()->m_amount;

// reset stolen single target auras
Expand Down Expand Up @@ -19242,7 +19242,7 @@ void Player::SendAurasForTarget(Unit *target)
{
for(int j = 0; j < MAX_EFFECT_INDEX; ++j)
{
if(Aura *aura = target->GetAura(itr->second, j))
if(Aura *aura = target->GetAura(itr->second, SpellEffectIndex(j)))
{
data << uint8(aura->GetAuraSlot());
data << uint32(aura->GetId());
Expand Down Expand Up @@ -21535,7 +21535,7 @@ void Player::SendDuelCountdown(uint32 counter)
GetSession()->SendPacket(&data);
}

bool Player::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const
bool Player::IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const
{
switch(spellInfo->Effect[index])
{
Expand Down
4 changes: 2 additions & 2 deletions src/game/Player.h
Expand Up @@ -104,7 +104,7 @@ struct SpellModifier
: op(_op), type(_type), charges(_charges), value(_value), mask(_mask), mask2(_mask2), spellId(_spellId), lastAffected(NULL)
{}

SpellModifier(SpellModOp _op, SpellModType _type, int32 _value, SpellEntry const* spellEntry, uint8 eff, int16 _charges = 0);
SpellModifier(SpellModOp _op, SpellModType _type, int32 _value, SpellEntry const* spellEntry, SpellEffectIndex eff, int16 _charges = 0);

SpellModifier(SpellModOp _op, SpellModType _type, int32 _value, Aura const* aura, int16 _charges = 0);

Expand Down Expand Up @@ -1544,7 +1544,7 @@ class MANGOS_DLL_SPEC Player : public Unit
TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const;
bool IsSpellFitByClassAndRace( uint32 spell_id ) const;
bool IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const;
bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const;
bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const;

void SendProficiency(uint8 pr1, uint32 pr2);
void SendInitialSpells();
Expand Down

1 comment on commit 881a467

@tendonsie
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error on compile:

../../../src/game/DynamicObject.h.36: error: 'SpellEffectIndex' has not been declared

DynamicObject.h:40: does not name a type
DynamicObject.h.62: does not name a type

Please sign in to comment.