From 1c31cb7eecc92d2fb218da8948e3201b618a46d2 Mon Sep 17 00:00:00 2001 From: Gareth Nelson Date: Wed, 22 Feb 2017 13:10:32 +0000 Subject: Add support for alternate config file locations (#3578) --- src/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/main.cpp') 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 #include + + #ifdef ANDROID // Workaround for Android NDK builds that do not support std::to_string namespace std @@ -381,6 +383,7 @@ static std::unique_ptr ParseArguments(int argc, char // Parse the comand line args: TCLAP::CmdLine cmd("Cuberite"); TCLAP::ValueArg slotsArg ("s", "max-players", "Maximum number of slots for the server to use, overrides setting in setting.ini", false, -1, "number", cmd); + TCLAP::ValueArg confArg ("c", "config-file", "Config file to use", false, "settings.ini", "string", cmd); TCLAP::MultiArg 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 ParseArguments(int argc, char // Copy the parsed args' values into a settings repository: auto repo = cpp14::make_unique(); + if (confArg.isSet()) + { + AString conf_file = confArg.getValue(); + repo->AddValue("Server", "ConfigFile", conf_file); + } if (slotsArg.isSet()) { int slots = slotsArg.getValue(); -- cgit v1.2.3