1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +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

@@ -1097,7 +1097,7 @@ void CGameHandler::handleConnection(std::set<PlayerColor> players, CConnection &
{
assert(!c.connected); //make sure that connection has been marked as broken
logGlobal->error(e.what());
end2 = true;
conns -= &c;
}
catch(...)
{
@@ -2631,6 +2631,9 @@ void CGameHandler::sendToAllClients(CPackForClient * info)
logNetwork->trace("Sending to all clients a package of type %s", typeid(*info).name());
for (auto & elem : conns)
{
if(!elem->isOpen())
continue;
boost::unique_lock<boost::mutex> lock(*(elem)->wmx);
*elem << info;
}
@@ -2703,6 +2706,7 @@ void CGameHandler::close()
{
exit(0);
}
end2 = true;
//for (CConnection *cc : conns)
// if (cc && cc->socket && cc->socket->is_open())