diff options
author | emixa-d <85313564+emixa-d@users.noreply.github.com> | 2021-10-06 22:19:41 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-07 00:19:41 +0200 |
commit | 9fab5d594cab4c0a027f0aecf356382f3a37c1de (patch) | |
tree | a5bed4dfac50fcd76464dfb2010713fa4265e5e2 /src/content | |
parent | 53e126ac49807d066328377c7c06352b0fc1a380 (diff) | |
download | minetest-9fab5d594cab4c0a027f0aecf356382f3a37c1de.tar.gz minetest-9fab5d594cab4c0a027f0aecf356382f3a37c1de.tar.bz2 minetest-9fab5d594cab4c0a027f0aecf356382f3a37c1de.zip |
Add "MINETEST_MOD_PATH" environment variable (#11515)
This adds an environment variable MINETEST_MOD_PATH.
When it exists, Minetest will look there for mods in addition to ~/.minetest/mods/.
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/subgames.cpp | 14 | ||||
-rw-r--r-- | src/content/subgames.h | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/content/subgames.cpp b/src/content/subgames.cpp index e9dc609b0..30447c838 100644 --- a/src/content/subgames.cpp +++ b/src/content/subgames.cpp @@ -113,6 +113,10 @@ SubgameSpec findSubgame(const std::string &id) if (user != share || user_game) mods_paths.insert(user + DIR_DELIM + "mods"); + for (const std::string &mod_path : getEnvModPaths()) { + mods_paths.insert(mod_path); + } + // Get meta std::string conf_path = game_path + DIR_DELIM + "game.conf"; Settings conf; @@ -384,3 +388,13 @@ void loadGameConfAndInitWorld(const std::string &path, const std::string &name, if (new_game_settings) delete game_settings; } + +std::vector<std::string> getEnvModPaths() +{ + const char *c_mod_path = getenv("MINETEST_MOD_PATH"); + std::vector<std::string> paths; + Strfnd search_paths(c_mod_path ? c_mod_path : ""); + while (!search_paths.at_end()) + paths.push_back(search_paths.next(PATH_DELIM)); + return paths; +} diff --git a/src/content/subgames.h b/src/content/subgames.h index 60392639b..4a50803e8 100644 --- a/src/content/subgames.h +++ b/src/content/subgames.h @@ -58,6 +58,8 @@ SubgameSpec findWorldSubgame(const std::string &world_path); std::set<std::string> getAvailableGameIds(); std::vector<SubgameSpec> getAvailableGames(); +// Get the list of paths to mods in the environment variable $MINETEST_MOD_PATH +std::vector<std::string> getEnvModPaths(); bool getWorldExists(const std::string &world_path); //! Try to get the displayed name of a world |