Performance fixes.
[oweals/minetest.git] / src / server.cpp
index 161aaafc71a96196290655c318e7ba06605b4e8b..c948427ad559b3c584f1f8910f39a43d9c87cb21 100644 (file)
@@ -295,6 +295,12 @@ Server::Server(
        // Lock environment
        JMutexAutoLock envlock(m_env_mutex);
 
+       // Load mapgen params from Settings
+       m_emerge->loadMapgenParams();
+
+       // Create the Map (loads map_meta.txt, overriding configured mapgen params)
+       ServerMap *servermap = new ServerMap(path_world, this, m_emerge);
+
        // Initialize scripting
        infostream<<"Server: Initializing Lua"<<std::endl;
 
@@ -302,10 +308,8 @@ Server::Server(
 
        std::string scriptpath = getBuiltinLuaPath() + DIR_DELIM "init.lua";
 
-       if (!m_script->loadScript(scriptpath)) {
+       if (!m_script->loadScript(scriptpath))
                throw ModError("Failed to load and run " + scriptpath);
-       }
-
 
        // Print 'em
        infostream<<"Server: Loading mods: ";
@@ -336,22 +340,16 @@ Server::Server(
        // Apply item aliases in the node definition manager
        m_nodedef->updateAliases(m_itemdef);
 
+       m_nodedef->setNodeRegistrationStatus(true);
+
        // Perform pending node name resolutions
        m_nodedef->runNodeResolverCallbacks();
 
-       // Load the mapgen params from global settings now after any
-       // initial overrides have been set by the mods
-       m_emerge->loadMapgenParams();
-
        // Initialize Environment
-       ServerMap *servermap = new ServerMap(path_world, this, m_emerge);
        m_env = new ServerEnvironment(servermap, m_script, this, m_path_world);
 
        m_clients.setEnv(m_env);
 
-       // Run some callbacks after the MG params have been set up but before activation
-       m_script->environment_OnMapgenInit(&m_emerge->params);
-
        // Initialize mapgens
        m_emerge->initMapgens();
 
@@ -1361,7 +1359,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                u8 client_max = data[2];
                u8 our_max = SER_FMT_VER_HIGHEST_READ;
                // Use the highest version supported by both
-               u8 deployed = std::min(client_max, our_max);
+               int deployed = std::min(client_max, our_max);
                // If it's lower than the lowest supported, give up.
                if(deployed < SER_FMT_VER_LOWEST)
                        deployed = SER_FMT_VER_INVALID;
@@ -1510,7 +1508,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                                                <<"tried to connect from "<<addr_s<<" "
                                                <<"but it was disallowed for the following reason: "
                                                <<reason<<std::endl;
-                               DenyAccess(peer_id, narrow_to_wide(reason.c_str()));
+                               DenyAccess(peer_id, narrow_to_wide(reason));
                                return;
                        }
                }