aboutsummaryrefslogtreecommitdiff
path: root/src/subgame.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-26 23:02:12 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-03-26 23:02:12 +0300
commit53f7eef05247378e02bfde328f7b5e2dbac4be44 (patch)
tree4371ecc3ebbbb39dff27cca3c1f8460c7507ab08 /src/subgame.cpp
parent405347769a2f8c73aead3bc2b64fdc4d81763921 (diff)
downloadminetest-53f7eef05247378e02bfde328f7b5e2dbac4be44.tar.gz
minetest-53f7eef05247378e02bfde328f7b5e2dbac4be44.tar.bz2
minetest-53f7eef05247378e02bfde328f7b5e2dbac4be44.zip
Add game.conf check in subgame.cpp
Diffstat (limited to 'src/subgame.cpp')
-rw-r--r--src/subgame.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/subgame.cpp b/src/subgame.cpp
index d7668b0e5..9a8ebe69f 100644
--- a/src/subgame.cpp
+++ b/src/subgame.cpp
@@ -23,6 +23,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h"
#include "log.h"
+std::string getGameName(const std::string &game_path)
+{
+ std::string conf_path = game_path + DIR_DELIM + "game.conf";
+ Settings conf;
+ bool succeeded = conf.readConfigFile(conf_path.c_str());
+ if(!succeeded)
+ return "";
+ if(!conf.exists("name"))
+ return "";
+ return conf.get("name");
+}
+
SubgameSpec findSubgame(const std::string &id)
{
if(id == "")
@@ -46,7 +58,9 @@ SubgameSpec findSubgame(const std::string &id)
if(user != share || user_game)
mods_paths.insert(user + DIR_DELIM + "mods" + DIR_DELIM + id);
// TODO: Read proper name from game_path/game.conf
- std::string game_name = id;
+ std::string game_name = getGameName(game_path);
+ if(game_name == "")
+ game_name = id;
return SubgameSpec(id, game_path, mods_paths, game_name);
}