From 216d32e8a76b65fb8d661d7e5a200edd637b8dd9 Mon Sep 17 00:00:00 2001 From: QAston Date: Fri, 22 Jan 2010 20:03:47 +0100 Subject: [PATCH] *Prevent assertion fail in Unit::_AddAura after creature add to remove list. --HG-- branch : trunk --- src/game/GameObject.cpp | 2 +- src/game/GameObject.h | 2 +- src/game/Map.cpp | 2 +- src/game/Object.cpp | 2 +- src/game/Object.h | 2 +- src/game/Player.cpp | 4 ++-- src/game/Player.h | 2 +- src/game/Unit.cpp | 7 +++++-- src/game/Unit.h | 2 +- 9 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 23b79a3de1b..5d6f730a045 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -71,7 +71,7 @@ GameObject::~GameObject() // CleanupsBeforeDelete(); } -void GameObject::CleanupsBeforeDelete() +void GameObject::CleanupsBeforeDelete(bool finalCleanup) { if(m_uint32Values) // field array can be not exist if GameOBject not loaded { diff --git a/src/game/GameObject.h b/src/game/GameObject.h index 3d6d94e3596..dd0b3508b36 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -589,7 +589,7 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject, public GridObjectGetMapId()==GetId() && obj->GetInstanceId()==GetInstanceId()); - obj->CleanupsBeforeDelete(); // remove or simplify at least cross referenced links + obj->CleanupsBeforeDelete(false); // remove or simplify at least cross referenced links i_objectsToRemove.insert(obj); //sLog.outDebug("Object (GUID: %u TypeId: %u ) added to removing list.",obj->GetGUIDLow(),obj->GetTypeId()); diff --git a/src/game/Object.cpp b/src/game/Object.cpp index eeb96db5798..7433113f051 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1165,7 +1165,7 @@ void WorldObject::setActive( bool on ) } } -void WorldObject::CleanupsBeforeDelete() +void WorldObject::CleanupsBeforeDelete(bool finalCleanup) { } diff --git a/src/game/Object.h b/src/game/Object.h index aea0216e688..b97fd4798ff 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -571,7 +571,7 @@ class TRINITY_DLL_SPEC WorldObject : public Object, public WorldLocation bool IsInBetween(const WorldObject *obj1, const WorldObject *obj2, float size = 0) const; - virtual void CleanupsBeforeDelete(); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units + virtual void CleanupsBeforeDelete(bool finalCleanup = true); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units virtual void SendMessageToSet(WorldPacket *data, bool self); virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index b6e996f050c..4e23b0c1e50 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -542,12 +542,12 @@ Player::~Player () sWorld.DecreasePlayerCount(); } -void Player::CleanupsBeforeDelete() +void Player::CleanupsBeforeDelete(bool finalCleanup) { TradeCancel(false); DuelComplete(DUEL_INTERUPTED); - Unit::CleanupsBeforeDelete(); + Unit::CleanupsBeforeDelete(finalCleanup); if (m_transport) m_transport->RemovePassenger(this); diff --git a/src/game/Player.h b/src/game/Player.h index 3781df95a89..4f3728de1a6 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -970,7 +970,7 @@ class TRINITY_DLL_SPEC Player : public Unit, public GridObject explicit Player (WorldSession *session); ~Player ( ); - void CleanupsBeforeDelete(); + void CleanupsBeforeDelete(bool finalCleanup = true); static UpdateMask updateVisualBits; static void InitVisibleBits(); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 026ff352445..adb5dceb85c 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -12961,7 +12961,7 @@ void Unit::RemoveFromWorld() } } -void Unit::CleanupsBeforeDelete() +void Unit::CleanupsBeforeDelete(bool finalCleanup) { if (IsInWorld()) RemoveFromWorld(); @@ -12971,7 +12971,10 @@ void Unit::CleanupsBeforeDelete() //A unit may be in removelist and not in world, but it is still in grid //and may have some references during delete RemoveAllAuras(); - m_cleanupDone = true; + + if (finalCleanup) + m_cleanupDone = 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 CombatStop(); diff --git a/src/game/Unit.h b/src/game/Unit.h index a0614298484..5ff61195cc4 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1101,7 +1101,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void AddToWorld(); void RemoveFromWorld(); - void CleanupsBeforeDelete(); // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units) + void CleanupsBeforeDelete(bool finalCleanup = true); // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units) DiminishingLevels GetDiminishing(DiminishingGroup group); void IncrDiminishing(DiminishingGroup group);