From 306d1ab866a3ce820e95f4faf805684cd4122ae4 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Thu, 21 Mar 2013 18:48:21 +0200 Subject: Common mods support Implement "common mods", includeable from {$user,$share}/games/common/$modname by using the game.conf setting common_mods = $modname,$modname2,... --- src/subgame.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/subgame.h') diff --git a/src/subgame.h b/src/subgame.h index 8561c1a52..996714be0 100644 --- a/src/subgame.h +++ b/src/subgame.h @@ -24,6 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include +class Settings; + #define WORLDNAME_BLACKLISTED_CHARS "/\\" struct SubgameSpec @@ -52,6 +54,8 @@ struct SubgameSpec } }; +bool getGameConfig(const std::string &game_path, Settings &conf); + std::string getGameName(const std::string &game_path); SubgameSpec findSubgame(const std::string &id); -- cgit v1.2.3 From c2250d95c4da368d1535794a1c7f2092ce479d7a Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Thu, 21 Mar 2013 21:42:23 +0200 Subject: Support game-specific minetest.conf --- doc/lua_api.txt | 3 +++ src/defaultsettings.cpp | 9 +++++++++ src/defaultsettings.h | 1 + src/server.cpp | 8 ++++++++ src/subgame.cpp | 6 ++++++ src/subgame.h | 3 +++ 6 files changed, 30 insertions(+) (limited to 'src/subgame.h') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 19fa81473..af8b1cc9a 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -57,6 +57,9 @@ eg. Common mods are loaded from the pseudo-game "common". +The game directory can contain the file minetest.conf, which will be used +to set default settings when running the particular game. + Mod load path ------------- Generic: diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index b0ae271ce..25edffe32 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -243,3 +243,12 @@ void set_default_settings(Settings *settings) } +void override_default_settings(Settings *settings, Settings *from) +{ + std::vector names = from->getNames(); + for(size_t i=0; isetDefault(name, from->get(name)); + } +} + diff --git a/src/defaultsettings.h b/src/defaultsettings.h index 37e3f717f..00aacad87 100644 --- a/src/defaultsettings.h +++ b/src/defaultsettings.h @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., class Settings; void set_default_settings(Settings *settings); +void override_default_settings(Settings *settings, Settings *from); #endif diff --git a/src/server.cpp b/src/server.cpp index 2dcab63b8..f77ac6ad9 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -58,6 +58,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "util/mathconstants.h" #include "rollback.h" #include "util/serialize.h" +#include "defaultsettings.h" void * ServerThread::Thread() { @@ -687,6 +688,13 @@ Server::Server( infostream<<"- config: "<