From bf66375bc73c2b9dd7c2d26d7af25b111734c622 Mon Sep 17 00:00:00 2001 From: megamage Date: Wed, 25 Feb 2009 20:52:20 -0600 Subject: *Update active object code. By VladimirMangos. --HG-- branch : trunk --- src/game/Object.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'src/game/Object.cpp') diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 2d19e51e76e..5551f844376 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1070,19 +1070,31 @@ WorldObject::WorldObject() m_isActive = false; } -void WorldObject::setActive(bool isActive) +void WorldObject::setActive( bool on ) { - // if already in the same activity state as we try to set, do nothing - if(isActive == m_isActive || isType(TYPEMASK_PLAYER)) + if(m_isActive==on) return; - m_isActive = isActive; - if(IsInWorld()) + bool world = IsInWorld(); + + Map* map; + if(world) { - if(isActive) - GetMap()->AddActiveObject(this); - else - GetMap()->RemoveActiveObject(this); + map = GetMap(); + if(GetTypeId() == TYPEID_UNIT) + map->Remove((Creature*)this,false); + else if(GetTypeId() == TYPEID_DYNAMICOBJECT) + map->Remove((DynamicObject*)this,false); + } + + m_isActive = on; + + if(world) + { + if(GetTypeId() == TYPEID_UNIT) + map->Add((Creature*)this); + else if(GetTypeId() == TYPEID_DYNAMICOBJECT) + map->Add((DynamicObject*)this); } } -- cgit v1.2.3