1
0

Add support for alternate config file locations (#3578)

This commit is contained in:
Gareth Nelson
2017-02-22 13:10:32 +00:00
committed by Mattes D
parent c89b20695d
commit 1c31cb7eec
5 changed files with 19 additions and 2 deletions

View File

@@ -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();