aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp27
-rw-r--r--src/server/game/Spells/SpellMgr.cpp6
2 files changed, 32 insertions, 1 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 91407436072..1ee6f4545c0 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -42,6 +42,7 @@
#include "Spell.h"
#include "SpellHistory.h"
#include "SpellMgr.h"
+#include "SpellScript.h"
#include "ThreatManager.h"
#include "Unit.h"
#include "Util.h"
@@ -935,6 +936,32 @@ void AuraEffect::CalculateSpellMod()
break;
}
GetBase()->CallScriptEffectCalcSpellModHandlers(this, m_spellmod);
+
+ // validate modifier
+ if (m_spellmod)
+ {
+ bool isValid = true;
+ auto logErrors = [&] { return std::ranges::any_of(GetBase()->m_loadedScripts, [](AuraScript const* script) { return script->DoEffectCalcSpellMod.size() > 0; }); };
+ if (AsUnderlyingType(m_spellmod->op) >= MAX_SPELLMOD)
+ {
+ isValid = false;
+ if (logErrors())
+ TC_LOG_ERROR("spells.aura.effect", "Aura script for spell id {} created invalid spell modifier op {}", GetId(), AsUnderlyingType(m_spellmod->op));
+ }
+
+ if (m_spellmod->type >= SPELLMOD_END)
+ {
+ isValid = false;
+ if (logErrors())
+ TC_LOG_ERROR("spells.aura.effect", "Aura script for spell id {} created invalid spell modifier type {}", GetId(), AsUnderlyingType(m_spellmod->type));
+ }
+
+ if (!isValid)
+ {
+ delete m_spellmod;
+ m_spellmod = nullptr;
+ }
+ }
}
void AuraEffect::ChangeAmount(int32 newAmount, bool mark, bool onStackOrReapply, AuraEffect const* triggeredBy /* = nullptr */)
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index cf9c3950316..c77febf47c2 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -2523,7 +2523,11 @@ void SpellMgr::LoadSpellInfoStore()
case SPELL_AURA_ADD_PCT_MODIFIER:
case SPELL_AURA_ADD_PCT_MODIFIER_BY_SPELL_LABEL:
case SPELL_AURA_ADD_FLAT_MODIFIER_BY_SPELL_LABEL:
- ASSERT(effect->EffectMiscValue[0] < MAX_SPELLMOD, "MAX_SPELLMOD must be at least %d", effect->EffectMiscValue[0] + 1);
+ if (effect->EffectMiscValue[0] >= MAX_SPELLMOD)
+ {
+ TC_LOG_ERROR("server.loading", "Invalid spell modifier type {} found on spell {} effect index {}, consider increasing MAX_SPELLMOD",
+ effect->EffectMiscValue[0], effect->SpellID, effect->EffectIndex);
+ }
break;
default:
break;