]> git.lizzy.rs Git - minetest.git/blobdiff - src/main.cpp
Initial directory structure rework
[minetest.git] / src / main.cpp
index ec999c5300574b25aa19e6ad7c28d791e59b5d41..322d84e9e0896d9ef6666bb542b4828da207ab5f 100644 (file)
@@ -1157,19 +1157,18 @@ int main(int argc, char *argv[])
        porting::signal_handler_init();
        bool &kill = *porting::signal_handler_killstatus();
        
-       // Initialize porting::path_data and porting::path_userdata
        porting::initializePaths();
 
        // Create user data directory
-       fs::CreateDir(porting::path_userdata);
+       fs::CreateDir(porting::path_user);
 
-       init_gettext((porting::path_data+DIR_DELIM+".."+DIR_DELIM+"locale").c_str());
+       init_gettext((porting::path_share+DIR_DELIM+".."+DIR_DELIM+"locale").c_str());
        
        // Initialize debug streams
 #ifdef RUN_IN_PLACE
        std::string debugfile = DEBUGFILE;
 #else
-       std::string debugfile = porting::path_userdata+DIR_DELIM+DEBUGFILE;
+       std::string debugfile = porting::path_user+DIR_DELIM+DEBUGFILE;
 #endif
        debugstreams_init(disable_stderr, debugfile.c_str());
        // Initialize debug stacks
@@ -1221,10 +1220,12 @@ int main(int argc, char *argv[])
        else
        {
                core::array<std::string> filenames;
-               filenames.push_back(porting::path_userdata +
+               filenames.push_back(porting::path_user +
                                DIR_DELIM + "minetest.conf");
 #ifdef RUN_IN_PLACE
-               filenames.push_back(porting::path_userdata +
+               // Try also from a lower level (to aid having the same configuration
+               // for many RUN_IN_PLACE installs)
+               filenames.push_back(porting::path_user +
                                DIR_DELIM + ".." + DIR_DELIM + "minetest.conf");
 #endif
 
@@ -1278,11 +1279,22 @@ int main(int argc, char *argv[])
                port = 30000;
        
        // Map directory
-       std::string map_dir = porting::path_userdata+DIR_DELIM+"world";
+       std::string map_dir = porting::path_user + DIR_DELIM + "server" + DIR_DELIM + "worlds" + DIR_DELIM + "world";
        if(cmd_args.exists("map-dir"))
                map_dir = cmd_args.get("map-dir");
        else if(g_settings->exists("map-dir"))
                map_dir = g_settings->get("map-dir");
+       else{
+               // No map-dir option was specified.
+               // Check if the world is found from the default directory, and if
+               // not, see if the legacy world directory exists.
+               std::string legacy_map_dir = porting::path_user+DIR_DELIM+".."+DIR_DELIM+"world";
+               if(!fs::PathExists(map_dir) && fs::PathExists(legacy_map_dir)){
+                       errorstream<<"Warning: Using legacy world directory \""
+                                       <<legacy_map_dir<<"\""<<std::endl;
+                       map_dir = legacy_map_dir;
+               }
+       }
        
        // Run dedicated server if asked to
        if(cmd_args.getFlag("server"))
@@ -1293,7 +1305,7 @@ int main(int argc, char *argv[])
                g_timegetter = new SimpleTimeGetter();
                
                // Create server
-               Server server(map_dir.c_str(), configpath);
+               Server server(map_dir, configpath, "mesetint");
                server.start(port);
                
                // Run server