Skip to content

Commit

Permalink
GOCasting: Fix crash due to updating pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Aug 17, 2021
1 parent 51ab47c commit ddbd35c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/game/Spells/Spell.cpp
Expand Up @@ -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<Unit*>(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;
}
}
Expand Down

0 comments on commit ddbd35c

Please sign in to comment.