Core/Auras: Remove m_effIndex member of AuraEffect and always take it from SpellEffectInfo

This commit is contained in:
Shauren
2021-03-11 10:32:03 +01:00
parent f4ff0489ca
commit efdca47aff
11 changed files with 27 additions and 31 deletions

View File

@@ -574,12 +574,11 @@ NonDefaultConstructible<pAuraEffectHandler> AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleNULL, //503 SPELL_AURA_MOD_VERSATILITY_HEALING_DONE_BENEFIT
};
AuraEffect::AuraEffect(Aura* base, uint32 effIndex, int32 *baseAmount, Unit* caster) :
m_base(base), m_spellInfo(base->GetSpellInfo()),
_effectInfo(m_spellInfo->GetEffect(effIndex)),
m_baseAmount(baseAmount ? *baseAmount : _effectInfo->CalcBaseValue(caster, base->GetType() == UNIT_AURA_TYPE ? base->GetOwner()->ToUnit() : nullptr, base->GetCastItemId(), base->GetCastItemLevel())),
AuraEffect::AuraEffect(Aura* base, SpellEffectInfo const* spellEfffectInfo, int32 *baseAmount, Unit* caster) :
m_base(base), m_spellInfo(base->GetSpellInfo()), m_effectInfo(spellEfffectInfo), m_spellmod(nullptr),
m_baseAmount(baseAmount ? *baseAmount : spellEfffectInfo->CalcBaseValue(caster, base->GetType() == UNIT_AURA_TYPE ? base->GetOwner()->ToUnit() : nullptr, base->GetCastItemId(), base->GetCastItemLevel())),
m_damage(0), m_critChance(0.0f), m_donePct(1.0f),
m_spellmod(nullptr), m_periodicTimer(0), m_tickNumber(0), m_effIndex(effIndex),
m_periodicTimer(0), m_tickNumber(0),
m_canBeRecalculated(true), m_isPeriodic(false)
{
CalculatePeriodic(caster, true, false);
@@ -4465,7 +4464,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
// pet auras
if (target->GetTypeId() == TYPEID_PLAYER && (mode & AURA_EFFECT_HANDLE_REAL))
{
if (PetAura const* petSpell = sSpellMgr->GetPetAura(GetId(), m_effIndex))
if (PetAura const* petSpell = sSpellMgr->GetPetAura(GetId(), GetEffIndex()))
{
if (apply)
target->ToPlayer()->AddPetAura(petSpell);
@@ -5766,7 +5765,7 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
bool AuraEffect::IsAreaAuraEffect() const
{
return _effectInfo->IsAreaAuraEffect();
return GetSpellEffectInfo()->IsAreaAuraEffect();
}
void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) const
@@ -6267,9 +6266,9 @@ void AuraEffect::HandleShowConfirmationPrompt(AuraApplication const* aurApp, uin
return;
if (apply)
player->AddTemporarySpell(_effectInfo->TriggerSpell);
player->AddTemporarySpell(GetSpellEffectInfo()->TriggerSpell);
else
player->RemoveTemporarySpell(_effectInfo->TriggerSpell);
player->RemoveTemporarySpell(GetSpellEffectInfo()->TriggerSpell);
}
void AuraEffect::HandleOverridePetSpecs(AuraApplication const* aurApp, uint8 mode, bool apply) const

View File

@@ -34,7 +34,7 @@ class TC_GAME_API AuraEffect
public:
~AuraEffect();
AuraEffect(Aura* base, uint32 effIndex, int32 *baseAmount, Unit* caster);
AuraEffect(Aura* base, SpellEffectInfo const* spellEfffectInfo, int32 *baseAmount, Unit* caster);
Unit* GetCaster() const { return GetBase()->GetCaster(); }
ObjectGuid GetCasterGUID() const { return GetBase()->GetCasterGUID(); }
Aura* GetBase() const { return m_base; }
@@ -47,7 +47,7 @@ class TC_GAME_API AuraEffect
SpellInfo const* GetSpellInfo() const { return m_spellInfo; }
uint32 GetId() const { return m_spellInfo->Id; }
uint32 GetEffIndex() const { return m_effIndex; }
uint32 GetEffIndex() const { return m_effectInfo->EffectIndex; }
int32 GetBaseAmount() const { return m_baseAmount; }
int32 GetPeriod() const { return m_period; }
@@ -100,31 +100,30 @@ class TC_GAME_API AuraEffect
// add/remove SPELL_AURA_MOD_SHAPESHIFT (36) linked auras
void HandleShapeshiftBoosts(Unit* target, bool apply) const;
SpellEffectInfo const* GetSpellEffectInfo() const { return _effectInfo; }
SpellEffectInfo const* GetSpellEffectInfo() const { return m_effectInfo; }
bool IsEffect() const { return _effectInfo->Effect != 0; }
bool IsEffect(SpellEffectName effectName) const { return _effectInfo->Effect == uint32(effectName); }
bool IsEffect() const { return m_effectInfo->Effect != 0; }
bool IsEffect(SpellEffectName effectName) const { return m_effectInfo->Effect == uint32(effectName); }
bool IsAreaAuraEffect() const;
private:
Aura* const m_base;
SpellInfo const* const m_spellInfo;
SpellEffectInfo const* _effectInfo;
int32 const m_baseAmount;
SpellEffectInfo const* m_effectInfo;
SpellModifier* m_spellmod;
int32 const m_baseAmount;
int32 m_amount;
int32 m_damage;
float m_critChance;
float m_donePct;
SpellModifier* m_spellmod;
int32 m_periodicTimer;
int32 m_period;
uint32 m_tickNumber;
uint8 const m_effIndex;
bool m_canBeRecalculated;
bool m_isPeriodic;

View File

@@ -382,10 +382,8 @@ void Aura::_InitEffects(uint32 effMask, Unit* caster, int32 *baseAmount)
_effects.resize(GetSpellInfo()->GetEffects().size());
for (SpellEffectInfo const* effect : GetSpellInfo()->GetEffects())
{
if (effect && effMask & (1 << effect->EffectIndex))
_effects[effect->EffectIndex] = new AuraEffect(this, effect->EffectIndex, baseAmount ? baseAmount + effect->EffectIndex : nullptr, caster);
}
_effects[effect->EffectIndex] = new AuraEffect(this, effect, baseAmount ? baseAmount + effect->EffectIndex : nullptr, caster);
}
Aura::~Aura()

View File

@@ -5950,7 +5950,7 @@ SpellCastResult Spell::CheckCasterAuras(uint32* param1) const
// fill up aura mechanic info to send client proper error message
if (param1)
{
*param1 = aurEff->GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->Mechanic;
*param1 = aurEff->GetSpellEffectInfo()->Mechanic;
if (!*param1)
*param1 = aurEff->GetSpellInfo()->Mechanic;
}

View File

@@ -1512,7 +1512,7 @@ class spell_halion_combustion_consumption_periodic : public SpellScriptLoader
if (!caster)
return;
uint32 triggerSpell = GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell;
uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell;
int32 radius = caster->GetObjectScale() * M_PI * 10000 / 3;
caster->CastCustomSpell(triggerSpell, SPELLVALUE_RADIUS_MOD, radius, nullptr, TRIGGERED_FULL_MASK, nullptr, aurEff, caster->GetGUID());

View File

@@ -1308,7 +1308,7 @@ class spell_putricide_mutated_plague : public SpellScriptLoader
if (!caster)
return;
uint32 triggerSpell = GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell;
uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell;
SpellInfo const* spell = sSpellMgr->AssertSpellInfo(triggerSpell, GetCastDifficulty());
int32 damage = spell->GetEffect(EFFECT_0)->CalcValue(caster);

View File

@@ -201,7 +201,7 @@ class spell_grobbulus_poison_cloud : public SpellScriptLoader
{
PreventDefaultAction();
uint32 triggerSpell = GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell;
uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell;
int32 mod = int32(((float(aurEff->GetTickNumber()) / aurEff->GetTotalTicks()) * 0.9f + 0.1f) * 10000 * 2 / 3);
GetTarget()->CastCustomSpell(triggerSpell, SPELLVALUE_RADIUS_MOD, mod, nullptr, TRIGGERED_FULL_MASK, nullptr, aurEff);
}

View File

@@ -269,7 +269,7 @@ class spell_mother_shahraz_saber_lash : public AuraScript
{
PreventDefaultAction();
uint32 triggerSpell = GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell;
uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell;
if (Unit* target = GetUnitOwner()->GetAI()->SelectTarget(SELECT_TARGET_RANDOM, 0))
GetUnitOwner()->CastSpell(target, triggerSpell, true);
}
@@ -297,7 +297,7 @@ class spell_mother_shahraz_generic_periodic : public AuraScript
{
PreventDefaultAction();
uint32 triggerSpell = GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell;
uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell;
if (Unit* target = GetUnitOwner()->GetAI()->SelectTarget(SELECT_TARGET_RANDOM, 0))
GetUnitOwner()->CastSpell(target, triggerSpell, true);
}

View File

@@ -179,7 +179,7 @@ class spell_broggok_poison_cloud : public SpellScriptLoader
{
PreventDefaultAction();
uint32 triggerSpell = GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell;
uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell;
int32 mod = int32(((float(aurEff->GetTickNumber()) / aurEff->GetTotalTicks()) * 0.9f + 0.1f) * 10000 * 2 / 3);
GetTarget()->CastCustomSpell(triggerSpell, SPELLVALUE_RADIUS_MOD, mod, nullptr, TRIGGERED_FULL_MASK, nullptr, aurEff);
}

View File

@@ -519,7 +519,7 @@ public:
spellMod->op = SPELLMOD_DOT;
spellMod->type = SPELLMOD_FLAT;
spellMod->spellId = GetId();
spellMod->mask = GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->SpellClassMask;
spellMod->mask = aurEff->GetSpellEffectInfo()->SpellClassMask;
}
spellMod->value = aurEff->GetAmount() / 7;
}

View File

@@ -2215,7 +2215,7 @@ class spell_q12619_emblazon_runeblade : public SpellScriptLoader
{
PreventDefaultAction();
if (Unit* caster = GetCaster())
caster->CastSpell(caster, GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell, true, nullptr, aurEff);
caster->CastSpell(caster, aurEff->GetSpellEffectInfo()->TriggerSpell, true, nullptr, aurEff);
}
void Register() override