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/subgames.cpp | |
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/subgames.cpp')
-rw-r--r-- | src/content/subgames.cpp | 14 |
1 files changed, 14 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; +} |