Core/Spells: fix a possible crash when a target that has been focused during spell casts disappears

(cherry picked from commit 0d152e932c)
This commit is contained in:
Ovah
2020-09-15 14:49:18 +02:00
committed by Shauren
parent c295cb9814
commit f70161dcc5

View File

@@ -3552,7 +3552,8 @@ void Spell::_cast(bool skipCheck)
// 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.
if (Creature* creatureCaster = m_caster->ToCreature())
if (!creatureCaster->GetTarget().IsEmpty() && !creatureCaster->HasUnitFlag(UNIT_FLAG_POSSESSED))
creatureCaster->SetInFront(ObjectAccessor::GetUnit(*creatureCaster, creatureCaster->GetTarget()));
if (WorldObject const* target = ObjectAccessor::GetUnit(*creatureCaster, creatureCaster->GetTarget()))
creatureCaster->SetInFront(target);
SelectSpellTargets();