From ddbd35ce47156780e560af3c6de9f05280a78a8a Mon Sep 17 00:00:00 2001 From: killerwife Date: Tue, 17 Aug 2021 17:04:42 +0200 Subject: [PATCH] GOCasting: Fix crash due to updating pointer Closes https://github.com/cmangos/issues/issues/2516 --- src/game/Spells/Spell.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp index c542a1da759..d12623e7fc9 100644 --- a/src/game/Spells/Spell.cpp +++ b/src/game/Spells/Spell.cpp @@ -7801,16 +7801,16 @@ void Spell::DelayedChannel() void Spell::UpdateOriginalCasterPointer() { - if (m_originalCasterGUID == m_caster->GetObjectGuid()) - m_originalCaster = m_caster; + if (m_originalCasterGUID == m_trueCaster->GetObjectGuid() && m_trueCaster->IsUnit()) + m_originalCaster = static_cast(m_trueCaster); else if (m_originalCasterGUID.IsGameObject()) { - GameObject* go = m_caster->IsInWorld() ? m_caster->GetMap()->GetGameObject(m_originalCasterGUID) : nullptr; + GameObject* go = m_trueCaster->IsInWorld() ? m_trueCaster->GetMap()->GetGameObject(m_originalCasterGUID) : nullptr; m_originalCaster = go ? go->GetOwner() : nullptr; } else { - Unit* unit = ObjectAccessor::GetUnit(*m_caster, m_originalCasterGUID); + Unit* unit = ObjectAccessor::GetUnit(*m_trueCaster, m_originalCasterGUID); m_originalCaster = unit && unit->IsInWorld() ? unit : nullptr; } }