diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-05-20 17:41:40 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-05-20 17:41:40 +0300 |
commit | 388906ac70ff13c4a2b88833872b9123034f5d1a (patch) | |
tree | b9d24eda2eb257ec427f80a81f9eaeff290840de /src | |
parent | 49d9745dc4bd88cccd0b77ad6fb5767acd5ddbf7 (diff) | |
download | minetest-388906ac70ff13c4a2b88833872b9123034f5d1a.tar.gz minetest-388906ac70ff13c4a2b88833872b9123034f5d1a.tar.bz2 minetest-388906ac70ff13c4a2b88833872b9123034f5d1a.zip |
Allow using --worldname for local game too
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/src/main.cpp b/src/main.cpp index ec305d4bf..a990032df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1037,6 +1037,31 @@ int main(int argc, char *argv[]) } } + // If a world name was specified, convert it to a path + if(commanded_worldname != ""){ + // Get information about available worlds + std::vector<WorldSpec> worldspecs = getAvailableWorlds(); + bool found = false; + for(u32 i=0; i<worldspecs.size(); i++){ + std::string name = worldspecs[i].name; + if(name == commanded_worldname){ + if(commanded_world != ""){ + dstream<<"--worldname takes precedence over previously " + <<"selected world."<<std::endl; + } + commanded_world = worldspecs[i].path; + found = true; + break; + } + } + if(!found){ + dstream<<"World '"<<commanded_worldname<<"' not " + <<"available. Available worlds:"<<std::endl; + print_worldspecs(worldspecs, dstream); + return 1; + } + } + // Gamespec SubgameSpec commanded_gamespec; if(cmd_args.exists("gameid")){ @@ -1074,25 +1099,6 @@ int main(int argc, char *argv[]) infostream<<"Using commanded world path ["<<world_path<<"]" <<std::endl; } - // If a world name was specified, select it - else if(commanded_worldname != ""){ - // Get information about available worlds - std::vector<WorldSpec> worldspecs = getAvailableWorlds(); - world_path = ""; - for(u32 i=0; i<worldspecs.size(); i++){ - std::string name = worldspecs[i].name; - if(name == commanded_worldname){ - world_path = worldspecs[i].path; - break; - } - } - if(world_path == ""){ - dstream<<"World '"<<commanded_worldname<<"' not " - <<"available. Available worlds:"<<std::endl; - print_worldspecs(worldspecs, dstream); - return 1; - } - } // No world was specified; try to select it automatically else { @@ -1207,8 +1213,6 @@ int main(int argc, char *argv[]) address = ""; else if(cmd_args.exists("address")) address = cmd_args.get("address"); - else if(cmd_args.exists("world")) - address = ""; std::string playername = g_settings->get("name"); if(cmd_args.exists("name")) |