mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Show message about client connecting and disconnecting
This commit is contained in:
parent
930f03e812
commit
77ff6a64e6
@ -1324,25 +1324,22 @@ void CGameHandler::addGenericKilledLog(BattleLogMessage & blm, const CStack * de
|
||||
|
||||
void CGameHandler::handleClientDisconnection(std::shared_ptr<CConnection> c)
|
||||
{
|
||||
/*for(auto playerConns : connections)
|
||||
if(lobby->state == EServerState::SHUTDOWN || !gs || !gs->scenarioOps)
|
||||
return;
|
||||
|
||||
for(auto & playerConnections : connections)
|
||||
{
|
||||
for(auto i = playerConns.second.begin(); i != playerConns.second.end(); )
|
||||
PlayerColor playerId = playerConnections.first;
|
||||
auto & playerSettings = gs->scenarioOps->getIthPlayersSettings(playerId);
|
||||
for(auto & playerConnection : playerConnections.second)
|
||||
{
|
||||
if(lobby->state != EServerState::SHUTDOWN && *i == c)
|
||||
if(playerConnection == c)
|
||||
{
|
||||
i = playerConns.second.erase(i);
|
||||
if(playerConns.second.size())
|
||||
continue;
|
||||
PlayerCheated pc;
|
||||
pc.player = playerConns.first;
|
||||
pc.losingCheatCode = true;
|
||||
sendAndApply(&pc);
|
||||
checkVictoryLossConditionsForPlayer(playerConns.first);
|
||||
std::string messageText = boost::str(boost::format("%s (cid %d) was disconnected") % playerSettings.name % c->connectionID);
|
||||
playerMessage(playerId, messageText, ObjectInstanceID{});
|
||||
}
|
||||
else
|
||||
++i;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
void CGameHandler::handleReceivedPack(CPackForServer * pack)
|
||||
|
@ -346,14 +346,12 @@ void CVCMIServer::threadHandleClient(std::shared_ptr<CConnection> c)
|
||||
catch(boost::system::system_error & e)
|
||||
{
|
||||
logNetwork->error("Network error receiving a pack. Connection %s dies. What happened: %s", c->toString(), e.what());
|
||||
|
||||
if(state != EServerState::LOBBY)
|
||||
{
|
||||
hangingConnections.insert(c);
|
||||
connections.erase(c);
|
||||
//gh->handleClientDisconnection(c);
|
||||
gh->handleClientDisconnection(c);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -556,6 +554,9 @@ void CVCMIServer::reconnectPlayer(int connId)
|
||||
if(!playerSettings)
|
||||
continue;
|
||||
|
||||
std::string messageText = boost::str(boost::format("%s (cid %d) is connected") % playerSettings->name % connId);
|
||||
gh->playerMessage(playerSettings->color, messageText, ObjectInstanceID{});
|
||||
|
||||
PlayerReinitInterface startAiPack;
|
||||
startAiPack.player = playerSettings->color;
|
||||
startAiPack.playerConnectionId = connId;
|
||||
@ -563,7 +564,6 @@ void CVCMIServer::reconnectPlayer(int connId)
|
||||
}
|
||||
//gh->playerMessage(playerSettings->color, playerLeftMsgText, ObjectInstanceID{});
|
||||
//gh->connections[playerSettings->color].insert(hostClient);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user