diff options
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 70b334b3c3c..f1d8269cd65 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -237,9 +237,11 @@ Unit::~Unit() // set current spells as deletable for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) { - // spell may be safely deleted now - if (m_currentSpells[i]) m_currentSpells[i]->SetDeletable(true); - m_currentSpells[i] = NULL; + if (m_currentSpells[i]) + { + m_currentSpells[i]->SetReferencedFromCurrent(false); + m_currentSpells[i] = NULL; + } } RemoveAllGameObjects(); @@ -3163,7 +3165,7 @@ void Unit::_UpdateSpells( uint32 time ) { if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED) { - m_currentSpells[i]->SetDeletable(true); // spell may be safely deleted now + m_currentSpells[i]->SetReferencedFromCurrent(false); m_currentSpells[i] = NULL; // remove pointer } } @@ -3276,7 +3278,6 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell ) uint32 CSpellType = pSpell->GetCurrentContainer(); - pSpell->SetDeletable(false); // spell will not be deleted until gone from current pointers if (pSpell == m_currentSpells[CSpellType]) return; // avoid breaking self // break same type spell if it is not delayed @@ -3333,10 +3334,11 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell ) // current spell (if it is still here) may be safely deleted now if (m_currentSpells[CSpellType]) - m_currentSpells[CSpellType]->SetDeletable(true); + m_currentSpells[CSpellType]->SetReferencedFromCurrent(false); // set new current spell m_currentSpells[CSpellType] = pSpell; + pSpell->SetReferencedFromCurrent(true); } void Unit::InterruptSpell(uint32 spellType, bool withDelayed) @@ -3354,7 +3356,7 @@ void Unit::InterruptSpell(uint32 spellType, bool withDelayed) if (m_currentSpells[spellType]->getState() != SPELL_STATE_FINISHED) m_currentSpells[spellType]->cancel(); - m_currentSpells[spellType]->SetDeletable(true); + m_currentSpells[spellType]->SetReferencedFromCurrent(false); m_currentSpells[spellType] = NULL; } } @@ -3390,7 +3392,7 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id) if ( (m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) && (withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED) ) m_currentSpells[CURRENT_GENERIC_SPELL]->cancel(); - m_currentSpells[CURRENT_GENERIC_SPELL]->SetDeletable(true); + m_currentSpells[CURRENT_GENERIC_SPELL]->SetReferencedFromCurrent(false); m_currentSpells[CURRENT_GENERIC_SPELL] = NULL; } @@ -3404,7 +3406,7 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id) if ( (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_FINISHED) && (withDelayed || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_DELAYED) ) m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->cancel(); - m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->SetDeletable(true); + m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->SetReferencedFromCurrent(false); m_currentSpells[CURRENT_AUTOREPEAT_SPELL] = NULL; } @@ -3413,7 +3415,7 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id) { if (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED) m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel(); - m_currentSpells[CURRENT_CHANNELED_SPELL]->SetDeletable(true); + m_currentSpells[CURRENT_CHANNELED_SPELL]->SetReferencedFromCurrent(false); m_currentSpells[CURRENT_CHANNELED_SPELL] = NULL; } } @@ -9860,7 +9862,7 @@ void Unit::CleanupsBeforeDelete() if(m_uint32Values) // only for fully created object { InterruptNonMeleeSpells(true); - m_Events.KillAllEvents(); + m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted ans will deleated at call in Map::RemoveAllObjectsInRemoveList CombatStop(); ClearComboPointHolders(); DeleteThreatList(); |