*Check IsInWorld() when calling GetMap() in RemoveFromWorld(). This may fix some crash bugs.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-02-22 17:03:01 -06:00
parent c9707d3c7f
commit 9bb7807935
2 changed files with 12 additions and 9 deletions
+5 -2
View File
@@ -51,6 +51,9 @@ void DynamicObject::AddToWorld()
} }
void DynamicObject::RemoveFromWorld() void DynamicObject::RemoveFromWorld()
{
///- Remove the dynamicObject from the accessor
if(IsInWorld())
{ {
// Make sure the object is back to grid container for removal as farsight targets // 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 // are switched to world container on creation and they are also set to active
@@ -59,8 +62,8 @@ void DynamicObject::RemoveFromWorld()
GetMap()->SwitchGridContainers(this, false); GetMap()->SwitchGridContainers(this, false);
setActive(false); setActive(false);
} }
///- Remove the dynamicObject from the accessor ObjectAccessor::Instance().RemoveObject(this);
if(IsInWorld()) ObjectAccessor::Instance().RemoveObject(this); }
WorldObject::RemoveFromWorld(); WorldObject::RemoveFromWorld();
} }
+1 -1
View File
@@ -1101,7 +1101,7 @@ void WorldObject::AddToWorld()
void WorldObject::RemoveFromWorld() void WorldObject::RemoveFromWorld()
{ {
if(m_isActive && !isType(TYPEMASK_PLAYER)) if(m_isActive && IsInWorld() && !isType(TYPEMASK_PLAYER))
GetMap()->RemoveActiveObject(this); GetMap()->RemoveActiveObject(this);
Object::RemoveFromWorld(); Object::RemoveFromWorld();
} }