Instructions Jenkins Doxygen

[Changed] how building objects track child creatures 94/894/2
authorIvojedi <ivojedi@swgemu.com>
Thu, 10 Oct 2013 05:39:25 +0000 (22:39 -0700)
committerIvojedi <ivojedi@swgemu.com>
Thu, 10 Oct 2013 09:31:37 +0000 (02:31 -0700)
[Changed] LuaBuildingObject to inherit from TangibleObject instead of
SceneObject
[Added] CreateChildCreature method to LuaBuildingObject

Change-Id: I3e64c9997262404ac32121d4a79a2af219c523bf

MMOCoreORB/src/server/zone/objects/building/BuildingObject.cpp
MMOCoreORB/src/server/zone/objects/building/BuildingObject.h
MMOCoreORB/src/server/zone/objects/building/BuildingObject.idl
MMOCoreORB/src/server/zone/objects/building/BuildingObjectImplementation.cpp
MMOCoreORB/src/server/zone/objects/building/LuaBuildingObject.cpp
MMOCoreORB/src/server/zone/objects/building/LuaBuildingObject.h
MMOCoreORB/src/server/zone/objects/building/components/DestructibleBuildingDataComponent.h
MMOCoreORB/src/server/zone/objects/structure/components/StructureZoneComponent.cpp
MMOCoreORB/src/server/zone/templates/ChildCreatureObject.h

index e3017a4..11a7a9b 100644 (file)
@@ -20,7 +20,7 @@
  *     BuildingObjectStub
  */
 
