Update comments and documentation

This commit is contained in:
Nauta Turbidus 2024-04-17 18:48:39 +02:00
parent 631d48dd16
commit be8f4de3c1
2 changed files with 10 additions and 3 deletions

View File

@ -93,6 +93,10 @@ The game directory can contain the following files:
an internal ID used to track versions.
* `textdomain`: Textdomain used to translate description. Defaults to game id.
See [Translating content meta](#translating-content-meta).
* `gameid_alias = <comma-separated aliases>`
e.g. `gameid_alias = aa,bb` (game has been named "aa" and then "bb" before)
This allows automatic loading of worlds using a gameid from this list.
This is intended to allow a full rename of a game, including its id.
* `minetest.conf`:
Used to set default settings when running this game.
* `settingtypes.txt`:

View File

@ -136,7 +136,7 @@ SubgameSpec findSubgame(const std::string &id)
std::string idv = id;
// Try to find aliased game
// Failed to find the game, try to find aliased game
if (game_path.empty()) {
std::vector<GameFindPath> gamespaths;
gamespaths.emplace_back(share + DIR_DELIM + "games", false);
@ -163,11 +163,13 @@ SubgameSpec findSubgame(const std::string &id)
if (conf.exists("gameid_alias")) {
std::string alias = conf.get("gameid_alias");
// Try direct matching with the alias
if (alias == id) {
idv = dln.name;
game_path = path + DIR_DELIM + dln.name;
user_game = gamespath.user_specific;
break;
// Make sure a "_game" suffix is ignored
} else if (str_ends_with(id, "_game")) {
std::string_view id_trimmed{id.c_str(), id.size() - 5};
if (id_trimmed == alias) {
@ -188,12 +190,13 @@ SubgameSpec findSubgame(const std::string &id)
}
}
if (!game_path.empty())
break;
break; // Aliased game has been found, escape the loop early
}
if (game_path.empty())
if (game_path.empty()) // Failed to find the game taking aliases into account
return SubgameSpec();
}
// Found the game, proceed
std::string gamemod_path = game_path + DIR_DELIM + "mods";