From 2e98bfc4e98c1cb0730514628d501c2ca0326c4e Mon Sep 17 00:00:00 2001 From: tycho Date: Mon, 18 May 2015 16:04:27 +0100 Subject: Add support for setting ports through command line --- src/main.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 2cf4b383e..8a237b8ee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -372,6 +372,8 @@ std::unique_ptr parseArguments(int argc, char **argv) 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::MultiArg portsArg("p", "port", "The port number the server should listen to", false, "port", cmd); + cmd.parse(argc, argv); auto repo = cpp14::make_unique(); @@ -381,8 +383,17 @@ std::unique_ptr parseArguments(int argc, char **argv) int slots = slotsArg.getValue(); - repo->SetValueI("Server", "MaxPlayers", slots); + repo->AddValue("Server", "MaxPlayers", static_cast(slots)); + + } + if (portsArg.isSet()) + { + std::vector ports = portsArg.getValue(); + for (auto port : ports) + { + repo->AddValue("Server", "Port", static_cast(port)); + } } repo->SetReadOnly(); -- cgit v1.2.3