aboutsummaryrefslogtreecommitdiff
path: root/src/subgame.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-13 00:06:37 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-03-13 00:06:37 +0200
commit591527d8787b6dfaafd2113bc001fe892b3eb0fb (patch)
tree8c6391f41af9b027779329c8ce68358099a781cc /src/subgame.cpp
parent82073025ccc551c2fd205cc1dc6fcecac61cc7ea (diff)
downloadminetest-591527d8787b6dfaafd2113bc001fe892b3eb0fb.tar.gz
minetest-591527d8787b6dfaafd2113bc001fe892b3eb0fb.tar.bz2
minetest-591527d8787b6dfaafd2113bc001fe892b3eb0fb.zip
World creation button and dialog and functionality
Diffstat (limited to 'src/subgame.cpp')
-rw-r--r--src/subgame.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/subgame.cpp b/src/subgame.cpp
index 2fa3b7944..58881ecb8 100644
--- a/src/subgame.cpp
+++ b/src/subgame.cpp
@@ -46,7 +46,9 @@ SubgameSpec findSubgame(const std::string &id)
+ DIR_DELIM + id);
addon_paths.insert(user_server + DIR_DELIM + "addons"
+ DIR_DELIM + id);
- return SubgameSpec(id, game_path, addon_paths);
+ // TODO: Read proper name from game_path/game.conf
+ std::string game_name = id;
+ return SubgameSpec(id, game_path, addon_paths, game_name);
}
std::set<std::string> getAvailableGameIds()
@@ -69,6 +71,16 @@ std::set<std::string> getAvailableGameIds()
return gameids;
}
+std::vector<SubgameSpec> getAvailableGames()
+{
+ std::vector<SubgameSpec> specs;
+ std::set<std::string> gameids = getAvailableGameIds();
+ for(std::set<std::string>::const_iterator i = gameids.begin();
+ i != gameids.end(); i++)
+ specs.push_back(findSubgame(*i));
+ return specs;
+}
+
#define LEGACY_GAMEID "mesetint"
std::string getWorldGameId(const std::string &world_path, bool can_be_legacy)
@@ -132,4 +144,18 @@ std::vector<WorldSpec> getAvailableWorlds()
return worlds;
}
+bool initializeWorld(const std::string &path, const std::string &gameid)
+{
+ infostream<<"Initializing world at "<<path<<std::endl;
+ // Create world.mt if does not already exist
+ std::string worldmt_path = path + DIR_DELIM + "world.mt";
+ if(!fs::PathExists(worldmt_path)){
+ infostream<<"Creating world.mt ("<<worldmt_path<<")"<<std::endl;
+ fs::CreateAllDirs(path);
+ std::ofstream of(worldmt_path.c_str(), std::ios::binary);
+ of<<"gameid = "<<gameid<<"\n";
+ }
+ return true;
+}
+