SAO: re-add old ActiveObjectTypes for a future migration layer
authorLoic Blot <loic.blot@unix-experience.fr>
Tue, 17 Feb 2015 10:37:55 +0000 (11:37 +0100)
committerLoic Blot <loic.blot@unix-experience.fr>
Tue, 17 Feb 2015 10:37:55 +0000 (11:37 +0100)
src/activeobject.h
src/clientobject.cpp
src/clientobject.h
src/environment.cpp
src/serverobject.cpp
src/serverobject.h

index 3dd1f98f524bd2be5eb5e4fd942a056c96b27271..76893280a5a504831af04e04122f0022cffa8eaf 100644 (file)
@@ -27,6 +27,11 @@ enum ActiveObjectType {
        ACTIVEOBJECT_TYPE_INVALID = 0,
        ACTIVEOBJECT_TYPE_TEST = 1,
        ACTIVEOBJECT_TYPE_ITEM = 2,
+       // Compat layer, migrating objects from 0.3 to 0.4+
+       ACTIVEOBJECT_TYPE_RAT = 3,
+       ACTIVEOBJECT_TYPE_OERKKI1 = 4,
+       ACTIVEOBJECT_TYPE_FIREFLY = 5,
+       ACTIVEOBJECT_TYPE_MOBV2 = 6,
        ACTIVEOBJECT_TYPE_LUAENTITY = 7,
 // Special type, not stored as a static object
        ACTIVEOBJECT_TYPE_PLAYER = 100,
index 37f693c5e1310d0b4306fa9ff720b684db1e9adf..ae1be092fb601f57c9d08ec1b57ffc1de3387414 100644 (file)
@@ -39,14 +39,13 @@ ClientActiveObject::~ClientActiveObject()
        removeFromScene(true);
 }
 
-ClientActiveObject* ClientActiveObject::create(u8 type, IGameDef *gamedef,
-               ClientEnvironment *env)
+ClientActiveObject* ClientActiveObject::create(ActiveObjectType type,
+               IGameDef *gamedef, ClientEnvironment *env)
 {
        // Find factory function
        std::map<u16, Factory>::iterator n;
        n = m_types.find(type);
-       if(n == m_types.end())
-       {
+       if(n == m_types.end()) {
                // If factory is not found, just return.
                dstream<<"WARNING: ClientActiveObject: No factory for type="
                                <<(int)type<<std::endl;
index 24150628eaa20ca6274469e0b3e24d972b5b9c36..4a77139e2bc59f23215b91192ab7cd9d87470e33 100644 (file)
@@ -86,7 +86,7 @@ public:
        virtual void initialize(const std::string &data){}
 
        // Create a certain type of ClientActiveObject
-       static ClientActiveObject* create(u8 type, IGameDef *gamedef,
+       static ClientActiveObject* create(ActiveObjectType type, IGameDef *gamedef,
                        ClientEnvironment *env);
 
        // If returns true, punch will not be sent to the server
index e1f79803b22de3878aeea71499a9cd9ca7b7afea..166523a4fa8c257276f2d27353b28a7f779f3b0b 100644 (file)
@@ -1700,7 +1700,7 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s)
                StaticObject &s_obj = *i;
                // Create an active object from the data
                ServerActiveObject *obj = ServerActiveObject::create
-                               (s_obj.type, this, 0, s_obj.pos, s_obj.data);
+                               ((ActiveObjectType) s_obj.type, this, 0, s_obj.pos, s_obj.data);
                // If couldn't create object, store static data back.
                if(obj==NULL)
                {
@@ -2488,7 +2488,7 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type,
                const std::string &init_data)
 {
        ClientActiveObject* obj =
-                       ClientActiveObject::create(type, m_gamedef, this);
+                       ClientActiveObject::create((ActiveObjectType) type, m_gamedef, this);
        if(obj == NULL)
        {
                infostream<<"ClientEnvironment::addActiveObject(): "
index 81307bc34f23a69d5f51f8e80bcc96d8b6fb6c9d..98d82550fb7c574dac09cc6b3a068755e58166a6 100644 (file)
@@ -38,15 +38,14 @@ ServerActiveObject::~ServerActiveObject()
 {
 }
 
-ServerActiveObject* ServerActiveObject::create(u8 type,
+ServerActiveObject* ServerActiveObject::create(ActiveObjectType type,
                ServerEnvironment *env, u16 id, v3f pos,
                const std::string &data)
 {
        // Find factory function
        std::map<u16, Factory>::iterator n;
        n = m_types.find(type);
-       if(n == m_types.end())
-       {
+       if(n == m_types.end()) {
                // If factory is not found, just return.
                dstream<<"WARNING: ServerActiveObject: No factory for type="
                                <<type<<std::endl;
index 96485d7a38123184aa72b5346499dcb2ed2a1269..878c37773e0fff64a7d025b8dee3a5af13a55898 100644 (file)
@@ -71,7 +71,7 @@ public:
        { return true; }
        
        // Create a certain type of ServerActiveObject
-       static ServerActiveObject* create(u8 type,
+       static ServerActiveObject* create(ActiveObjectType type,
                        ServerEnvironment *env, u16 id, v3f pos,
                        const std::string &data);