mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-21 12:06:49 +02:00
Merge pull request #687 from kambala-decapitator/fix-server-crash-client-disconnect
fix server crash on unexpected client disconnect
This commit is contained in:
commit
b310f2e61e
@ -1195,11 +1195,11 @@ void CGameHandler::handleClientDisconnection(std::shared_ptr<CConnection> c)
|
|||||||
{
|
{
|
||||||
for(auto playerConns : connections)
|
for(auto playerConns : connections)
|
||||||
{
|
{
|
||||||
for(auto conn : playerConns.second)
|
for(auto i = playerConns.second.begin(); i != playerConns.second.end(); )
|
||||||
{
|
{
|
||||||
if(lobby->state != EServerState::SHUTDOWN && conn == c)
|
if(lobby->state != EServerState::SHUTDOWN && *i == c)
|
||||||
{
|
{
|
||||||
vstd::erase_if_present(playerConns.second, conn);
|
i = playerConns.second.erase(i);
|
||||||
if(playerConns.second.size())
|
if(playerConns.second.size())
|
||||||
continue;
|
continue;
|
||||||
PlayerCheated pc;
|
PlayerCheated pc;
|
||||||
@ -1208,6 +1208,8 @@ void CGameHandler::handleClientDisconnection(std::shared_ptr<CConnection> c)
|
|||||||
sendAndApply(&pc);
|
sendAndApply(&pc);
|
||||||
checkVictoryLossConditionsForPlayer(playerConns.first);
|
checkVictoryLossConditionsForPlayer(playerConns.first);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5267,7 +5269,7 @@ void CGameHandler::checkVictoryLossConditionsForAll()
|
|||||||
void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)
|
void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)
|
||||||
{
|
{
|
||||||
const PlayerState * p = getPlayer(player);
|
const PlayerState * p = getPlayer(player);
|
||||||
if (p->status != EPlayerStatus::INGAME) return;
|
if (!p || p->status != EPlayerStatus::INGAME) return;
|
||||||
|
|
||||||
auto victoryLossCheckResult = gs->checkForVictoryAndLoss(player);
|
auto victoryLossCheckResult = gs->checkForVictoryAndLoss(player);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user