Fix Spell::m_selfContainer not reset in destructor. This should fix crash in Unit::FindCurrentSpellBySpellId.

Fixes issue #2263.

--HG--
branch : trunk
This commit is contained in:
Trazom62
2010-05-31 19:19:30 +02:00
parent 15847b2f2f
commit 427e8be656
+8
View File
@@ -445,6 +445,14 @@ Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 origin
Spell::~Spell() Spell::~Spell()
{ {
if (m_referencedFromCurrentSpell && m_selfContainer && *m_selfContainer == this)
{
// Clean the reference to avoid later crash.
// If this error is repeating, we may have to add an assert to better track down how we get into this case.
sLog.outError("SPELL: deleting spell for spell ID %u. However, spell still referenced.", m_spellInfo->Id);
*m_selfContainer = NULL;
}
if (m_caster && m_caster->GetTypeId() == TYPEID_PLAYER) if (m_caster && m_caster->GetTypeId() == TYPEID_PLAYER)
assert(m_caster->ToPlayer()->m_spellModTakingSpell != this); assert(m_caster->ToPlayer()->m_spellModTakingSpell != this);
delete m_spellValue; delete m_spellValue;