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

This commit is contained in:
Ovah
2020-09-15 14:49:18 +02:00
committed by GitHub
parent 39a436bd65
commit 0d152e932c

View File

@@ -3366,7 +3366,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->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED))
creatureCaster->SetInFront(ObjectAccessor::GetUnit(*creatureCaster, creatureCaster->GetTarget()));
if (WorldObject const* target = ObjectAccessor::GetUnit(*creatureCaster, creatureCaster->GetTarget()))
creatureCaster->SetInFront(target);
SelectSpellTargets();