diff options
author | Shauren <shauren.trinity@gmail.com> | 2025-01-09 17:48:41 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2025-01-09 17:48:41 +0100 |
commit | 561b122364525deaee815ad900a78f1323c37776 (patch) | |
tree | 162a91f6740c225fa9970ee3aa477af559c352d5 /src/server/game/Spells/Auras | |
parent | 97f58a59f13fcf3a8a6675215674fb89b1a136ca (diff) |
Core/Spells: Replace MAX_SPELL_EFFECTS loop limits with correct upper bound depending on how many effects the spell has
Diffstat (limited to 'src/server/game/Spells/Auras')
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuras.cpp | 27 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 5425afe4bc3..2a474f4a6c4 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -5582,7 +5582,7 @@ void AuraEffect::HandlePeriodicTriggerSpellWithValueAuraTick(Unit* target, Unit* { CastSpellExtraArgs args(this); args.SetTriggerFlags(TRIGGERED_FULL_MASK & ~(TRIGGERED_IGNORE_POWER_COST | TRIGGERED_IGNORE_REAGENT_COST)); - for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) + for (std::size_t i = 0; i < triggeredSpellInfo->GetEffects().size(); ++i) args.AddSpellMod(SpellValueMod(SPELLVALUE_BASE_POINT0 + i), GetAmount()); triggerCaster->CastSpell(target, triggerSpellId, args); TC_LOG_DEBUG("spells.aura.effect", "AuraEffect::HandlePeriodicTriggerSpellWithValueAuraTick: Spell {} Trigger {}", GetId(), triggeredSpellInfo->Id); diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 90cb347b578..1fce448a566 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -200,14 +200,14 @@ void AuraApplication::UpdateApplyEffectMask(uint32 newEffMask, bool canHandleNew } // update real effects only if they were applied already - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + for (std::size_t i = 0; i < GetBase()->GetAuraEffectCount(); ++i) if (HasEffect(i) && (removeEffMask & (1 << i))) _HandleEffect(i, false); _effectsToApply = newEffMask; if (canHandleNewEffects) - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + for (std::size_t i = 0; i < GetBase()->GetAuraEffectCount(); ++i) if (addEffMask & (1 << i)) _HandleEffect(i, true); } @@ -507,6 +507,9 @@ void Aura::_InitEffects(uint32 effMask, Unit* caster, int32 const* baseAmount) for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects()) if (effMask & (1 << spellEffectInfo.EffectIndex)) _effects[spellEffectInfo.EffectIndex] = new AuraEffect(this, spellEffectInfo, baseAmount ? baseAmount + spellEffectInfo.EffectIndex : nullptr, caster); + + while (!_effects.back()) + _effects.pop_back(); } Aura::~Aura() @@ -940,9 +943,8 @@ void Aura::RefreshDuration(bool withMods) m_timeCla = 1 * IN_MILLISECONDS; // also reset periodic counters - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (AuraEffect* aurEff = GetEffect(i)) - aurEff->ResetTicks(); + for (AuraEffect* aurEff : GetAuraEffects()) + aurEff->ResetTicks(); } void Aura::RefreshTimers(bool resetPeriodicTimer) @@ -962,9 +964,8 @@ void Aura::RefreshTimers(bool resetPeriodicTimer) RefreshDuration(); Unit* caster = GetCaster(); - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (AuraEffect* aurEff = GetEffect(i)) - aurEff->CalculatePeriodic(caster, resetPeriodicTimer, false); + for (AuraEffect* aurEff : GetAuraEffects()) + aurEff->CalculatePeriodic(caster, resetPeriodicTimer, false); } void Aura::SetCharges(uint8 charges) @@ -1886,10 +1887,10 @@ uint32 Aura::GetProcEffectMask(AuraApplication* aurApp, ProcEventInfo& eventInfo // At least one effect has to pass checks to proc aura uint32 procEffectMask = aurApp->GetEffectMask(); - for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (procEffectMask & (1u << i)) - if ((procEntry->DisableEffectsMask & (1u << i)) || !GetEffect(i)->CheckEffectProc(aurApp, eventInfo)) - procEffectMask &= ~(1u << i); + for (AuraEffect const* aurEff : GetAuraEffects()) + if (procEffectMask & (1u << aurEff->GetEffIndex())) + if ((procEntry->DisableEffectsMask & (1u << aurEff->GetEffIndex())) || !aurEff->CheckEffectProc(aurApp, eventInfo)) + procEffectMask &= ~(1u << aurEff->GetEffIndex()); if (!procEffectMask) return 0; @@ -1990,7 +1991,7 @@ void Aura::TriggerProcOnEvent(uint32 procEffectMask, AuraApplication* aurApp, Pr bool prevented = CallScriptProcHandlers(aurApp, eventInfo); if (!prevented) { - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + for (std::size_t i = 0; i < GetAuraEffectCount(); ++i) { if (!(procEffectMask & (1 << i))) continue; |