summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2019-02-28 19:36:27 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-03-03 12:12:32 +0100
commitc61acc7fc1fc6bbc1e5b1d0a782e74ecf16a9a23 (patch)
treed844afc46f7527aa687d86f8b041e556b78feca2
parentc91e0058c27ac3f837de2735e2ce5fcfcd50b6ab (diff)
downloadopenttd-c61acc7fc1fc6bbc1e5b1d0a782e74ecf16a9a23.tar.xz
Fix #7280: Save in the right location on desync and server timeout
-rw-r--r--src/network/network_client.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index b4d0a06f7..0cb7728e6 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -125,6 +125,7 @@ struct PacketReader : LoadFilter {
void ClientNetworkEmergencySave()
{
if (!_settings_client.gui.autosave_on_network_disconnect) return;
+ if (!_networking) return;
const char *filename = "netsave.sav";
DEBUG(net, 0, "Client: Performing emergency save (%s)", filename);
@@ -212,6 +213,8 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res)
SendError(errorno);
}
+ ClientNetworkEmergencySave();
+
_switch_mode = SM_MENU;
this->CloseConnection(res);
_networking = false;
@@ -1173,7 +1176,6 @@ void ClientNetworkGameSocketHandler::CheckConnection()
if (lag > 20) {
this->NetworkGameSocketHandler::CloseConnection();
ShowErrorMessage(STR_NETWORK_ERROR_LOSTCONNECTION, INVALID_STRING_ID, WL_CRITICAL);
- ClientNetworkEmergencySave();
return;
}