Permalink
Browse files

Support game-specific minetest.conf

  • Loading branch information...
1 parent adc52f3 commit eab8247538c8117f25103d464507ddcab3ef4d60 @celeron55 committed Mar 21, 2013
Showing with 30 additions and 0 deletions.
  1. +3 −0 doc/lua_api.txt
  2. +9 −0 src/defaultsettings.cpp
  3. +1 −0 src/defaultsettings.h
  4. +8 −0 src/server.cpp
  5. +6 −0 src/subgame.cpp
  6. +3 −0 src/subgame.h
View
@@ -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:
@@ -243,3 +243,12 @@ void set_default_settings(Settings *settings)
}
+void override_default_settings(Settings *settings, Settings *from)
+{
+ std::vector<std::string> names = from->getNames();
+ for(size_t i=0; i<names.size(); i++){
+ const std::string &name = names[i];
+ settings->setDefault(name, from->get(name));
+ }
+}
+
@@ -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
View
@@ -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: "<<m_path_config<<std::endl;
infostream<<"- game: "<<m_gamespec.path<<std::endl;
+ // Initialize default settings and override defaults with those provided
+ // by the game
+ set_default_settings(g_settings);
+ Settings gamedefaults;
+ getGameMinetestConfig(gamespec.path, gamedefaults);
+ override_default_settings(g_settings, &gamedefaults);
+
// Create biome definition manager
m_biomedef = new BiomeDefManager(this);
View
@@ -24,6 +24,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "log.h"
#include "util/string.h"
+bool getGameMinetestConfig(const std::string &game_path, Settings &conf)
+{
+ std::string conf_path = game_path + DIR_DELIM + "minetest.conf";
+ return conf.readConfigFile(conf_path.c_str());
+}
+
bool getGameConfig(const std::string &game_path, Settings &conf)
{
std::string conf_path = game_path + DIR_DELIM + "game.conf";
View
@@ -54,6 +54,9 @@ struct SubgameSpec
}
};
+// minetest.conf
+bool getGameMinetestConfig(const std::string &game_path, Settings &conf);
+// game.conf
bool getGameConfig(const std::string &game_path, Settings &conf);
std::string getGameName(const std::string &game_path);

0 comments on commit eab8247

Please sign in to comment.