From b048b57f4623e6e19da24726f17c584e8bdb6f3c Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 4 May 2022 10:04:12 -0400 Subject: [PATCH] Core/Spells: fix a possible crash when a target that has been focused during spell casts disappears Port From (https://github.com/TrinityCore/TrinityCore/commit/f70161dcc5af3c2c958d4df559b77ace735fc7d4) --- Source/Game/Spells/Spell.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 3a43ca621..adac60ac2 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -2728,8 +2728,14 @@ namespace Game.Spells // The spell focusing is making sure that we have a valid cast target guid when we need it so only check for a guid value here. Creature creatureCaster = m_caster.ToCreature(); if (creatureCaster != null) + { if (!creatureCaster.GetTarget().IsEmpty() && !creatureCaster.HasUnitFlag(UnitFlags.Possessed)) - creatureCaster.SetInFront(Global.ObjAccessor.GetUnit(creatureCaster, creatureCaster.GetTarget())); + { + WorldObject target = Global.ObjAccessor.GetUnit(creatureCaster, creatureCaster.GetTarget()); + if (target != null) + creatureCaster.SetInFront(target); + } + } SelectSpellTargets();