mirror of
https://github.com/minetest/minetest.git
synced 2024-08-18 20:44:16 +02:00
Support game-specific minetest.conf
This commit is contained in:
parent
adc52f3f3c
commit
c2250d95c4
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user