aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-04-08 23:15:50 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-04-08 23:17:02 +0300
commit42323014eaf359f76b388e75e788486bb0bda280 (patch)
tree46490264492dd1d69fc5b3528f5406d31ae64b08 /src/main.cpp
parentc59d139eebf06680bb4ea019b9a952c20e334154 (diff)
downloadminetest-42323014eaf359f76b388e75e788486bb0bda280.tar.gz
minetest-42323014eaf359f76b388e75e788486bb0bda280.tar.bz2
minetest-42323014eaf359f76b388e75e788486bb0bda280.zip
Support placing a minetest game inside $world/game to allow creating proper adventure maps
Pro-tip: You can open a world in minetest by opening the world.mt file using minetest.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 8ec4c2632..c1ed70faf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1135,43 +1135,44 @@ int main(int argc, char *argv[])
}
verbosestream<<"Using world path ["<<world_path<<"]"<<std::endl;
- // We need a gameid.
- std::string gameid;
- verbosestream<<"Determining gameid"<<std::endl;
+ // We need a gamespec.
+ SubgameSpec gamespec;
+ verbosestream<<"Determining gameid/gamespec"<<std::endl;
// If world doesn't exist
if(!getWorldExists(world_path))
{
// Try to take gamespec from command line
if(commanded_gamespec.isValid()){
- gameid = commanded_gamespec.id;
- infostream<<"Using commanded gameid ["<<gameid<<"]"<<std::endl;
+ gamespec = commanded_gamespec;
+ infostream<<"Using commanded gameid ["<<gamespec.id<<"]"<<std::endl;
}
// Otherwise we will be using "minetest"
else{
- gameid = g_settings->get("default_game");
- infostream<<"Using default gameid ["<<gameid<<"]"<<std::endl;
+ gamespec = findSubgame(g_settings->get("default_game"));
+ infostream<<"Using default gameid ["<<gamespec.id<<"]"<<std::endl;
}
}
- // If world exists
+ // World exists
else
{
- // Otherwise read from the world
std::string world_gameid = getWorldGameId(world_path, is_legacy_world);
- gameid = world_gameid;
- if(commanded_gamespec.isValid() &&
- commanded_gamespec.id != world_gameid){
- gameid = commanded_gamespec.id;
- errorstream<<"WARNING: Using commanded gameid ["<<gameid<<"]"
- <<" instead of world gameid ["<<world_gameid
- <<"]"<<std::endl;
+ // If commanded to use a gameid, do so
+ if(commanded_gamespec.isValid()){
+ gamespec = commanded_gamespec;
+ if(commanded_gamespec.id != world_gameid){
+ errorstream<<"WARNING: Using commanded gameid ["
+ <<gamespec.id<<"]"<<" instead of world gameid ["
+ <<world_gameid<<"]"<<std::endl;
+ }
} else{
- infostream<<"Using world gameid ["<<gameid<<"]"<<std::endl;
+ // If world contains an embedded game, use it;
+ // Otherwise find world from local system.
+ gamespec = findWorldSubgame(world_path);
+ infostream<<"Using world gameid ["<<gamespec.id<<"]"<<std::endl;
}
}
- verbosestream<<"Finding subgame ["<<gameid<<"]"<<std::endl;
- SubgameSpec gamespec = findSubgame(gameid);
if(!gamespec.isValid()){
- errorstream<<"Subgame ["<<gameid<<"] could not be found."
+ errorstream<<"Subgame ["<<gamespec.id<<"] could not be found."
<<std::endl;
return 1;
}
@@ -1602,7 +1603,7 @@ int main(int argc, char *argv[])
continue;
}
// Load gamespec for required game
- gamespec = findSubgame(worldspec.gameid);
+ gamespec = findWorldSubgame(worldspec.path);
if(!gamespec.isValid() && !commanded_gamespec.isValid()){
error_message = L"Could not find or load game \""
+ narrow_to_wide(worldspec.gameid) + L"\"";