mirror of https://github.com/minetest/minetest.git
Add gameid aliases
This commit is contained in:
parent
eb432d3da0
commit
b237a532e1
|
@ -134,8 +134,50 @@ SubgameSpec findSubgame(const std::string &id)
|
|||
}
|
||||
}
|
||||
|
||||
if (game_path.empty())
|
||||
return SubgameSpec();
|
||||
std::string idv = id;
|
||||
|
||||
// Try to find aliased game
|
||||
if (game_path.empty()) {
|
||||
std::vector<GameFindPath> gamespaths;
|
||||
gamespaths.emplace_back(share + DIR_DELIM + "games", false);
|
||||
gamespaths.emplace_back(user + DIR_DELIM + "games", true);
|
||||
|
||||
Strfnd search_paths(getSubgamePathEnv());
|
||||
|
||||
while (!search_paths.at_end())
|
||||
gamespaths.emplace_back(search_paths.next(PATH_DELIM), false);
|
||||
|
||||
for (const GameFindPath &gamespath : gamespaths) {
|
||||
const std::string &path = gamespath.path;
|
||||
std::vector<fs::DirListNode> dirlist = fs::GetDirListing(path);
|
||||
for (const fs::DirListNode &dln : dirlist) {
|
||||
if (!dln.dir)
|
||||
continue;
|
||||
|
||||
// If configuration file is not found or broken, ignore game
|
||||
Settings conf;
|
||||
std::string conf_path = path + DIR_DELIM + dln.name +
|
||||
DIR_DELIM + "game.conf";
|
||||
if (!conf.readConfigFile(conf_path.c_str()))
|
||||
continue;
|
||||
|
||||
if (conf.exists("gameid_alias")) {
|
||||
std::string alias = conf.get("gameid_alias");
|
||||
if (alias == id) {
|
||||
idv = dln.name;
|
||||
game_path = path + DIR_DELIM + dln.name;
|
||||
user_game = gamespath.user_specific;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!game_path.empty())
|
||||
break;
|
||||
}
|
||||
|
||||
if (game_path.empty())
|
||||
return SubgameSpec();
|
||||
}
|
||||
|
||||
std::string gamemod_path = game_path + DIR_DELIM + "mods";
|
||||
|
||||
|
@ -160,7 +202,7 @@ SubgameSpec findSubgame(const std::string &id)
|
|||
else if (conf.exists("name"))
|
||||
game_title = conf.get("name");
|
||||
else
|
||||
game_title = id;
|
||||
game_title = idv;
|
||||
|
||||
std::string game_author;
|
||||
if (conf.exists("author"))
|
||||
|
@ -176,7 +218,7 @@ SubgameSpec findSubgame(const std::string &id)
|
|||
game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png");
|
||||
#endif
|
||||
|
||||
SubgameSpec spec(id, game_path, gamemod_path, mods_paths, game_title,
|
||||
SubgameSpec spec(idv, game_path, gamemod_path, mods_paths, game_title,
|
||||
menuicon_path, game_author, game_release);
|
||||
|
||||
if (conf.exists("name") && !conf.exists("title"))
|
||||
|
|
Loading…
Reference in New Issue