sao prototype global variables no longer depend on link order to be correctly added...
authorsapier <sapier at gmx dot net>
Sun, 15 Jan 2012 18:43:31 +0000 (19:43 +0100)
committersapier <sapier at gmx dot net>
Sun, 15 Jan 2012 18:43:31 +0000 (19:43 +0100)
src/serverobject.cpp
src/serverobject.h

index ca3d2c3b98d2790de87d64905446a6fb0e273e99..b5fd6fc3a249d2f1fe358dcd718aa547625e7a11 100644 (file)
@@ -43,8 +43,8 @@ ServerActiveObject* ServerActiveObject::create(u8 type,
                const std::string &data)
 {
        // Find factory function
-       core::map<u16, Factory>::Node *n;
-       n = m_types.find(type);
+       core::map<u8, Factory>::Node *n;
+       n = ServerActiveObject::getTypes().find(type);
        if(n == NULL)
        {
                // If factory is not found, just return.
@@ -58,13 +58,13 @@ ServerActiveObject* ServerActiveObject::create(u8 type,
        return object;
 }
 
-void ServerActiveObject::registerType(u16 type, Factory f)
+void ServerActiveObject::registerType(u8 type, Factory f)
 {
-       core::map<u16, Factory>::Node *n;
-       n = m_types.find(type);
+       core::map<u8, Factory>::Node *n;
+       n = ServerActiveObject::getTypes().find(type);
        if(n)
                return;
-       m_types.insert(type, f);
+       ServerActiveObject::getTypes().insert(type, f);
 }
 
 void ServerActiveObject::getWieldDiggingProperties(ToolDiggingProperties *dst)
index fd8a51a9e06d716f7145aa2a9439ded617a669eb..d2627c87ef74149b152a8c315ec30a4886d56aaf 100644 (file)
@@ -200,14 +200,17 @@ protected:
        typedef ServerActiveObject* (*Factory)
                        (ServerEnvironment *env, v3f pos,
                        const std::string &data);
-       static void registerType(u16 type, Factory f);
+       static void registerType(u8 type, Factory f);
 
        ServerEnvironment *m_env;
        v3f m_base_position;
 
 private:
-       // Used for creating objects based on type
-       static core::map<u16, Factory> m_types;
+    static core::map<u8, Factory>& getTypes()
+    {
+        static core::map<u8, Factory> types;
+        return types;
+    }
 };
 
 #endif