mirror of https://github.com/OpenTTD/OpenTTD.git
Fix: prevent clients making emergency saves twice if server disconnects (#8477)
This was clearly overlooked during the initial implementation.
This commit is contained in:
parent
46e13e7f0b
commit
c288eba813
|
@ -211,16 +211,23 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res)
|
|||
default: errorno = NETWORK_ERROR_GENERAL; break;
|
||||
}
|
||||
|
||||
/* This means we fucked up and the server closed the connection */
|
||||
if (res != NETWORK_RECV_STATUS_SERVER_ERROR && res != NETWORK_RECV_STATUS_SERVER_FULL &&
|
||||
res != NETWORK_RECV_STATUS_SERVER_BANNED) {
|
||||
if (res == NETWORK_RECV_STATUS_SERVER_ERROR || res == NETWORK_RECV_STATUS_SERVER_FULL ||
|
||||
res == NETWORK_RECV_STATUS_SERVER_BANNED) {
|
||||
/* This means the server closed the connection. Emergency save is
|
||||
* already created if this was appropriate during handling of the
|
||||
* disconnect. */
|
||||
this->CloseConnection(res);
|
||||
} else {
|
||||
/* This means we as client made a boo-boo. */
|
||||
SendError(errorno);
|
||||
|
||||
/* Close connection before we make an emergency save, as the save can
|
||||
* take a bit of time; better that the server doesn't stall while we
|
||||
* are doing the save, and already disconnects us. */
|
||||
this->CloseConnection(res);
|
||||
ClientNetworkEmergencySave();
|
||||
}
|
||||
|
||||
this->CloseConnection(res);
|
||||
|
||||
ClientNetworkEmergencySave();
|
||||
|
||||
_switch_mode = SM_MENU;
|
||||
_networking = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue