mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 18:36:31 +01:00
Core/Entities: fix crash
- m_currentSpells and spell would be different in case cancelation of a channeled spell would remove the aura, and aura scripted to cast another channeled spell on remove
- In the above situation, we would lose reference of currentSpell and remove reference from wrong one, this was fixed by clearing the pointer before spell cancelation.
Closes #20172
(cherry picked from commit 5e284d4b38)
This commit is contained in:
@@ -3093,14 +3093,15 @@ void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool wi
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
ToPlayer()->SendAutoRepeatCancel(this);
|
||||
|
||||
m_currentSpells[spellType] = nullptr;
|
||||
|
||||
if (spell->getState() != SPELL_STATE_FINISHED)
|
||||
spell->cancel();
|
||||
else
|
||||
spell->SetReferencedFromCurrent(false);
|
||||
|
||||
if (GetTypeId() == TYPEID_UNIT && IsAIEnabled)
|
||||
ToCreature()->AI()->OnSpellCastInterrupt(spell->GetSpellInfo());
|
||||
|
||||
m_currentSpells[spellType] = nullptr;
|
||||
spell->SetReferencedFromCurrent(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3372,13 +3372,15 @@ void Spell::_cast(bool skipCheck)
|
||||
|
||||
CallScriptAfterCastHandlers();
|
||||
|
||||
if (const std::vector<int32> *spell_triggered = sSpellMgr->GetSpellLinked(m_spellInfo->Id))
|
||||
if (std::vector<int32> const* spell_triggered = sSpellMgr->GetSpellLinked(m_spellInfo->Id))
|
||||
{
|
||||
for (std::vector<int32>::const_iterator i = spell_triggered->begin(); i != spell_triggered->end(); ++i)
|
||||
if (*i < 0)
|
||||
m_caster->RemoveAurasDueToSpell(-(*i));
|
||||
for (int32 id : *spell_triggered)
|
||||
{
|
||||
if (id < 0)
|
||||
m_caster->RemoveAurasDueToSpell(-id);
|
||||
else
|
||||
m_caster->CastSpell(m_targets.GetUnitTarget() ? m_targets.GetUnitTarget() : m_caster, *i, true);
|
||||
m_caster->CastSpell(m_targets.GetUnitTarget() ? m_targets.GetUnitTarget() : m_caster, id, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (modOwner)
|
||||
|
||||
Reference in New Issue
Block a user