Instructions Jenkins Doxygen

[Changed] only creos to have activeAreas vectors 65/2265/2
authorIvojedi <ivojedi@swgemu.com>
Sat, 9 Aug 2014 20:32:07 +0000 (13:32 -0700)
committergerrit <gerrit@review.swgemu.com>
Sat, 9 Aug 2014 22:32:41 +0000 (22:32 +0000)
[Added] range and permission checks to camp terminal options

Change-Id: I71a277f1616302a8c2eaa0b75fa2337f1bf19651

19 files changed:
MMOCoreORB/bin/scripts/screenplays/treasure_map/TreasureMapMenuComponent.lua
MMOCoreORB/src/server/zone/Zone.idl
MMOCoreORB/src/server/zone/ZoneContainerComponent.cpp
MMOCoreORB/src/server/zone/ZoneImplementation.cpp
MMOCoreORB/src/server/zone/objects/building/BuildingObjectImplementation.cpp
MMOCoreORB/src/server/zone/objects/cell/CellObjectImplementation.cpp
MMOCoreORB/src/server/zone/objects/creature/CreatureObject.idl
MMOCoreORB/src/server/zone/objects/creature/CreatureObjectImplementation.cpp
MMOCoreORB/src/server/zone/objects/creature/LuaCreatureObject.cpp
MMOCoreORB/src/server/zone/objects/creature/LuaCreatureObject.h
MMOCoreORB/src/server/zone/objects/region/CityRegionImplementation.cpp
MMOCoreORB/src/server/zone/objects/scene/LuaSceneObject.cpp
MMOCoreORB/src/server/zone/objects/scene/LuaSceneObject.h
MMOCoreORB/src/server/zone/objects/scene/SceneObject.idl
MMOCoreORB/src/server/zone/objects/scene/SceneObjectImplementation.cpp
MMOCoreORB/src/server/zone/objects/scene/components/ZoneComponent.cpp
MMOCoreORB/src/server/zone/objects/tangible/components/CampKitMenuComponent.cpp
MMOCoreORB/src/server/zone/objects/tangible/components/CampTerminalMenuComponent.cpp
MMOCoreORB/src/server/zone/tests/ZoneTest.cpp

index e094e20..12f8684 100644 (file)
@@ -52,48 +52,46 @@ end
 
 function TreasureMapMenuComponent:doSearchArea(pObject, pPlayer)
        local mapType = TreasureMapMenuComponent:getMapType(pObject)
