diff options
author | Gareth Nelson <gareth@garethnelson.com> | 2017-02-22 14:10:32 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2017-02-22 14:10:32 +0100 |
commit | 1c31cb7eecc92d2fb218da8948e3201b618a46d2 (patch) | |
tree | 48212c2758941cd4bc1115fa8bdd91356c341d65 | |
parent | Add 1.11.1/1.11.2 protocol (#3575) (diff) | |
download | cuberite-1c31cb7eecc92d2fb218da8948e3201b618a46d2.tar cuberite-1c31cb7eecc92d2fb218da8948e3201b618a46d2.tar.gz cuberite-1c31cb7eecc92d2fb218da8948e3201b618a46d2.tar.bz2 cuberite-1c31cb7eecc92d2fb218da8948e3201b618a46d2.tar.lz cuberite-1c31cb7eecc92d2fb218da8948e3201b618a46d2.tar.xz cuberite-1c31cb7eecc92d2fb218da8948e3201b618a46d2.tar.zst cuberite-1c31cb7eecc92d2fb218da8948e3201b618a46d2.zip |
-rw-r--r-- | CONTRIBUTORS | 1 | ||||
-rw-r--r-- | src/Bindings/PluginManager.cpp | 2 | ||||
-rw-r--r-- | src/Root.cpp | 8 | ||||
-rw-r--r-- | src/Root.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 8 |
5 files changed, 19 insertions, 2 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 0f7ff964c..84186be46 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -10,6 +10,7 @@ derouinw Diusrex Duralex FakeTruth (founder) +Gareth Nelson HaoTNN Howaner jan64 diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index e190abe15..714fa03f6 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -111,7 +111,7 @@ void cPluginManager::RefreshPluginList(void) void cPluginManager::ReloadPluginsNow(void) { cIniFile a_SettingsIni; - a_SettingsIni.ReadFile("settings.ini"); + a_SettingsIni.ReadFile(cRoot::Get()->m_SettingsFilename); ReloadPluginsNow(a_SettingsIni); } diff --git a/src/Root.cpp b/src/Root.cpp index 37fbf125f..508d0a648 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -141,8 +141,14 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo) LOG("Reading server config..."); + m_SettingsFilename = "settings.ini"; + if (a_OverridesRepo->HasValue("Server","ConfigFile")) + { + m_SettingsFilename = a_OverridesRepo->GetValue("Server","ConfigFile"); + } + auto IniFile = cpp14::make_unique<cIniFile>(); - bool IsNewIniFile = !IniFile->ReadFile("settings.ini"); + bool IsNewIniFile = !IniFile->ReadFile(m_SettingsFilename); if (IsNewIniFile) { diff --git a/src/Root.h b/src/Root.h index 10848ea3f..3595848d9 100644 --- a/src/Root.h +++ b/src/Root.h @@ -52,6 +52,8 @@ public: static bool m_TerminateEventRaised; static bool m_RunAsService; + /** which ini file to load settings from, default is settings.ini */ + AString m_SettingsFilename; cRoot(void); ~cRoot(); diff --git a/src/main.cpp b/src/main.cpp index 83056bf61..4ae54511b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,8 @@ #include <csignal> #include <stdlib.h> + + #ifdef ANDROID // Workaround for Android NDK builds that do not support std::to_string namespace std @@ -381,6 +383,7 @@ static std::unique_ptr<cMemorySettingsRepository> ParseArguments(int argc, char // Parse the comand line args: TCLAP::CmdLine cmd("Cuberite"); TCLAP::ValueArg<int> slotsArg ("s", "max-players", "Maximum number of slots for the server to use, overrides setting in setting.ini", false, -1, "number", cmd); + TCLAP::ValueArg<AString> confArg ("c", "config-file", "Config file to use", false, "settings.ini", "string", cmd); TCLAP::MultiArg<int> portsArg ("p", "port", "The port number the server should listen to", false, "port", cmd); TCLAP::SwitchArg commLogArg ("", "log-comm", "Log server client communications to file", cmd); TCLAP::SwitchArg commLogInArg ("", "log-comm-in", "Log inbound server client communications to file", cmd); @@ -393,6 +396,11 @@ static std::unique_ptr<cMemorySettingsRepository> ParseArguments(int argc, char // Copy the parsed args' values into a settings repository: auto repo = cpp14::make_unique<cMemorySettingsRepository>(); + if (confArg.isSet()) + { + AString conf_file = confArg.getValue(); + repo->AddValue("Server", "ConfigFile", conf_file); + } if (slotsArg.isSet()) { int slots = slotsArg.getValue(); |