From 80a1054060006e9e6c3f87d8c0826b1f620789f1 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 6 Sep 2014 13:21:46 -0400 Subject: [PATCH] Search for subgames using $MINETEST_SUBGAME_PATH. --- src/subgame.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/subgame.cpp b/src/subgame.cpp index f2465c9..24a4af5 100644 --- a/src/subgame.cpp +++ b/src/subgame.cpp @@ -66,6 +66,19 @@ SubgameSpec findSubgame(const std::string &id) std::string share = porting::path_share; std::string user = porting::path_user; std::vector find_paths; + + char *search_paths = getenv("MINETEST_SUBGAME_PATH"); + char *search_path = strtok(search_paths, ":"); + + while(search_path != NULL) { + std::string path = std::string(search_path); + find_paths.push_back(GameFindPath( + path + DIR_DELIM + id, false)); + find_paths.push_back(GameFindPath( + path + DIR_DELIM + id + "_game", false)); + search_path = strtok(NULL, ":"); + } + find_paths.push_back(GameFindPath( user + DIR_DELIM + "games" + DIR_DELIM + id + "_game", true)); find_paths.push_back(GameFindPath( @@ -129,6 +142,15 @@ std::set getAvailableGameIds() std::set gamespaths; gamespaths.insert(porting::path_share + DIR_DELIM + "games"); gamespaths.insert(porting::path_user + DIR_DELIM + "games"); + + char *search_paths = getenv("MINETEST_SUBGAME_PATH"); + char *search_path = strtok(search_paths, ":"); + + while(search_path != NULL) { + gamespaths.insert(std::string(search_path)); + search_path = strtok(NULL, ":"); + } + for(std::set::const_iterator i = gamespaths.begin(); i != gamespaths.end(); i++){ std::vector dirlist = fs::GetDirListing(*i); -- 2.1.0