From 7f7fb9750df3aceec48f65cee657e15364e0a911 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 11 Mar 2012 14:54:23 +0200 Subject: command-line/world game selection --- src/main.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 15 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 8b2ef3668..00776d89c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -69,6 +69,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "log.h" #include "mods.h" #include "utility_string.h" +#include "subgame.h" /* Settings. @@ -781,6 +782,8 @@ int main(int argc, char *argv[]) "Print more information to console")); allowed_options.insert("logfile", ValueSpec(VALUETYPE_STRING, "Set logfile path (debug.txt)")); + allowed_options.insert("gameid", ValueSpec(VALUETYPE_STRING, + "Set gameid")); #ifndef SERVER allowed_options.insert("speedtests", ValueSpec(VALUETYPE_FLAG, "Run speed tests")); @@ -958,22 +961,63 @@ int main(int argc, char *argv[]) port = 30000; // Map directory - 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"); + std::string world_path = porting::path_user + DIR_DELIM + "server" + DIR_DELIM + "worlds" + DIR_DELIM + "world"; + if(cmd_args.exists("world")) + world_path = cmd_args.get("world"); + else if(cmd_args.exists("map-dir")) + world_path = cmd_args.get("map-dir"); else if(g_settings->exists("map-dir")) - map_dir = g_settings->get("map-dir"); + world_path = 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)){ + std::string legacy_world_path = porting::path_user+DIR_DELIM+".."+DIR_DELIM+"world"; + if(!fs::PathExists(world_path) && fs::PathExists(legacy_world_path)){ errorstream<<"Warning: Using legacy world directory \"" - < gameids = getAvailableGameIds(); + infostream<<"Available gameids: "; + for(std::set::const_iterator i = gameids.begin(); + i != gameids.end(); i++) + infostream<<(*i)<<" "; + infostream<setMinHardwareBufferVertexCount(50); - // Set the window caption - device->setWindowCaption(L"Minetest [Main Menu]"); - // Create time getter g_timegetter = new IrrlichtTimeGetter(device); @@ -1154,6 +1195,8 @@ int main(int argc, char *argv[]) */ while(device->run() && kill == false) { + // Set the window caption + device->setWindowCaption(L"Minetest [Main Menu]"); // This is used for catching disconnects try @@ -1257,7 +1300,7 @@ int main(int argc, char *argv[]) // Delete map if requested if(menudata.delete_map) { - bool r = fs::RecursiveDeleteContent(map_dir); + bool r = fs::RecursiveDeleteContent(world_path); if(r == false) error_message = L"Delete failed"; continue; @@ -1303,14 +1346,15 @@ int main(int argc, char *argv[]) input, device, font, - map_dir, + world_path, playername, password, address, port, error_message, configpath, - chat_backend + chat_backend, + gamespec ); } //try -- cgit v1.2.3