Core/Spells: Replaced assert with startup error log
Port From (https://github.com/TrinityCore/TrinityCore/commit/8043b71708e2efd380c7a1f6a738a1e9e497706d)
This commit is contained in:
@@ -2675,6 +2675,8 @@ namespace Game.Spells
|
||||
return aura;
|
||||
}
|
||||
|
||||
public List<AuraScript> GetLoadedScripts() { return m_loadedScripts; }
|
||||
|
||||
#region Fields
|
||||
List<AuraScript> m_loadedScripts = new();
|
||||
SpellInfo m_spellInfo;
|
||||
|
||||
@@ -334,6 +334,29 @@ namespace Game.Spells
|
||||
break;
|
||||
}
|
||||
GetBase().CallScriptEffectCalcSpellModHandlers(this, ref m_spellmod);
|
||||
|
||||
// validate modifier
|
||||
if (m_spellmod != null)
|
||||
{
|
||||
bool isValid = true;
|
||||
bool logErrors = GetBase().GetLoadedScripts().Any(script => script.DoEffectCalcSpellMod.Count > 0);
|
||||
if (m_spellmod.op >= SpellModOp.Max)
|
||||
{
|
||||
isValid = false;
|
||||
if (logErrors)
|
||||
Log.outError(LogFilter.Spells, $"Aura script for spell id {GetId()} created invalid spell modifier op {m_spellmod.op}");
|
||||
}
|
||||
|
||||
if (m_spellmod.type >= SpellModType.End)
|
||||
{
|
||||
isValid = false;
|
||||
if (logErrors)
|
||||
Log.outError(LogFilter.Spells, $"Aura script for spell id {GetId()} created invalid spell modifier type {m_spellmod.type}");
|
||||
}
|
||||
|
||||
if (!isValid)
|
||||
m_spellmod = null;
|
||||
}
|
||||
}
|
||||
public void ChangeAmount(int newAmount, bool mark = true, bool onStackOrReapply = false, AuraEffect triggeredBy = null)
|
||||
{
|
||||
|
||||
@@ -2222,6 +2222,8 @@ namespace Game.Entities
|
||||
case AuraType.AddPctModifierBySpellLabel:
|
||||
case AuraType.AddFlatModifierBySpellLabel:
|
||||
Cypher.Assert(effect.EffectMiscValue[0] < (int)SpellModOp.Max, $"MAX_SPELLMOD must be at least {effect.EffectMiscValue[0] + 1}");
|
||||
if (effect.EffectMiscValue[0] >= (int)SpellModOp.Max)
|
||||
Log.outError(LogFilter.ServerLoading, $"Invalid spell modifier type {effect.EffectMiscValue[0]} found on spell {effect.SpellID} effect index {effect.EffectIndex}, consider increasing MAX_SPELLMOD");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user