summaryrefslogtreecommitdiff
path: root/src/subgame.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2013-03-21 18:48:21 +0200
committerPerttu Ahola <celeron55@gmail.com>2013-03-21 18:56:42 +0200
commit306d1ab866a3ce820e95f4faf805684cd4122ae4 (patch)
tree0cc350601b241216e9a05f4460d6f6c4009fc3d1 /src/subgame.cpp
parent9b5bb5c7559953db40b52dead3c85e1a1245b4f1 (diff)
downloadminetest-306d1ab866a3ce820e95f4faf805684cd4122ae4.tar.gz
minetest-306d1ab866a3ce820e95f4faf805684cd4122ae4.tar.bz2
minetest-306d1ab866a3ce820e95f4faf805684cd4122ae4.zip
Common mods support
Implement "common mods", includeable from {$user,$share}/games/common/$modname by using the game.conf setting common_mods = $modname,$modname2,...
Diffstat (limited to 'src/subgame.cpp')
-rw-r--r--src/subgame.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/subgame.cpp b/src/subgame.cpp
index 3c8bf53c5..8678ae37f 100644
--- a/src/subgame.cpp
+++ b/src/subgame.cpp
@@ -24,12 +24,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "log.h"
#include "util/string.h"
-std::string getGameName(const std::string &game_path)
+bool getGameConfig(const std::string &game_path, Settings &conf)
{
std::string conf_path = game_path + DIR_DELIM + "game.conf";
+ return conf.readConfigFile(conf_path.c_str());
+}
+
+std::string getGameName(const std::string &game_path)
+{
Settings conf;
- bool succeeded = conf.readConfigFile(conf_path.c_str());
- if(!succeeded)
+ if(!getGameConfig(game_path, conf))
return "";
if(!conf.exists("name"))
return "";
@@ -117,6 +121,11 @@ std::set<std::string> getAvailableGameIds()
for(u32 j=0; j<dirlist.size(); j++){
if(!dirlist[j].dir)
continue;
+ // If configuration file is not found or broken, ignore game
+ Settings conf;
+ if(!getGameConfig(*i + DIR_DELIM + dirlist[j].name, conf))
+ continue;
+ // Add it to result
const char *ends[] = {"_game", NULL};
std::string shorter = removeStringEnd(dirlist[j].name, ends);
if(shorter != "")