*Fix some crash when unit is removed.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-04-03 14:51:40 -06:00
parent 2bc033a328
commit c48ea87a03
2 changed files with 16 additions and 17 deletions
-3
View File
@@ -511,10 +511,7 @@ void Player::CleanupsBeforeDelete()
TradeCancel(false); TradeCancel(false);
DuelComplete(DUEL_INTERUPTED); DuelComplete(DUEL_INTERUPTED);
if(IsInWorld()) // only for fully created Object
{
Unit::CleanupsBeforeDelete(); Unit::CleanupsBeforeDelete();
}
if (m_transport) if (m_transport)
m_transport->RemovePassenger(this); m_transport->RemovePassenger(this);
+5 -3
View File
@@ -11323,8 +11323,10 @@ void Unit::RemoveFromWorld()
void Unit::CleanupsBeforeDelete() void Unit::CleanupsBeforeDelete()
{ {
if(IsInWorld()) // only for fully created object assert(m_uint32Values);
{
//A unit may be in removelist and not in world, but it is still in grid
//and may have some references during delete
RemoveAllAuras(); RemoveAllAuras();
InterruptNonMeleeSpells(true); InterruptNonMeleeSpells(true);
m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList
@@ -11336,9 +11338,9 @@ void Unit::CleanupsBeforeDelete()
RemoveAllDynObjects(); RemoveAllDynObjects();
GetMotionMaster()->Clear(false); // remove different non-standard movement generators. GetMotionMaster()->Clear(false); // remove different non-standard movement generators.
if(IsInWorld())
RemoveFromWorld(); RemoveFromWorld();
} }
}
void Unit::UpdateCharmAI() void Unit::UpdateCharmAI()
{ {