]> git.lizzy.rs Git - minetest.git/blobdiff - src/main.cpp
Initial directory structure rework
[minetest.git] / src / main.cpp
index b7c3ceffe3dfdd57409ba5e4a28a2ce464e43872..322d84e9e0896d9ef6666bb542b4828da207ab5f 100644 (file)
@@ -54,24 +54,6 @@ A list of "active blocks" in which stuff happens. (+=done)
                + This was left to be done by the old system and it sends only the
                  nearest ones.
 
-Vim conversion regexpes for moving to extended content type storage:
-%s/\(\.\|->\)d \([!=]=\)/\1getContent() \2/g
-%s/content_features(\([^.]*\)\.d)/content_features(\1)/g
-%s/\(\.\|->\)d = \([^;]*\);/\1setContent(\2);/g
-%s/\(getNodeNoExNoEmerge([^)]*)\)\.d/\1.getContent()/g
-%s/\(getNodeNoExNoEmerge(.*)\)\.d/\1.getContent()/g
-%s/\.d;/.getContent();/g
-%s/\(content_liquid\|content_flowing_liquid\|make_liquid_flowing\|content_pointable\)(\([^.]*\).d)/\1(\2.getContent())/g
-Other things to note:
-- node.d = node.param0 (only in raw serialization; use getContent() otherwise)
-- node.param = node.param1
-- node.dir = node.param2
-- content_walkable(node.d) etc should be changed to
-  content_features(node).walkable etc
-- Also check for lines that store the result of getContent to a 8-bit
-  variable and fix them (result of getContent() must be stored in
-  content_t, which is 16-bit)
-
 NOTE: Seeds in 1260:6c77e7dbfd29:
 5721858502589302589:
        Spawns you on a small sand island with a surface dungeon
@@ -351,8 +333,6 @@ TODO: Block cube placement around player's head
 TODO: Protocol version field
 TODO: Think about using same bits for material for fences and doors, for
          example
-TODO: Move mineral to param2, increment map serialization version, add
-      conversion
 
 SUGG: Restart irrlicht completely when coming back to main menu from game.
        - This gets rid of everything that is stored in irrlicht's caches.
@@ -419,8 +399,6 @@ Doing currently:
 #include "filesys.h"
 #include "config.h"
 #include "guiMainMenu.h"
-#include "mineral.h"
-#include "materials.h"
 #include "game.h"
 #include "keycode.h"
 #include "tile.h"
@@ -1106,22 +1084,31 @@ int main(int argc, char *argv[])
        
        // List all allowed options
        core::map<std::string, ValueSpec> allowed_options;
-       allowed_options.insert("help", ValueSpec(VALUETYPE_FLAG));
+       allowed_options.insert("help", ValueSpec(VALUETYPE_FLAG,
+                       "Show allowed options"));
        allowed_options.insert("server", ValueSpec(VALUETYPE_FLAG,
                        "Run server directly"));
        allowed_options.insert("config", ValueSpec(VALUETYPE_STRING,
                        "Load configuration from specified file"));
-       allowed_options.insert("port", ValueSpec(VALUETYPE_STRING));
-       allowed_options.insert("address", ValueSpec(VALUETYPE_STRING));
-       allowed_options.insert("random-input", ValueSpec(VALUETYPE_FLAG));
-       allowed_options.insert("disable-unittests", ValueSpec(VALUETYPE_FLAG));
-       allowed_options.insert("enable-unittests", ValueSpec(VALUETYPE_FLAG));
-       allowed_options.insert("map-dir", ValueSpec(VALUETYPE_STRING));
+       allowed_options.insert("port", ValueSpec(VALUETYPE_STRING,
+                       "Set network port to connect to"));
+       allowed_options.insert("address", ValueSpec(VALUETYPE_STRING,
+                       "Address to connect to"));
+       allowed_options.insert("random-input", ValueSpec(VALUETYPE_FLAG,
+                       "Enable random user input, for testing"));
+       allowed_options.insert("disable-unittests", ValueSpec(VALUETYPE_FLAG,
+                       "Disable unit tests"));
+       allowed_options.insert("enable-unittests", ValueSpec(VALUETYPE_FLAG,
+                       "Enable unit tests"));
+       allowed_options.insert("map-dir", ValueSpec(VALUETYPE_STRING,
+                       "Map directory (where everything in the world is stored)"));
 #ifdef _WIN32
        allowed_options.insert("dstream-on-stderr", ValueSpec(VALUETYPE_FLAG));
 #endif
-       allowed_options.insert("speedtests", ValueSpec(VALUETYPE_FLAG));
-       allowed_options.insert("info-on-stderr", ValueSpec(VALUETYPE_FLAG));
+       allowed_options.insert("speedtests", ValueSpec(VALUETYPE_FLAG,
+                       "Run speed tests"));
+       allowed_options.insert("info-on-stderr", ValueSpec(VALUETYPE_FLAG,
+                       "Print debug information to console"));
 
        Settings cmd_args;
        
@@ -1170,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
@@ -1234,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
 
@@ -1260,16 +1248,6 @@ int main(int argc, char *argv[])
        srand(time(0));
        mysrand(time(0));
 
-       /*
-               Pre-initialize some stuff with a dummy irrlicht wrapper.
-
-               These are needed for unit tests at least.
-       */
-       
-       // Must be called before texturesource is created
-       // (for texture atlas making)
-       init_mineral();
-
        /*
                Run unit tests
        */
@@ -1301,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"))
@@ -1316,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