-       ObjectManager.withSceneObject(pPlayer, function(playerSceo)
-               ObjectManager.withCreatureAndPlayerObject(pPlayer, function(creature, player)
-                       local mapData = treasureMapData[mapType]
-                       local waypointID = readData(creature:getObjectID() .. ":treasureMapSearchAreaWaypointID")
-                       local searchAreaID = readData(creature:getObjectID() .. ":treasureMapSearchAreaActiveAreaID")
+       ObjectManager.withCreatureAndPlayerObject(pPlayer, function(creature, player)
+               local mapData = treasureMapData[mapType]
+               local waypointID = readData(creature:getObjectID() .. ":treasureMapSearchAreaWaypointID")
+               local searchAreaID = readData(creature:getObjectID() .. ":treasureMapSearchAreaActiveAreaID")
 
-                       if (waypointID == 0 or searchAreaID == 0) then
-                               creature:sendSystemMessage("@treasure_map/treasure_map:sys_no_waypoint") -- You must store the treasure's waypoint in your datapad before you can search for it!
-                               return 0
-                       end
+               if (waypointID == 0 or searchAreaID == 0) then
+                       creature:sendSystemMessage("@treasure_map/treasure_map:sys_no_waypoint") -- You must store the treasure's waypoint in your datapad before you can search for it!
+                       return 0
+               end
 
-                       if (playerSceo:hasActiveArea(searchAreaID) == false) then
-                               creature:sendSystemMessage("@treasure_map/treasure_map:sys_cant_pinpoint") -- You are not close enough to pinpoint the treasure's location.
-                               return 0
-                       end
+               if (creature:hasActiveArea(searchAreaID) == false) then
+                       creature:sendSystemMessage("@treasure_map/treasure_map:sys_cant_pinpoint") -- You are not close enough to pinpoint the treasure's location.
+                       return 0
+               end
 
-                       local pWaypoint = getSceneObject(waypointID)
+               local pWaypoint = getSceneObject(waypointID)
 
-                       local pActiveArea = getSceneObject(searchAreaID)
-                       ObjectManager.withSceneObject(pActiveArea, function(area)
-                               area:destroyObjectFromWorld()
-                       end)
+               local pActiveArea = getSceneObject(searchAreaID)
+               ObjectManager.withSceneObject(pActiveArea, function(area)
+                       area:destroyObjectFromWorld()
+               end)
 
-                       deleteData(creature:getObjectID() .. ":treasureMapSearchAreaWaypointID")
-                       deleteData(creature:getObjectID() .. ":treasureMapSearchAreaActiveAreaID")
+               deleteData(creature:getObjectID() .. ":treasureMapSearchAreaWaypointID")
+               deleteData(creature:getObjectID() .. ":treasureMapSearchAreaActiveAreaID")
 
-                       local spawnPoint
-                       ObjectManager.withSceneObject(pWaypoint, function(waypoint)
-                               if (mapType == 4) then
-                                       spawnPoint = getSpawnPoint(pPlayer, waypoint:getWorldPositionX(), waypoint:getWorldPositionY(), 15, 30)
-                               else
-                                       spawnPoint = getSpawnPoint(pPlayer, waypoint:getWorldPositionX(), waypoint:getWorldPositionY(), 30, 60)
-                               end
-                       end)
+               local spawnPoint
+               ObjectManager.withSceneObject(pWaypoint, function(waypoint)
+                       if (mapType == 4) then
+                               spawnPoint = getSpawnPoint(pPlayer, waypoint:getWorldPositionX(), waypoint:getWorldPositionY(), 15, 30)
+                       else
+                               spawnPoint = getSpawnPoint(pPlayer, waypoint:getWorldPositionX(), waypoint:getWorldPositionY(), 30, 60)
+                       end
+               end)
 
-                       local x = spawnPoint[1]
-                       local y = spawnPoint[3]
+               local x = spawnPoint[1]
+               local y = spawnPoint[3]
 
-                       creature:sendSystemMessage("@treasure_map/treasure_map:sys_pinpoint") -- You have successfully pinpointed the exact location of the treasure!
-                       player:addWaypoint(mapData.planet, "@treasure_map/treasure_map:waypoint_name", "", x, y, WAYPOINTGREEN, true, true, WAYPOINTTREASUREMAP, 0)
+               creature:sendSystemMessage("@treasure_map/treasure_map:sys_pinpoint") -- You have successfully pinpointed the exact location of the treasure!
+               player:addWaypoint(mapData.planet, "@treasure_map/treasure_map:waypoint_name", "", x, y, WAYPOINTGREEN, true, true, WAYPOINTTREASUREMAP, 0)
 
-               end)
        end)
 end
 
index 2c89cdf..3fcae12 100644 (file)
@@ -153,7 +153,7 @@ class Zone extends SceneObject {
        @local
        public native void inRange(QuadTreeEntry entry, float range);
 
-       public native void updateActiveAreas(SceneObject object);
+       public native void updateActiveAreas(CreatureObject creature);
 
        public native void startManagers();
 
index b311f6b..88ed047 100644 (file)
@@ -52,10 +52,15 @@ bool ZoneContainerComponent::insertActiveArea(Zone* newZone, ActiveArea* activeA
        for (int i = 0; i < objects.size(); ++i) {
                SceneObject* object = cast<SceneObject*>(objects.get(i).get());
 
+               if (!object->isCreatureObject()) {
+                       continue;
+               }
+
+               CreatureObject* creature = cast<CreatureObject*>(object);
                Vector3 worldPos = object->getWorldPosition();
 
-               if (!object->hasActiveArea(activeArea) && activeArea->containsPoint(worldPos.getX(), worldPos.getY())) {
-                       object->addActiveArea(activeArea);
+               if (!creature->hasActiveArea(activeArea) && activeArea->containsPoint(worldPos.getX(), worldPos.getY())) {
+                       creature->addActiveArea(activeArea);
                        activeArea->enqueueEnterEvent(object);
                }
        }
@@ -106,8 +111,14 @@ bool ZoneContainerComponent::removeActiveArea(Zone* zone, ActiveArea* activeArea
 
        //      Locker olocker(object);
 
-               if (object->hasActiveArea(activeArea)) {
-                       object->dropActiveArea(activeArea);
+               if (!object->isCreatureObject()) {
+                       continue;
+               }
+
+               CreatureObject* creature = cast<CreatureObject*>(object);
+
+               if (creature->hasActiveArea(activeArea)) {
+                       creature->dropActiveArea(activeArea);
                        activeArea->enqueueExitEvent(object);
                }
        }
@@ -187,7 +198,11 @@ bool ZoneContainerComponent::transferObject(SceneObject* sceneObject, SceneObjec
 
        zone->inRange(object, 192);
 
-       zone->updateActiveAreas(object);
+       if (object->isCreatureObject()) {
+               CreatureObject* creature = cast<CreatureObject*>(object);
+
+               zone->updateActiveAreas(creature);
+       }
 
        SharedBuildingObjectTemplate* objtemplate = dynamic_cast<SharedBuildingObjectTemplate*>(object->getObjectTemplate());
 
@@ -212,7 +227,6 @@ bool ZoneContainerComponent::removeObject(SceneObject* sceneObject, SceneObject*
                return removeActiveArea(zone, dynamic_cast<ActiveArea*>(object));
 
        ManagedReference<SceneObject*> parent = object->getParent();
-       Vector<ManagedReference<ActiveArea*> >* activeAreas = object->getActiveAreas();
        //SortedVector<ManagedReference<SceneObject*> >* notifiedSentObjects = sceneObject->getNotifiedSentObjects();
 
        try {
@@ -281,15 +295,20 @@ bool ZoneContainerComponent::removeObject(SceneObject* sceneObject, SceneObject*
 
                zoneLocker.release();
 
-               while (activeAreas->size() > 0) {
-                       Locker _alocker(object->getContainerLock());
+               if (object->isCreatureObject()) {
+                       CreatureObject* creature = cast<CreatureObject*>(object);
+                       Vector<ManagedReference<ActiveArea*> >* activeAreas = creature->getActiveAreas();
 
-                       ManagedReference<ActiveArea*> area = activeAreas->get(0);
-                       activeAreas->remove(0);
+                       while (activeAreas->size() > 0) {
+                               Locker _alocker(object->getContainerLock());
 
-                       _alocker.release();
+                               ManagedReference<ActiveArea*> area = activeAreas->get(0);
+                               activeAreas->remove(0);
 
-                       area->enqueueExitEvent(object);
+                               _alocker.release();
+
+                               area->enqueueExitEvent(object);
+                       }
                }
 
                SortedVector<ManagedReference<SceneObject*> >* childObjects = object->getChildObjects();
index 71f4a3d..6f7edc0 100644 (file)
@@ -321,16 +321,16 @@ int ZoneImplementation::getInRangeActiveAreas(float x, float y, float range, Sor
        return objects->size();
 }
 
-void ZoneImplementation::updateActiveAreas(SceneObject* object) {
+void ZoneImplementation::updateActiveAreas(CreatureObject* creature) {
        //Locker locker(_this.get());
 
-       Locker _alocker(object->getContainerLock());
+       Locker _alocker(creature->getContainerLock());
 
-       SortedVector<ManagedReference<ActiveArea* > > areas = *dynamic_cast<SortedVector<ManagedReference<ActiveArea* > >* >(object->getActiveAreas());
+       SortedVector<ManagedReference<ActiveArea* > > areas = *dynamic_cast<SortedVector<ManagedReference<ActiveArea* > >* >(creature->getActiveAreas());
 
        _alocker.release();
 
-       Vector3 worldPos = object->getWorldPosition();
+       Vector3 worldPos = creature->getWorldPosition();
 
        SortedVector<ManagedReference<QuadTreeEntry*> > entryObjects;
 
@@ -363,11 +363,11 @@ void ZoneImplementation::updateActiveAreas(SceneObject* object) {
 //                     Locker locker(area, object);
 
                        if (!area->containsPoint(worldPos.getX(), worldPos.getY())) {
-                               object->dropActiveArea(area);
-                               area->enqueueExitEvent(object);
+                               creature->dropActiveArea(area);
+                               area->enqueueExitEvent(creature);
 //                             area->notifyExit(object);
                        } else {
-                               area->notifyPositionUpdate(object);
+                               area->notifyPositionUpdate(creature);
                        }
                }
 
@@ -376,13 +376,13 @@ void ZoneImplementation::updateActiveAreas(SceneObject* object) {
                        //update in new ones
                        ActiveArea* activeArea = dynamic_cast<ActiveArea*>(entryObjects.get(i).get());
 
-                       if (!object->hasActiveArea(activeArea) && activeArea->containsPoint(worldPos.getX(), worldPos.getY())) {
+                       if (!creature->hasActiveArea(activeArea) && activeArea->containsPoint(worldPos.getX(), worldPos.getY())) {
                                //Locker lockerO(object);
 
                                //Locker locker(activeArea, object);
 
-                               object->addActiveArea(activeArea);
-                               activeArea->enqueueEnterEvent(object);
+                               creature->addActiveArea(activeArea);
+                               activeArea->enqueueEnterEvent(creature);
                                //activeArea->notifyEnter(object);
                        }
                }
@@ -394,16 +394,16 @@ void ZoneImplementation::updateActiveAreas(SceneObject* object) {
                        if (worldAreas != NULL) {
                                for (int i = 0; i < worldAreas->size(); ++i) {
                                        ActiveArea* activeArea = worldAreas->get(i);
-                                       Locker lockerO(object);
+                                       Locker lockerO(creature);
 
                                        //                      Locker locker(activeArea, object);
 
-                                       if (!object->hasActiveArea(activeArea)) {
-                                               object->addActiveArea(activeArea);
+                                       if (!creature->hasActiveArea(activeArea)) {
+                                               creature->addActiveArea(activeArea);
                                                //activeArea->enqueueEnterEvent(object);
-                                               activeArea->notifyEnter(object);
+                                               activeArea->notifyEnter(creature);
                                        } else {
-                                               activeArea->notifyPositionUpdate(object);
+                                               activeArea->notifyPositionUpdate(creature);
                                        }
                                }
                        }
index 49f6d41..932a215 100644 (file)
@@ -113,7 +113,10 @@ void BuildingObjectImplementation::notifyLoadFromDatabase() {
 
                                rlocker.release();
 
-                               zone->updateActiveAreas(child);
+                               if (child->isCreatureObject()) {
+                                       CreatureObject* creature = cast<CreatureObject*>(child);
+                                       zone->updateActiveAreas(creature);
+                               }
                        }
                }
        }
@@ -440,7 +443,10 @@ void BuildingObjectImplementation::notifyObjectInsertedToZone(SceneObject* objec
        addInRangeObject(object, false);
 
        if (getZone() != NULL) {
-               getZone()->updateActiveAreas(object);
+               if (object->isCreatureObject()) {
+                       CreatureObject* creature = cast<CreatureObject*>(object);
+                       getZone()->updateActiveAreas(creature);
+               }
 
                object->notifyInsertToZone(getZone());
        }
@@ -906,8 +912,10 @@ int BuildingObjectImplementation::notifyObjectInsertedToChild(SceneObject* objec
        if (zone != NULL)
                delete _locker;
 
-       if (getZone() != NULL)
-               getZone()->updateActiveAreas(object);
+       if (getZone() != NULL && object->isCreatureObject()) {
+               CreatureObject* creature = cast<CreatureObject*>(object);
+               getZone()->updateActiveAreas(creature);
+       }
 
        return 0;
 }
index 718c377..ff771c8 100644 (file)
@@ -137,8 +137,10 @@ bool CellObjectImplementation::transferObject(SceneObject* object, int containme
        try {
                ret = SceneObjectImplementation::transferObject(object, containmentType, notifyClient, allowOverflow);
 
-               if (zone != NULL)
-                       zone->updateActiveAreas(object);
+               if (zone != NULL && object->isCreatureObject()) {
+                       CreatureObject* creature = cast<CreatureObject*>(object);
+                       zone->updateActiveAreas(creature);
+               }
        } catch (...) {
 
        }
index f1f2397..420d5d8 100644 (file)
@@ -211,7 +211,10 @@ class CreatureObject extends TangibleObject {
        
        protected transient byte currentWeather;
        protected transient byte currentWind;
-       
+
+       @dereferenced
+       protected SortedVector<ActiveArea> activeAreas;
+
        @dereferenced
        protected transient Time lastCombatActionTime;
 
@@ -1704,4 +1707,61 @@ class CreatureObject extends TangibleObject {
        public native void updateSpeedAndAccelerationMods();
 
        public native void setFaction(unsigned int crc);
+
+       public native void addActiveArea(ActiveArea area);
+
+       public void dropActiveArea(ActiveArea area) {
+               synchronized (super.getContainerLock()) {
+                       activeAreas.drop(area);
+               }
+       }
+
+       @read
+       public boolean hasActiveArea(ActiveArea area) {
+               synchronized (super.getContainerLock()) {
+                       return activeAreas.contains(area);
+               }
+       }
+
+       @read
+       public boolean hasActiveArea(unsigned long objectid) {
+               synchronized (super.getContainerLock()) {
+                       for (int i = 0; i < activeAreas.size(); ++i) {
+                               ActiveArea area = activeAreas.get(i);
+
+                               if (area.getObjectID() == objectid) {
+                                       return true;
+                               }
+                       }
+               }
+
+               return false;
+       }
+
+       @local
+       @read
+       public Vector<ActiveArea> getActiveAreas() {
+               return activeAreas;
+       }
+
+       @read
+       public int getActiveAreasSize() {
+               return activeAreas.size();
+       }
+
+       @read
+       @reference
+       public ActiveArea getActiveRegion() {
+               synchronized (super.getContainerLock()) {
+                       for (int i = 0; i < activeAreas.size(); i++) {
+                               ActiveArea region = activeAreas.get(i);
+
+                               if (region.isRegion()) {
+                                       return region;
+                               }
+                       }
+               }
+
+               return null;
+       }
 }
index e2dedc4..a6448b8 100644 (file)
@@ -1928,6 +1928,12 @@ void CreatureObjectImplementation::notifyLoadFromDatabase() {
                setPosture(CreaturePosture::UPRIGHT);
        }
 
+       for (int i = 0; i < activeAreas.size(); ++i) {
+               activeAreas.get(i)->notifyExit(_this.get());
+       }
+
+       activeAreas.removeAll();
+
        if (ghost == NULL)
                return;
 
@@ -2894,3 +2900,10 @@ void CreatureObjectImplementation::setFaction(unsigned int crc) {
                task->execute();
        }
 }
+
+void CreatureObjectImplementation::addActiveArea(ActiveArea* area) {
+       if (!area->isDeplyoed())
+               area->deploy();
+
+       activeAreas.put(area);
+}
index 6411549..e533cc1 100644 (file)
@@ -99,6 +99,7 @@ Luna<LuaCreatureObject>::RegType LuaCreatureObject::Register[] = {
                { "getPerformanceName", &LuaCreatureObject::getPerformanceName},
                { "getWalkSpeed", &LuaCreatureObject::getWalkSpeed },
                { "isAttackableBy", &LuaCreatureObject::isAttackableBy },
+               { "hasActiveArea", &LuaCreatureObject::hasActiveArea},
                { 0, 0 }
 };
 
@@ -723,3 +724,12 @@ int LuaCreatureObject::isAttackableBy(lua_State* L) {
        return 1;
 }
 
+int LuaCreatureObject::hasActiveArea(lua_State* L) {
+       uint64 objectid = lua_tointeger(L, -1);
+
+       bool res = realObject->hasActiveArea(objectid);
+
+       lua_pushboolean(L, res);
+
+       return 1;
+}
index db36dce..e1f5556 100644 (file)
@@ -94,6 +94,7 @@ namespace creature {
                int getPerformanceName(lua_State* L);
                int getWalkSpeed(lua_State* L);
                int isAttackableBy(lua_State* L);
+               int hasActiveArea(lua_State* L);
 
        private:
                // The pointer to the 'real object' defined in object.cc
index ab79009..7c53a81 100644 (file)
@@ -243,15 +243,21 @@ void CityRegionImplementation::notifyEnter(SceneObject* object) {
 
 void CityRegionImplementation::notifyExit(SceneObject* object) {
        //pre: no 2 different city regions should ever overlap, only 2 Regions of the same city region
-       ManagedReference<Region*> activeRegion = object->getActiveRegion().castTo<Region*>();
+       if (object->isCreatureObject()) {
+               CreatureObject* creature = cast<CreatureObject*>(object);
+
+               ManagedReference<Region*> activeRegion = creature->getActiveRegion().castTo<Region*>();
 
-       if (activeRegion != NULL) {
-               ManagedReference<CityRegion*> city = activeRegion->getCityRegion();
+               if (activeRegion != NULL) {
+                       ManagedReference<CityRegion*> city = activeRegion->getCityRegion();
 
-               object->setCityRegion(city);
+                       object->setCityRegion(city);
 
-               if (city == _this.get()) // if its the same city we wait till the object exits the last region
-                       return;
+                       if (city == _this.get()) // if its the same city we wait till the object exits the last region
+                               return;
+               } else {
+                       object->setCityRegion(NULL);
+               }
        } else {
                object->setCityRegion(NULL);
        }
index 59d075d..e7fafb1 100644 (file)
@@ -66,7 +66,6 @@ Luna<LuaSceneObject>::RegType LuaSceneObject::Register[] = {
                { "setContainerDefaultDenyPermission", &LuaSceneObject::setContainerDefaultDenyPermission},
                { "clearContainerDefaultDenyPermission", &LuaSceneObject::clearContainerDefaultDenyPermission},
                { "setContainerOwnerID", &LuaSceneObject::setContainerOwnerID},
-               { "hasActiveArea", &LuaSceneObject::hasActiveArea},
                { "setObjectName", &LuaSceneObject::setObjectName},
                { "isASubChildOf", &LuaSceneObject::isASubChildOf},
                { 0, 0 }
@@ -220,16 +219,6 @@ int LuaSceneObject::isInRange(lua_State* L) {
        return 1;
 }
 
-int LuaSceneObject::hasActiveArea(lua_State* L) {
-       uint64 objectid = lua_tointeger(L, -1);
-
-       bool res = realObject->hasActiveArea(objectid);
-
-       lua_pushboolean(L, res);
-
-       return 1;
-}
-
 int LuaSceneObject::getGameObjectType(lua_State* L) {
        uint32 type = realObject->getGameObjectType();
 
index 3410a2d..29bb498 100644 (file)
@@ -81,7 +81,6 @@ namespace scene {
                int setContainerDefaultDenyPermission(lua_State* L);
                int clearContainerDefaultDenyPermission(lua_State* L);
                int setContainerOwnerID(lua_State* L);
-               int hasActiveArea(lua_State* L);
                int setObjectName(lua_State* L);
                int isASubChildOf(lua_State* L);
 
index 3805915..4338f7b 100644 (file)
@@ -155,10 +155,7 @@ class SceneObject extends QuadTreeEntry implements Logger {
 
        @weakReference
        protected transient CityRegion cityRegion;
-       
-       @dereferenced
-       protected SortedVector<ActiveArea> activeAreas;
-       
+
        @dereferenced
        protected SortedVector<SceneObject> childObjects;
        
@@ -874,64 +871,7 @@ class SceneObject extends QuadTreeEntry implements Logger {
        public abstract int notifyObjectRemoved(SceneObject object) {
                return 0;
        }
-       
-       public native void addActiveArea(ActiveArea area);
-       
-       public void dropActiveArea(ActiveArea area) {
-               synchronized (containerLock) {
-                       activeAreas.drop(area);
-               }
-       }
-       
-       @read
-       public boolean hasActiveArea(ActiveArea area) {
-               synchronized (containerLock) {
-                       return activeAreas.contains(area);
-               }
-       }
-       
-       @read
-       public boolean hasActiveArea(unsigned long objectid) {
-               synchronized (containerLock) {
-                       for (int i = 0; i < activeAreas.size(); ++i) {
-                               ActiveArea area = activeAreas.get(i);
-
-                               if (area.getObjectID() == objectid) {
-                                       return true;
-                               }
-                       }
-               }
-               
-               return false;
-       }
-       
-       @local
-       @read
-       public Vector<ActiveArea> getActiveAreas() {
-               return activeAreas;
-       }
-       
-       @read
-       public int getActiveAreasSize() {
-               return activeAreas.size();
-       }
-       
-       @read
-       @reference
-       public ActiveArea getActiveRegion() {
-               synchronized (containerLock) {
-                       for (int i = 0; i < activeAreas.size(); i++) {
-                               ActiveArea region = activeAreas.get(i);
 
-                               if (region.isRegion()) {
-                                       return region;
-                               }
-                       }
-               }
-               
-               return null;
-       }
-       
        @read
        @local
        @weakReference
index 1af9422..18c2976 100644 (file)
@@ -122,8 +122,6 @@ void SceneObjectImplementation::initializeTransientMembers() {
 
        movementCounter = 0;
 
-       //activeAreas.removeAll();
-
        setGlobalLogging(true);
        setLogging(false);
 
@@ -480,12 +478,6 @@ void SceneObjectImplementation::notifyLoadFromDatabase() {
 
        }
 
-       for (int i = 0; i < activeAreas.size(); ++i) {
-               activeAreas.get(i)->notifyExit(_this.get());
-       }
-
-       activeAreas.removeAll();
-
        if (zone != NULL) {
                zone->transferObject(_this.get(), -1, true);
        } /*else if (parent != NULL && getParent()->isCellObject()) {
@@ -1627,13 +1619,6 @@ bool SceneObjectImplementation::setTransformForCollisionMatrixIfNull(Matrix4* ma
        return transformForCollisionMatrix.compareAndSet(NULL, mat);
 }
 
-void SceneObjectImplementation::addActiveArea(ActiveArea* area) {
-       if (!area->isDeplyoed())
-               area->deploy();
-
-       activeAreas.put(area);
-}
-
 int SceneObjectImplementation::getCountableObjectsRecursive() {
        int count = 0;
 
index 9d39b73..6689a00 100644 (file)
@@ -229,17 +229,17 @@ void ZoneComponent::updateZone(SceneObject* sceneObject, bool lightUpdate, bool
                        updateInRangeObjectsOnMount(sceneObject);
                }
        }
-
-       zone->updateActiveAreas(sceneObject);
        
        bool isInvis = false;
 
        if (sceneObject->isCreatureObject()) {
                CreatureObject* creo = cast<CreatureObject*>(sceneObject);
-               
+
+               zone->updateActiveAreas(creo);
+
                if(creo->isInvisible())
                        isInvis = true;
-               }
+       }
 
 
        if (!isInvis && sendPackets && (parent == NULL || (!parent->isVehicleObject() && !parent->isMount()))) {
@@ -290,7 +290,10 @@ void ZoneComponent::updateZoneWithParent(SceneObject* sceneObject, SceneObject*
                } else {
                        zone->unlock();
 
-                       zone->updateActiveAreas(sceneObject);
+                       if (sceneObject->isCreatureObject()) {
+                               CreatureObject* creature = cast<CreatureObject*>(sceneObject);
+                               zone->updateActiveAreas(creature);
+                       }
                }
 
                //notify in range objects that i moved
@@ -504,16 +507,19 @@ void ZoneComponent::destroyObjectFromWorld(SceneObject* sceneObject, bool sendSe
 
 //             locker.release();
 
-               Vector<ManagedReference<ActiveArea*> >* activeAreas =  sceneObject->getActiveAreas();
+               if (sceneObject->isCreatureObject()) {
+                       CreatureObject* creature = cast<CreatureObject*>(sceneObject);
+                       Vector<ManagedReference<ActiveArea*> >* activeAreas =  creature->getActiveAreas();
 
-               while (activeAreas->size() > 0) {
-                       Locker _alocker(sceneObject->getContainerLock());
-                       ManagedReference<ActiveArea*> area = activeAreas->get(0);
-                       activeAreas->remove(0);
+                       while (activeAreas->size() > 0) {
+                               Locker _alocker(sceneObject->getContainerLock());
+                               ManagedReference<ActiveArea*> area = activeAreas->get(0);
+                               activeAreas->remove(0);
                        
-                       _alocker.release();
+                               _alocker.release();
                        
-                       area->enqueueExitEvent(sceneObject);
+                               area->enqueueExitEvent(sceneObject);
+                       }
                }
        }
 }
index d9ed88d..bf95bd5 100644 (file)
@@ -250,8 +250,6 @@ int CampKitMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject,
 
                zone->transferObject(campArea, -1, false);
 
-               structureObject->addActiveArea(campArea);
-
                ghost->addOwnedStructure(structureObject);
 
                player->sendSystemMessage("@camp:camp_complete");
index 5e37a72..4343738 100644 (file)
@@ -46,6 +46,10 @@ void CampTerminalMenuComponent::fillObjectMenuResponse(SceneObject* sceneObject,
                return;
        }
 
+       if (!player->isInRange(terminal, 7)) {
+               return;
+       }
+
        menuResponse->addRadialMenuItem(68, 3, "@camp:mnu_status");
 
        /// Make sure player doesn't already have a camp setup somewhere else
@@ -60,7 +64,7 @@ void CampTerminalMenuComponent::fillObjectMenuResponse(SceneObject* sceneObject,
                }
        }
 
-       Vector < ManagedReference<ActiveArea*> > *areas = sceneObject->getActiveAreas();
+       Vector < ManagedReference<ActiveArea*> > *areas = player->getActiveAreas();
        ManagedReference<ActiveArea*> area = NULL;
        for (int i = 0; i < areas->size(); ++i) {
                area = areas->get(i);
@@ -112,6 +116,10 @@ void CampTerminalMenuComponent::disbandCamp(SceneObject* sceneObject,
                return;
        }
 
+       if (!player->isInRange(terminal, 7)) {
+               return;
+       }
+
        StructureObject* camp = cast<StructureObject*>(terminal->getControlledObject());
        if(camp == NULL) {
                error("Camp is null in disbandCamp");
@@ -121,12 +129,22 @@ void CampTerminalMenuComponent::disbandCamp(SceneObject* sceneObject,
        if (camp->getZone() == NULL)
                return;
 
+       PlayerObject* ghost = player->getPlayerObject();
+
+       if (ghost == NULL) {
+               return;
+       }
+
+       if (!ghost->isOwnedStructure(camp)) {
+               return;
+       }
+
        if(player->isSitting()) {
                player->setPosture(CreaturePosture::UPRIGHT, true);
        }
 
        // Find Camp Area
-       Vector<ManagedReference<ActiveArea* > >* areas = camp->getActiveAreas();
+       Vector<ManagedReference<ActiveArea* > >* areas = player->getActiveAreas();
        ManagedReference<ActiveArea*> area = NULL;
        for(int i = 0; i < areas->size(); ++i) {
                area = areas->get(i);
@@ -157,6 +175,10 @@ void CampTerminalMenuComponent::assumeCampOwnership(SceneObject* sceneObject,
                return;
        }
 
+       if (!player->isInRange(terminal, 7)) {
+               return;
+       }
+
        StructureObject* camp = cast<StructureObject*>(terminal->getControlledObject());
        if(camp == NULL) {
                error("Camp is null in assumeCampOwnership");
@@ -164,7 +186,7 @@ void CampTerminalMenuComponent::assumeCampOwnership(SceneObject* sceneObject,
        }
 
        // Find Camp Area
-       Vector<ManagedReference<ActiveArea* > >* areas = camp->getActiveAreas();
+       Vector<ManagedReference<ActiveArea* > >* areas = player->getActiveAreas();
        ManagedReference<ActiveArea*> area = NULL;
        for(int i = 0; i < areas->size(); ++i) {
                area = areas->get(i);
@@ -195,6 +217,10 @@ void CampTerminalMenuComponent::showCampStatus(SceneObject* sceneObject,
                return;
        }
 
+       if (!player->isInRange(terminal, 7)) {
+               return;
+       }
+
        StructureObject* camp = cast<StructureObject*>(terminal->getControlledObject());
        if(camp == NULL) {
                error("Camp is null in CampTerminalMenuComponent::showCampStatus");
@@ -202,7 +228,7 @@ void CampTerminalMenuComponent::showCampStatus(SceneObject* sceneObject,
        }
 
        // Get Camp Area
-       Vector<ManagedReference<ActiveArea* > >* areas = camp->getActiveAreas();
+       Vector<ManagedReference<ActiveArea* > >* areas = player->getActiveAreas();
        ManagedReference<ActiveArea*> area = NULL;
        for(int i = 0; i < areas->size(); ++i) {
                area = areas->get(i);
index 0737229..b4924d1 100644 (file)
@@ -44,6 +44,14 @@ public:
                return object;
        }
 
+       Reference<CreatureObject*> createCreatureObject() {
+               Reference<CreatureObject*> object = new CreatureObject();
+               setDefaultComponents(object);
+               object->_setObjectID(nextObjectId.increment());
+
+               return object;
+       }
+
        Reference<ActiveArea*> createActiveArea() {
                Reference<ActiveArea*> activeArea = new ActiveArea();
                setDefaultComponents(activeArea);
@@ -154,24 +162,24 @@ TEST_F(ZoneTest, ActiveAreaTest) {
 
        alocker.release();
 
-       Reference<SceneObject*> scene = createSceneObject();
-       scene->initializePosition(0, 0, 0);
+       Reference<CreatureObject*> creature = createCreatureObject();
+       creature->initializePosition(0, 0, 0);
 
-       Locker slocker(scene);
+       Locker slocker(creature);
 
-       ASSERT_EQ(scene->getActiveAreasSize(), 0);
+       ASSERT_EQ(creature->getActiveAreasSize(), 0);
 
-       zone->transferObject(scene, -1);
+       zone->transferObject(creature, -1);
 
-       ASSERT_EQ(scene->getActiveAreasSize(), 1);
+       ASSERT_EQ(creature->getActiveAreasSize(), 1);
 
-       scene->teleport(200, 0, 0);
+       creature->teleport(200, 0, 0);
 
-       ASSERT_EQ(scene->getActiveAreasSize(), 0);
+       ASSERT_EQ(creature->getActiveAreasSize(), 0);
 
-       scene->teleport(120, 0, 0);
+       creature->teleport(120, 0, 0);
 
-       ASSERT_EQ(scene->getActiveAreasSize(), 1);
+       ASSERT_EQ(creature->getActiveAreasSize(), 1);
 
        slocker.release();
 
@@ -181,11 +189,11 @@ TEST_F(ZoneTest, ActiveAreaTest) {
 
        blocker.release();
 
-       Locker s2locker(scene);
+       Locker s2locker(creature);
 
-       ASSERT_EQ(scene->getActiveAreasSize(), 0);
+       ASSERT_EQ(creature->getActiveAreasSize(), 0);
 
-       scene->destroyObjectFromWorld(false);
+       creature->destroyObjectFromWorld(false);
 }