mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-08 22:26:51 +02:00
Fix crash on attempting to connect newly created lobby room
This commit is contained in:
@@ -80,27 +80,25 @@ CVCMIServer::CVCMIServer(uint16_t port, bool runByClient)
|
|||||||
|
|
||||||
CVCMIServer::~CVCMIServer() = default;
|
CVCMIServer::~CVCMIServer() = default;
|
||||||
|
|
||||||
uint16_t CVCMIServer::prepare(bool connectToLobby, bool listenForConnections) {
|
uint16_t CVCMIServer::prepare(bool connectToLobby, bool listenForConnections)
|
||||||
if(connectToLobby) {
|
{
|
||||||
|
if(connectToLobby)
|
||||||
lobbyProcessor = std::make_unique<GlobalLobbyProcessor>(*this);
|
lobbyProcessor = std::make_unique<GlobalLobbyProcessor>(*this);
|
||||||
return 0;
|
|
||||||
} else {
|
return startAcceptingIncomingConnections(listenForConnections);
|
||||||
return startAcceptingIncomingConnections(listenForConnections);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t CVCMIServer::startAcceptingIncomingConnections(bool listenForConnections)
|
uint16_t CVCMIServer::startAcceptingIncomingConnections(bool listenForConnections)
|
||||||
{
|
{
|
||||||
networkServer = networkHandler->createServerTCP(*this);
|
networkServer = networkHandler->createServerTCP(*this);
|
||||||
|
|
||||||
port
|
|
||||||
? logNetwork->info("Port %d will be used", port)
|
|
||||||
: logNetwork->info("Randomly assigned port will be used");
|
|
||||||
|
|
||||||
// config port may be 0 => srvport will contain the OS-assigned port value
|
|
||||||
|
|
||||||
if (listenForConnections)
|
if (listenForConnections)
|
||||||
{
|
{
|
||||||
|
// config port may be 0 => srvport will contain the OS-assigned port value
|
||||||
|
port
|
||||||
|
? logNetwork->info("Port %d will be used", port)
|
||||||
|
: logNetwork->info("Randomly assigned port will be used");
|
||||||
|
|
||||||
auto srvport = networkServer->start(port);
|
auto srvport = networkServer->start(port);
|
||||||
logNetwork->info("Listening for connections at port %d", srvport);
|
logNetwork->info("Listening for connections at port %d", srvport);
|
||||||
return srvport;
|
return srvport;
|
||||||
|
@@ -99,7 +99,6 @@ void GlobalLobbyProcessor::receiveServerLoginSuccess(const JsonNode & json)
|
|||||||
{
|
{
|
||||||
// no-op, wait just for any new commands from lobby
|
// no-op, wait just for any new commands from lobby
|
||||||
logGlobal->info("Lobby: Successfully connected to lobby server");
|
logGlobal->info("Lobby: Successfully connected to lobby server");
|
||||||
owner.startAcceptingIncomingConnections(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalLobbyProcessor::receiveAccountJoinsRoom(const JsonNode & json)
|
void GlobalLobbyProcessor::receiveAccountJoinsRoom(const JsonNode & json)
|
||||||
|
Reference in New Issue
Block a user