summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-05 14:49:46 +0000
committerrubidium <rubidium@openttd.org>2010-12-05 14:49:46 +0000
commitff8a01fbd26cdab6bbd77900391a0085866fb787 (patch)
treeb022b2631d826d521390cec9337d04d5b3339dbd /src/network
parent216e48cd07d96cabd0fd51b965a526350b47b552 (diff)
downloadopenttd-ff8a01fbd26cdab6bbd77900391a0085866fb787.tar.xz
(svn r21400) -Fix [FS#4284]: when loading a savegame takes more than 2 seconds locally, don't see that as lag of the server. Also increase the client side's lag thresholds a bit
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_client.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 990eda667..281c2e928 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -833,6 +833,9 @@ DEF_GAME_RECEIVE_COMMAND(Client, PACKET_SERVER_MAP_DONE)
/* The map is done downloading, load it */
bool load_success = SafeLoad(NULL, SL_LOAD, GM_NORMAL, NO_DIRECTORY, lf);
+ /* Long savegame loads shouldn't affect the lag calculation! */
+ this->last_packet = _realtime_tick;
+
if (!load_success) {
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
_switch_mode_errorstr = STR_NETWORK_ERROR_SAVEGAMEERROR;
@@ -1133,14 +1136,14 @@ void ClientNetworkGameSocketHandler::CheckConnection()
/* It might... sometimes occur that the realtime ticker overflows. */
if (_realtime_tick < this->last_packet) this->last_packet = _realtime_tick;
- /* Lag is in milliseconds; 2 seconds are roughly the server's
- * "you're slow" threshold (1 game day). */
+ /* Lag is in milliseconds; 5 seconds are roughly twice the
+ * server's "you're slow" threshold (1 game day). */
uint lag = (_realtime_tick - this->last_packet) / 1000;
- if (lag < 2) return;
+ if (lag < 5) return;
- /* 10 seconds are (way) more than 4 game days after which
+ /* 20 seconds are (way) more than 4 game days after which
* the server will forcefully disconnect you. */
- if (lag > 10) {
+ if (lag > 20) {
this->NetworkGameSocketHandler::CloseConnection();
_switch_mode_errorstr = STR_NETWORK_ERROR_LOSTCONNECTION;
return;