From 0b1f2fe34efb29f0abe53ec91fac1ffe21879710 Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Mon, 5 Aug 2024 22:24:00 -0400 Subject: [PATCH] Core/Conditions: Added startup error log for conditions using invalid effect index on CONDITION_AURA Port From (https://github.com/TrinityCore/TrinityCore/commit/325cfd047d7846c68335465acff0c6a86e1493de) --- Source/Game/Conditions/ConditionManager.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Source/Game/Conditions/ConditionManager.cs b/Source/Game/Conditions/ConditionManager.cs index 87484f915..d260525a6 100644 --- a/Source/Game/Conditions/ConditionManager.cs +++ b/Source/Game/Conditions/ConditionManager.cs @@ -1233,15 +1233,22 @@ namespace Game { case ConditionTypes.Aura: { - if (!Global.SpellMgr.HasSpellInfo(cond.ConditionValue1, Difficulty.None)) + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(cond.ConditionValue1, Difficulty.None); + if (spellInfo == null) { - Log.outError(LogFilter.Sql, "{0} has non existing spell (Id: {1}), skipped", cond.ToString(), cond.ConditionValue1); + Log.outError(LogFilter.Sql, "{0} has non existing spell (Id: {1}), skipped", cond.ToString(true), cond.ConditionValue1); return false; } - if (cond.ConditionValue2 >= SpellConst.MaxEffects) + if (cond.ConditionValue2 >= spellInfo.GetEffects().Count) { - Log.outError(LogFilter.Sql, $"{cond.ToString(true)} has non existing effect index ({cond.ConditionValue2}) (must be 0..{SpellConst.MaxEffects - 1}), skipped"); + Log.outError(LogFilter.Sql, $"{cond.ToString(true)} spell {cond.ConditionValue1} has non existing effect index ({cond.ConditionValue2}) (must be 0..{spellInfo.GetEffects().Count - 1}), skipped."); + return false; + } + + if (!spellInfo.GetEffect(cond.ConditionValue2).IsAura()) + { + Log.outError(LogFilter.Sql, $"{cond.ToString(true)} spell {cond.ConditionValue1} effect index {cond.ConditionValue2} is not an aura, skipped."); return false; } break;