From 6779036d25e460ca5e8c6d290772e78c3277ccfc Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 25 Mar 2012 20:29:56 +0300 Subject: Make server world selection not brain dead and use gameid 'minetest' instead of 'mesetint' --- src/defaultsettings.cpp | 2 +- src/main.cpp | 152 +++++++++++++++++++++++++++++++++++++++--------- src/subgame.cpp | 15 ++++- src/subgame.h | 1 + 4 files changed, 140 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index a777ed736..5d4c969e3 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -101,7 +101,7 @@ void set_default_settings(Settings *settings) // Server stuff // "map-dir" doesn't exist by default. - settings->setDefault("default_game", "mesetint"); + settings->setDefault("default_game", "minetest"); settings->setDefault("motd", ""); settings->setDefault("max_users", "100"); settings->setDefault("strict_protocol_version_checking", "true"); diff --git a/src/main.cpp b/src/main.cpp index fe1bcd450..41b62b1dd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -739,6 +739,20 @@ void SpeedTests() } } +static void print_worldspecs(const std::vector &worldspecs, + std::ostream &os) +{ + for(u32 i=0; iexists("map-dir")) commanded_world = g_settings->get("map-dir"); + // World name + std::string commanded_worldname = ""; + if(cmd_args.exists("worldname")) + commanded_worldname = cmd_args.get("worldname"); + // Strip world.mt from commanded_world { std::string worldmt = "world.mt"; @@ -1037,21 +1058,74 @@ int main(int argc, char *argv[]) // World directory std::string world_path; + verbosestream<<"Determining world path"< worldspecs = getAvailableWorlds(); + world_path = ""; + for(u32 i=0; i worldspecs = getAvailableWorlds(); + // If a world name was specified, select it + if(commanded_worldname != ""){ + world_path = ""; + for(u32 i=0; i 1){ + dstream<<"Multiple worlds are available."<" + <<" or --world "<get("default_game"); + infostream<<"Using default gameid ["< getAvailableGames() return specs; } -#define LEGACY_GAMEID "mesetint" +#define LEGACY_GAMEID "minetest" + +bool getWorldExists(const std::string &world_path) +{ + return (fs::PathExists(world_path + DIR_DELIM + "map_meta.txt") || + fs::PathExists(world_path + DIR_DELIM + "world.mt")); +} std::string getWorldGameId(const std::string &world_path, bool can_be_legacy) { @@ -95,6 +101,9 @@ std::string getWorldGameId(const std::string &world_path, bool can_be_legacy) } if(!conf.exists("gameid")) return ""; + // The "mesetint" gameid has been discarded + if(conf.get("gameid") == "mesetint") + return "minetest"; return conf.get("gameid"); } @@ -113,7 +122,9 @@ std::vector getAvailableWorlds() continue; std::string fullpath = *i + DIR_DELIM + dirvector[j].name; std::string name = dirvector[j].name; - std::string gameid = getWorldGameId(fullpath); + // Just allow filling in the gameid always for now + bool can_be_legacy = true; + std::string gameid = getWorldGameId(fullpath, can_be_legacy); WorldSpec spec(fullpath, name, gameid); if(!spec.isValid()){ infostream<<"(invalid: "< getAvailableGameIds(); std::vector getAvailableGames(); +bool getWorldExists(const std::string &world_path); std::string getWorldGameId(const std::string &world_path, bool can_be_legacy=false); -- cgit v1.2.3