From a4c4db7af5a584a2d53c13b30499f360da054068 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 14 Jan 2021 17:06:53 -0500 Subject: [PATCH] Core/Spells: Fixed missing null checks on some SpellEffects --- Source/Game/Entities/Creature/Gossip.cs | 2 +- Source/Game/Spells/Spell.cs | 3 ++- Source/Game/Spells/SpellManager.cs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Game/Entities/Creature/Gossip.cs b/Source/Game/Entities/Creature/Gossip.cs index 6cd922556..c45079cfa 100644 --- a/Source/Game/Entities/Creature/Gossip.cs +++ b/Source/Game/Entities/Creature/Gossip.cs @@ -443,7 +443,7 @@ namespace Game.Misc if (spellInfo != null) { foreach (SpellEffectInfo effect in spellInfo.GetEffects()) - if (effect.IsEffect(SpellEffectName.LearnSpell)) + if (effect != null && effect.IsEffect(SpellEffectName.LearnSpell)) packet.LearnSpells.Add(effect.TriggerSpell); } diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 7a2309938..759d3a16f 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -3410,8 +3410,9 @@ namespace Game.Spells { uint item = 0; foreach (SpellEffectInfo effect in spellInfo.GetEffects()) - if (effect.ItemType != 0) + if (effect != null && effect.ItemType != 0) item = effect.ItemType; + ItemTemplate proto = Global.ObjectMgr.GetItemTemplate(item); if (proto != null && proto.GetItemLimitCategory() != 0) packet.FailedArg1 = (int)proto.GetItemLimitCategory(); diff --git a/Source/Game/Spells/SpellManager.cs b/Source/Game/Spells/SpellManager.cs index afc03f93e..b19f56e6f 100644 --- a/Source/Game/Spells/SpellManager.cs +++ b/Source/Game/Spells/SpellManager.cs @@ -1248,7 +1248,7 @@ namespace Game.Entities SpellInfo spellInfo = GetSpellInfo(spellId, Difficulty.None); foreach (SpellEffectInfo effectInfo in spellInfo.GetEffects()) { - if (!effectInfo.IsAura()) + if (effectInfo == null || !effectInfo.IsAura()) continue; AuraType auraName = effectInfo.ApplyAuraName;