aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-13 01:32:21 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-03-13 01:46:19 +0200
commit71a3c2fcd13051dbaed45c69107a6e6b4a94cfe8 (patch)
tree0251c4848a519fe5accf7964529a22a873a87822 /src/main.cpp
parent4ff36696ea0451c9017cc98d5cc29b0998badba5 (diff)
downloadminetest-71a3c2fcd13051dbaed45c69107a6e6b4a94cfe8.tar.gz
minetest-71a3c2fcd13051dbaed45c69107a6e6b4a94cfe8.tar.bz2
minetest-71a3c2fcd13051dbaed45c69107a6e6b4a94cfe8.zip
Allow directly supplying world as a parameter, including world.mt
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 4ce73f633..e01e59a33 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -806,7 +806,7 @@ int main(int argc, char *argv[])
bool ret = cmd_args.parseCommandLine(argc, argv, allowed_options);
- if(ret == false || cmd_args.getFlag("help"))
+ if(ret == false || cmd_args.getFlag("help") || cmd_args.exists("nonopt1"))
{
dstream<<"Allowed options:"<<std::endl;
for(core::map<std::string, ValueSpec>::Iterator
@@ -979,9 +979,23 @@ int main(int argc, char *argv[])
commanded_world = cmd_args.get("world");
else if(cmd_args.exists("map-dir"))
commanded_world = cmd_args.get("map-dir");
+ else if(cmd_args.exists("nonopt0"))
+ commanded_world = cmd_args.get("nonopt0");
else if(g_settings->exists("map-dir"))
commanded_world = g_settings->get("map-dir");
+ // Strip world.mt from commanded_world
+ {
+ std::string worldmt = "world.mt";
+ if(commanded_world.size() > worldmt.size() &&
+ commanded_world.substr(commanded_world.size()-worldmt.size())
+ == worldmt){
+ dstream<<"Supplied world.mt file - stripping it off."<<std::endl;
+ commanded_world = commanded_world.substr(
+ 0, commanded_world.size()-worldmt.size());
+ }
+ }
+
// Gamespec
SubgameSpec commanded_gamespec;
if(cmd_args.exists("gameid")){
@@ -1065,7 +1079,9 @@ int main(int argc, char *argv[])
*/
std::string address = g_settings->get("address");
- if(cmd_args.exists("address"))
+ if(commanded_world != "")
+ address = "";
+ else if(cmd_args.exists("address"))
address = cmd_args.get("address");
else if(cmd_args.exists("world"))
address = "";
@@ -1294,9 +1310,10 @@ int main(int argc, char *argv[])
std::string gameid = getWorldGameId(commanded_world, true);
if(gameid == "")
gameid = g_settings->get("default_game");
- WorldSpec spec(commanded_world, "--world", gameid);
+ WorldSpec spec(commanded_world, "[--world parameter]",
+ gameid);
worldspecs.push_back(spec);
- menudata.selected_world = menudata.worlds.size()-1;
+ menudata.selected_world = worldspecs.size()-1;
}
// Copy worldspecs to menu
menudata.worlds = worldspecs;