From 9bb780793556fc82e45fd56a6f59c27d4050eb94 Mon Sep 17 00:00:00 2001 From: megamage Date: Sun, 22 Feb 2009 17:03:01 -0600 Subject: *Check IsInWorld() when calling GetMap() in RemoveFromWorld(). This may fix some crash bugs. --HG-- branch : trunk --- src/game/DynamicObject.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/game/DynamicObject.cpp') diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index 677a31b34de..12a9cd67500 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -52,15 +52,18 @@ void DynamicObject::AddToWorld() void DynamicObject::RemoveFromWorld() { - // Make sure the object is back to grid container for removal as farsight targets - // are switched to world container on creation and they are also set to active - if (isActive()) + ///- Remove the dynamicObject from the accessor + if(IsInWorld()) { - GetMap()->SwitchGridContainers(this, false); - setActive(false); + // Make sure the object is back to grid container for removal as farsight targets + // are switched to world container on creation and they are also set to active + if (isActive()) + { + GetMap()->SwitchGridContainers(this, false); + setActive(false); + } + ObjectAccessor::Instance().RemoveObject(this); } - ///- Remove the dynamicObject from the accessor - if(IsInWorld()) ObjectAccessor::Instance().RemoveObject(this); WorldObject::RemoveFromWorld(); } -- cgit v1.2.3