1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Bind server to a randomly assigned port

This commit is contained in:
Simeon Manolov
2024-07-12 00:39:36 +03:00
parent 719f920914
commit 9d73b50979
9 changed files with 57 additions and 32 deletions

View File

@@ -15,6 +15,7 @@
#include "../lib/logging/CBasicLogConfigurator.h"
#include "../lib/VCMIDirs.h"
#include "../lib/VCMI_Lib.h"
#include "../lib/CConfigHandler.h"
#include <boost/program_options.hpp>
@@ -86,12 +87,12 @@ int main(int argc, const char * argv[])
{
bool connectToLobby = opts.count("lobby");
bool runByClient = opts.count("runByClient");
uint16_t port = 3030;
uint16_t port = settings["server"]["localPort"].Integer();
if(opts.count("port"))
port = opts["port"].as<uint16_t>();
CVCMIServer server(port, connectToLobby, runByClient);
CVCMIServer server(port, runByClient);
server.prepare(connectToLobby);
server.run();
// CVCMIServer destructor must be called here - before VLC cleanup