From 790108746678cf48023eb98e17644d3364e37486 Mon Sep 17 00:00:00 2001 From: cx384 Date: Mon, 12 Feb 2024 23:21:19 +0100 Subject: [PATCH] Rename `MINETEST_SUBGAME_PATH` to `MINETEST_GAME_PATH` (#14351) --- doc/minetest.6 | 2 +- src/content/subgames.cpp | 15 ++++++++++++++- src/unittest/test_servermodmanager.cpp | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/doc/minetest.6 b/doc/minetest.6 index 06062721e..dcd38501f 100644 --- a/doc/minetest.6 +++ b/doc/minetest.6 @@ -119,7 +119,7 @@ Display an interactive terminal over ncurses during execution. .SH ENVIRONMENT .TP -.B MINETEST_SUBGAME_PATH +.B MINETEST_GAME_PATH Colon delimited list of directories to search for games. .TP .B MINETEST_MOD_PATH diff --git a/src/content/subgames.cpp b/src/content/subgames.cpp index c50c6f429..c1d8189e6 100644 --- a/src/content/subgames.cpp +++ b/src/content/subgames.cpp @@ -77,8 +77,21 @@ struct GameFindPath std::string getSubgamePathEnv() { + static bool has_warned = false; char *subgame_path = getenv("MINETEST_SUBGAME_PATH"); - return subgame_path ? std::string(subgame_path) : ""; + if (subgame_path && !has_warned) { + warningstream << "MINETEST_SUBGAME_PATH is deprecated, use MINETEST_GAME_PATH instead." + << std::endl; + has_warned = true; + } + + char *game_path = getenv("MINETEST_GAME_PATH"); + + if (game_path) + return std::string(game_path); + else if (subgame_path) + return std::string(subgame_path); + return ""; } SubgameSpec findSubgame(const std::string &id) diff --git a/src/unittest/test_servermodmanager.cpp b/src/unittest/test_servermodmanager.cpp index 30b02f184..f023e3a3b 100644 --- a/src/unittest/test_servermodmanager.cpp +++ b/src/unittest/test_servermodmanager.cpp @@ -82,7 +82,7 @@ void TestServerModManager::runTests(IGameDef *gamedef) TEST(testGetModNames); TEST(testGetModMediaPathsWrongDir); TEST(testGetModMediaPaths); - // TODO: test MINETEST_SUBGAME_PATH + // TODO: test MINETEST_GAME_PATH unsetenv("MINETEST_MOD_PATH"); }