1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Multiplayer: gracefully handle player loss unless it's a host

We don't want server to shutdown after just one of players lost the game.
This commit is contained in:
Arseniy Shestakov
2016-10-30 02:43:06 +03:00
parent c66c66c5ae
commit db5a52a0f8
4 changed files with 14 additions and 3 deletions

View File

@@ -391,7 +391,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
else
{
serv = con;
networkMode = (con->connectionID == 1) ? HOST : GUEST;
networkMode = con->isHost() ? HOST : GUEST;
}
CConnection &c = *serv;
@@ -693,7 +693,7 @@ void CClient::stopConnection()
{
terminate = true;
if (serv) //request closing connection
if (serv && serv->isHost()) //request closing connection
{
logNetwork->infoStream() << "Connection has been requested to be closed.";
boost::unique_lock<boost::mutex>(*serv->wmx);
@@ -1075,6 +1075,7 @@ CConnection * CServerHandler::justConnectToServer(const std::string &host, const
ret = new CConnection( host.size() ? host : settings["server"]["server"].String(),
realPort,
NAME);
ret->connectionID = 1; // TODO: Refactoring for the server so IDs set outside of CConnection
}
catch(...)
{