-enum {RPC_CREATECELLOBJECTS__ = 6,RPC_DESTROYOBJECTFROMDATABASE__BOOL_,RPC_INITIALIZETRANSIENTMEMBERS__,RPC_CREATECONTAINERCOMPONENT__,RPC_SETCUSTOMOBJECTNAME__UNICODESTRING_BOOL_,RPC_UPDATESIGNNAME__BOOL_,RPC_SENDCONTAINEROBJECTSTO__SCENEOBJECT_,RPC_UPDATECELLPERMISSIONSTO__CREATUREOBJECT_,RPC_BROADCASTCELLPERMISSIONS__,RPC_BROADCASTCELLPERMISSIONS__LONG_,RPC_ISALLOWEDENTRY__CREATUREOBJECT_,RPC_ISCITYBANNED__CREATUREOBJECT_,RPC_NOTIFYSTRUCTUREPLACED__CREATUREOBJECT_,RPC_HASTEMPLATEEJECTIONPOINT__,RPC_EJECTOBJECT__CREATUREOBJECT_,RPC_NOTIFYREMOVEFROMZONE__,RPC_NOTIFYLOADFROMDATABASE__,RPC_NOTIFYINSERTTOZONE__ZONE_,RPC_NOTIFYOBJECTINSERTEDTOZONE__SCENEOBJECT_,RPC_SENDTO__SCENEOBJECT_BOOL_,RPC_SENDBASELINESTO__SCENEOBJECT_,RPC_SENDDESTROYTO__SCENEOBJECT_,RPC_ADDCELL__CELLOBJECT_INT_,RPC_ISSTATICBUILDING__,RPC_GETCELL__INT_,RPC_GETTOTALCELLNUMBER__,RPC_TRANSFEROBJECT__SCENEOBJECT_INT_BOOL_BOOL_,RPC_NOTIFYOBJECTINSERTEDTOCHILD__SCENEOBJECT_SCENEOBJECT_SCENEOBJECT_,RPC_NOTIFYOBJECTREMOVEDFROMCHILD__SCENEOBJECT_SCENEOBJECT_,RPC_GETCURRENTNUMBEROFPLAYERITEMS__,RPC_DESTROYALLPLAYERITEMS__,RPC_ONENTER__CREATUREOBJECT_,RPC_ONEXIT__CREATUREOBJECT_LONG_,RPC_ISBUILDINGOBJECT__,RPC_SETSIGNOBJECT__SIGNOBJECT_,RPC_GETSIGNOBJECT__,RPC_ISPUBLICSTRUCTURE__,RPC_ISPRIVATESTRUCTURE__,RPC_SETPUBLICSTRUCTURE__BOOL_,RPC_ISCONDEMNED__,RPC_GETMAPCELLSIZE__,RPC_TOGGLEPRIVACY__,RPC_GETMAXIMUMNUMBEROFPLAYERITEMS__,RPC_GETREDEEDMESSAGE__,RPC_HASACCESSFEE__,RPC_GETACCESSFEE__,RPC_CANCHANGEACCESSFEE__,RPC_SETACCESSFEE__INT_INT_,RPC_REMOVEACCESSFEE__,RPC_GETACCESSFEEDELAY__,RPC_PAYACCESSFEE__CREATUREOBJECT_,RPC_UPDATEPAIDACCESSLIST__,RPC_CREATECHILDOBJECTS__,RPC_SPAWNCHILDCREATURES__,RPC_HASCHILDCREATURES__,RPC_ISRESIDENCE__,RPC_SETRESIDENCE__BOOL_};
+enum {RPC_CREATECELLOBJECTS__ = 6,RPC_DESTROYOBJECTFROMDATABASE__BOOL_,RPC_INITIALIZETRANSIENTMEMBERS__,RPC_CREATECONTAINERCOMPONENT__,RPC_SETCUSTOMOBJECTNAME__UNICODESTRING_BOOL_,RPC_UPDATESIGNNAME__BOOL_,RPC_SENDCONTAINEROBJECTSTO__SCENEOBJECT_,RPC_UPDATECELLPERMISSIONSTO__CREATUREOBJECT_,RPC_BROADCASTCELLPERMISSIONS__,RPC_BROADCASTCELLPERMISSIONS__LONG_,RPC_ISALLOWEDENTRY__CREATUREOBJECT_,RPC_ISCITYBANNED__CREATUREOBJECT_,RPC_NOTIFYSTRUCTUREPLACED__CREATUREOBJECT_,RPC_HASTEMPLATEEJECTIONPOINT__,RPC_EJECTOBJECT__CREATUREOBJECT_,RPC_NOTIFYREMOVEFROMZONE__,RPC_NOTIFYLOADFROMDATABASE__,RPC_NOTIFYINSERTTOZONE__ZONE_,RPC_NOTIFYOBJECTINSERTEDTOZONE__SCENEOBJECT_,RPC_SENDTO__SCENEOBJECT_BOOL_,RPC_SENDBASELINESTO__SCENEOBJECT_,RPC_SENDDESTROYTO__SCENEOBJECT_,RPC_ADDCELL__CELLOBJECT_INT_,RPC_ISSTATICBUILDING__,RPC_GETCELL__INT_,RPC_GETTOTALCELLNUMBER__,RPC_TRANSFEROBJECT__SCENEOBJECT_INT_BOOL_BOOL_,RPC_NOTIFYOBJECTINSERTEDTOCHILD__SCENEOBJECT_SCENEOBJECT_SCENEOBJECT_,RPC_NOTIFYOBJECTREMOVEDFROMCHILD__SCENEOBJECT_SCENEOBJECT_,RPC_GETCURRENTNUMBEROFPLAYERITEMS__,RPC_DESTROYALLPLAYERITEMS__,RPC_ONENTER__CREATUREOBJECT_,RPC_ONEXIT__CREATUREOBJECT_LONG_,RPC_ISBUILDINGOBJECT__,RPC_SETSIGNOBJECT__SIGNOBJECT_,RPC_GETSIGNOBJECT__,RPC_ISPUBLICSTRUCTURE__,RPC_ISPRIVATESTRUCTURE__,RPC_SETPUBLICSTRUCTURE__BOOL_,RPC_ISCONDEMNED__,RPC_GETMAPCELLSIZE__,RPC_TOGGLEPRIVACY__,RPC_GETMAXIMUMNUMBEROFPLAYERITEMS__,RPC_GETREDEEDMESSAGE__,RPC_HASACCESSFEE__,RPC_GETACCESSFEE__,RPC_CANCHANGEACCESSFEE__,RPC_SETACCESSFEE__INT_INT_,RPC_REMOVEACCESSFEE__,RPC_GETACCESSFEEDELAY__,RPC_PAYACCESSFEE__CREATUREOBJECT_,RPC_UPDATEPAIDACCESSLIST__,RPC_CREATECHILDOBJECTS__,RPC_SPAWNCHILDCREATURESFROMTEMPLATE__,RPC_HASTEMPLATECHILDCREATURES__,RPC_ISRESIDENCE__,RPC_SETRESIDENCE__BOOL_};
 
 BuildingObject::BuildingObject() : StructureObject(DummyConstructorParameter::instance()) {
        BuildingObjectImplementation* _implementation = new BuildingObjectImplementation();
@@ -847,30 +847,39 @@ void BuildingObject::createChildObjects() {
                _implementation->createChildObjects();
 }
 
-void BuildingObject::spawnChildCreatures() {
+void BuildingObject::spawnChildCreaturesFromTemplate() {
        BuildingObjectImplementation* _implementation = static_cast<BuildingObjectImplementation*>(_getImplementation());
        if (_implementation == NULL) {
                if (!deployed)
                        throw ObjectNotDeployedException(this);
 
-               DistributedMethod method(this, RPC_SPAWNCHILDCREATURES__);
+               DistributedMethod method(this, RPC_SPAWNCHILDCREATURESFROMTEMPLATE__);
 
                method.executeWithVoidReturn();
        } else
-               _implementation->spawnChildCreatures();
+               _implementation->spawnChildCreaturesFromTemplate();
 }
 
-bool BuildingObject::hasChildCreatures() {
+void BuildingObject::spawnChildCreature(String& mobile, int respawnTimer, float x, float z, float y, float heading, unsigned long long cellID) {
+       BuildingObjectImplementation* _implementation = static_cast<BuildingObjectImplementation*>(_getImplementation());
+       if (_implementation == NULL) {
+               throw ObjectNotLocalException(this);
+
+       } else
+               _implementation->spawnChildCreature(mobile, respawnTimer, x, z, y, heading, cellID);
+}
+
+bool BuildingObject::hasTemplateChildCreatures() {
        BuildingObjectImplementation* _implementation = static_cast<BuildingObjectImplementation*>(_getImplementation());
        if (_implementation == NULL) {
                if (!deployed)
                        throw ObjectNotDeployedException(this);
 
-               DistributedMethod method(this, RPC_HASCHILDCREATURES__);
+               DistributedMethod method(this, RPC_HASTEMPLATECHILDCREATURES__);
 
                return method.executeWithBooleanReturn();
        } else
-               return _implementation->hasChildCreatures();
+               return _implementation->hasTemplateChildCreatures();
 }
 
 bool BuildingObject::isResidence() {
@@ -1038,6 +1047,10 @@ bool BuildingObjectImplementation::readObjectMember(ObjectInputStream* stream, c
                TypeInfo<VectorMap<unsigned long long, unsigned int> >::parseFromBinaryStream(&paidAccessList, stream);
                return true;
 
+       case 0x2f655877: //BuildingObject.childCreatureObjects
+               TypeInfo<SortedVector<ManagedReference<CreatureObject* > > >::parseFromBinaryStream(&childCreatureObjects, stream);
+               return true;
+
        case 0xd1c7bb1c: //BuildingObject.publicStructure
                TypeInfo<bool >::parseFromBinaryStream(&publicStructure, stream);
                return true;
@@ -1124,6 +1137,14 @@ int BuildingObjectImplementation::writeObjectMembers(ObjectOutputStream* stream)
        _totalSize = (uint32) (stream->getOffset() - (_offset + 4));
        stream->writeInt(_offset, _totalSize);
 
+       _nameHashCode = 0x2f655877; //BuildingObject.childCreatureObjects
+       TypeInfo<uint32>::toBinaryStream(&_nameHashCode, stream);
+       _offset = stream->getOffset();
+       stream->writeInt(0);
+       TypeInfo<SortedVector<ManagedReference<CreatureObject* > > >::toBinaryStream(&childCreatureObjects, stream);
+       _totalSize = (uint32) (stream->getOffset() - (_offset + 4));
+       stream->writeInt(_offset, _totalSize);
+
        _nameHashCode = 0xd1c7bb1c; //BuildingObject.publicStructure
        TypeInfo<uint32>::toBinaryStream(&_nameHashCode, stream);
        _offset = stream->getOffset();
@@ -1149,7 +1170,7 @@ int BuildingObjectImplementation::writeObjectMembers(ObjectOutputStream* stream)
        stream->writeInt(_offset, _totalSize);
 
 
-       return _count + 10;
+       return _count + 11;
 }
 
 BuildingObjectImplementation::BuildingObjectImplementation() {
@@ -1584,14 +1605,14 @@ void BuildingObjectAdapter::invokeMethod(uint32 methid, DistributedMethod* inv)
                        createChildObjects();
                }
                break;
-       case RPC_SPAWNCHILDCREATURES__:
+       case RPC_SPAWNCHILDCREATURESFROMTEMPLATE__:
                {
-                       spawnChildCreatures();
+                       spawnChildCreaturesFromTemplate();
                }
                break;
-       case RPC_HASCHILDCREATURES__:
+       case RPC_HASTEMPLATECHILDCREATURES__:
                {
-                       resp->insertBoolean(hasChildCreatures());
+                       resp->insertBoolean(hasTemplateChildCreatures());
                }
                break;
        case RPC_ISRESIDENCE__:
@@ -1821,12 +1842,12 @@ void BuildingObjectAdapter::createChildObjects() {
        (static_cast<BuildingObject*>(stub))->createChildObjects();
 }
 
-void BuildingObjectAdapter::spawnChildCreatures() {
-       (static_cast<BuildingObject*>(stub))->spawnChildCreatures();
+void BuildingObjectAdapter::spawnChildCreaturesFromTemplate() {
+       (static_cast<BuildingObject*>(stub))->spawnChildCreaturesFromTemplate();
 }
 
-bool BuildingObjectAdapter::hasChildCreatures() {
-       return (static_cast<BuildingObject*>(stub))->hasChildCreatures();
+bool BuildingObjectAdapter::hasTemplateChildCreatures() {
+       return (static_cast<BuildingObject*>(stub))->hasTemplateChildCreatures();
 }
 
 bool BuildingObjectAdapter::isResidence() {
index a398289..8509838 100644 (file)
@@ -244,9 +244,11 @@ public:
 
        void createChildObjects();
 
-       void spawnChildCreatures();
+       void spawnChildCreaturesFromTemplate();
 
-       bool hasChildCreatures();
+       void spawnChildCreature(String& mobile, int respawnTimer, float x, float z, float y, float heading, unsigned long long cellID);
+
+       bool hasTemplateChildCreatures();
 
        bool isResidence();
 
@@ -297,6 +299,8 @@ protected:
 
        VectorMap<unsigned long long, unsigned int> paidAccessList;
 
+       SortedVector<ManagedReference<CreatureObject* > > childCreatureObjects;
+
 public:
        bool publicStructure;
 
@@ -440,9 +444,11 @@ public:
 
        void createChildObjects();
 
-       void spawnChildCreatures();
+       void spawnChildCreaturesFromTemplate();
+
+       void spawnChildCreature(String& mobile, int respawnTimer, float x, float z, float y, float heading, unsigned long long cellID);
 
-       bool hasChildCreatures();
+       bool hasTemplateChildCreatures();
 
        bool isResidence();
 
@@ -597,9 +603,9 @@ public:
 
        void createChildObjects();
 
-       void spawnChildCreatures();
+       void spawnChildCreaturesFromTemplate();
 
-       bool hasChildCreatures();
+       bool hasTemplateChildCreatures();
 
        bool isResidence();
 
index 4a5fe64..781e77e 100644 (file)
@@ -81,7 +81,10 @@ class BuildingObject extends StructureObject {
        
        @dereferenced
        protected VectorMap<unsigned long, unsigned int> paidAccessList;
-       
+
+       @dereferenced
+       protected SortedVector<CreatureObject> childCreatureObjects;
+
        public boolean publicStructure;
        
        public static final int MAXPLAYERITEMS = 400;
@@ -377,9 +380,12 @@ class BuildingObject extends StructureObject {
 
        public native void createChildObjects();
 
-       public native void spawnChildCreatures();
+       public native void spawnChildCreaturesFromTemplate();
+
+       @local
+       public native void spawnChildCreature(string mobile, int respawnTimer, float x, float z, float y, float heading, unsigned long cellID);
 
-       public native boolean hasChildCreatures();
+       public native boolean hasTemplateChildCreatures();
 
        public boolean isResidence(){
                return isOwnerResidence;
index 91926d0..23b9311 100644 (file)
@@ -567,6 +567,16 @@ void BuildingObjectImplementation::destroyObjectFromDatabase(
        if (signObject != NULL)
                signObject->destroyObjectFromDatabase(true);
 
+       //Remove all child creature objects from database
+       for (int i = 0; i < childCreatureObjects.size(); ++i) {
+               ManagedReference<CreatureObject*> child = childCreatureObjects.get(i);
+
+               if (child == NULL)
+                       continue;
+
+               child->destroyObjectFromDatabase(true);
+       }
+
        //Loop through the cells and delete all objects from the database.
 }
 
@@ -1200,7 +1210,7 @@ void BuildingObjectImplementation::createChildObjects(){
 
 }
 
-void BuildingObjectImplementation::spawnChildCreatures(){
+void BuildingObjectImplementation::spawnChildCreaturesFromTemplate(){
        SharedBuildingObjectTemplate* buildingTemplate = cast<SharedBuildingObjectTemplate*>(getObjectTemplate());
 
        if(buildingTemplate == NULL)
@@ -1265,12 +1275,33 @@ void BuildingObjectImplementation::spawnChildCreatures(){
                                ai->setRespawnTimer(child->getRespawnTimer());
                        }
 
-                       childObjects.put(creature);
+                       childCreatureObjects.put(creature);
                }
        }
 }
 
-bool BuildingObjectImplementation::hasChildCreatures(){
+void BuildingObjectImplementation::spawnChildCreature(String& mobile, int respawnTimer, float x, float z, float y, float heading, unsigned long long cellID){
+       CreatureManager* creatureManager = zone->getCreatureManager();
+
+       if(creatureManager == NULL)
+               return;
+
+       CreatureObject* creature = creatureManager->spawnCreature(mobile.hashCode(),0,x,z,y,cellID,false);
+
+       if(creature == NULL)
+               return;
+
+       creature->updateDirection(heading);
+
+       if(creature->isAiAgent()){
+               AiAgent* ai = cast<AiAgent*>(creature);
+               ai->setRespawnTimer(respawnTimer);
+       }
+
+       childCreatureObjects.put(creature);
+}
+
+bool BuildingObjectImplementation::hasTemplateChildCreatures(){
        SharedBuildingObjectTemplate* buildingTemplate = cast<SharedBuildingObjectTemplate*>(getObjectTemplate());
 
        if(buildingTemplate == NULL)
index c3da6e2..5a2259e 100644 (file)
@@ -21,12 +21,14 @@ Luna<LuaBuildingObject>::RegType LuaBuildingObject::Register[] = {
                { "getPositionZ", &LuaSceneObject::getPositionZ },
                { "getParentID", &LuaSceneObject::getParentID },
                { "getServerObjectCRC", &LuaSceneObject::getServerObjectCRC },
+               { "setFaction", &LuaTangibleObject::setFaction },
                { "grantPermission", &LuaBuildingObject::grantPermission },
                { "broadcastSpecificCellPermissions", &LuaBuildingObject::broadcastSpecificCellPermissions },
+               { "spawnChildCreature", &LuaBuildingObject::spawnChildCreature },
                { 0, 0 }
 };
 
-LuaBuildingObject::LuaBuildingObject(lua_State *L) : LuaSceneObject(L) {
+LuaBuildingObject::LuaBuildingObject(lua_State *L) : LuaTangibleObject(L) {
        realObject = (BuildingObject*)lua_touserdata(L, 1);
 }
 
@@ -70,3 +72,17 @@ int LuaBuildingObject::broadcastSpecificCellPermissions(lua_State* L) {
 
        return 0;
 }
+
+int LuaBuildingObject::spawnChildCreature(lua_State* L) {
+       uint64 parentID = lua_tointeger(L, -1);
+       float heading = lua_tonumber(L, -2);
+       float y = lua_tonumber(L, -3);
+       float z = lua_tonumber(L, -4);
+       float x = lua_tonumber(L, -5);
+       int respawnTimer = lua_tointeger(L, -6);
+       String mobile = lua_tostring(L, -7);
+
+       realObject->spawnChildCreature(mobile, respawnTimer, x, z, y, heading, parentID);
+
+       return 0;
+}
index 5d69fbd..cc959f7 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "engine/engine.h"
 
-#include "server/zone/objects/scene/LuaSceneObject.h"
+#include "server/zone/objects/tangible/LuaTangibleObject.h"
 
 namespace server {
 namespace zone {
@@ -18,7 +18,7 @@ namespace objects {
 namespace building {
        class BuildingObject;
 
-       class LuaBuildingObject : public LuaSceneObject {
+       class LuaBuildingObject : public LuaTangibleObject {
        public:
                // Constants
                static const char className[];
@@ -33,6 +33,7 @@ namespace building {
                int getCell(lua_State* L);
                int grantPermission(lua_State* L);
                int broadcastSpecificCellPermissions(lua_State* L);
+               int spawnChildCreature(lua_State* L);
 
        private:
                // The pointer to the 'real object' defined in object.cc
index 97932f1..ab3d207 100644 (file)
@@ -338,7 +338,6 @@ public:
        void addMinefield(int indx, uint64 minefieldOID){
                minefieldSlots.add(indx, minefieldOID);
        }
-       void spawnChildCreatures();
 
        bool isGCWBaseData(){
                return true;
index 5a0a8c6..bc15306 100644 (file)
@@ -17,8 +17,8 @@ void StructureZoneComponent::notifyInsertToZone(SceneObject* sceneObject, Zone*
 
        if(sceneObject->isGCWBase()){
                ManagedReference<BuildingObject*> building = cast<BuildingObject*>(sceneObject);
-               if(building->hasChildCreatures())
-                       building->spawnChildCreatures();
+               if(building->hasTemplateChildCreatures())
+                       building->spawnChildCreaturesFromTemplate();
        }
 }
 
index 17b0394..8f50206 100644 (file)
@@ -74,6 +74,18 @@ public:
                containmentType = containment;
        }
 
+       inline void setMobileName(String name) {
+               mobileName = name;
+       }
+
+       inline void setRespawnTime(int respawn) {
+               respawnTime = respawn;
+       }
+
+       inline void setHeading(float head) {
+               heading = head;
+       }
+
        inline Vector3& getPosition() {
                return position;
        }