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

Remove network connection from local games

This removes need for TCP network connection in single-player games.

Instead, game will now create internal pseudo-connection that performs
client<->server communication by posting sent messages to client/server
asio::io_service'a.

This should fix gameplay aborting on switching to another app on iOS (and
apparently, on Android in some cases)
This commit is contained in:
Ivan Savenko
2025-02-02 17:47:37 +00:00
parent e113622dc3
commit d9244cf061
12 changed files with 141 additions and 5 deletions

View File

@@ -206,9 +206,13 @@ void CServerHandler::connectToServer(const std::string & addr, const ui16 port)
Settings remotePort = settings.write["server"]["remotePort"];
remotePort->Integer() = port;
}
networkHandler->connectToRemote(*this, addr, port);
networkHandler->connectToRemote(*this, addr, port);
}
else
{
serverRunner->connect(*networkHandler, *this, addr, port);
}
}
void CServerHandler::onConnectionFailed(const std::string & errorMessage)
@@ -245,7 +249,7 @@ void CServerHandler::onTimer()
}
assert(isServerLocal());
networkHandler->connectToRemote(*this, getLocalHostname(), getLocalPort());
serverRunner->connect(*networkHandler, *this, getLocalHostname(), getLocalPort());
}
void CServerHandler::onConnectionEstablished(const NetworkConnectionPtr & netConnection)