diff options
author | rubidium42 <rubidium@openttd.org> | 2021-04-25 17:53:24 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-04-25 19:54:21 +0200 |
commit | 65818db1f4332fecb9395df2e41f2068bb86feeb (patch) | |
tree | 3279d5ca4ddc61aef4f7922f2a43a3b2d34b4eba | |
parent | f158957a4e9d7fab39e35b5dc3b5e31882d4da52 (diff) | |
download | openttd-65818db1f4332fecb9395df2e41f2068bb86feeb.tar.xz |
Fix: [Network] Prevent stalling save game transfer when compression is slow
-rw-r--r-- | src/network/network_server.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index f6b3e1192..5489db848 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -592,7 +592,7 @@ void ServerNetworkGameSocketHandler::CheckNextClientToSendMap(NetworkClientSocke /** This sends the map to the client */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendMap() { - static uint sent_packets; // How many packets we did send successfully last time + static uint16 sent_packets; // How many packets we did send successfully last time if (this->status < STATUS_AUTHORIZED) { /* Illegal call, return error and ignore the packet */ @@ -652,8 +652,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendMap() return NETWORK_RECV_STATUS_CONN_LOST; case SPS_ALL_SENT: - /* All are sent, increase the sent_packets */ - if (has_packets) sent_packets *= 2; + /* All are sent, increase the sent_packets but do not overflow! */ + if (has_packets && sent_packets < std::numeric_limits<decltype(sent_packets)>::max() / 2) { + sent_packets *= 2; + } break; case SPS_PARTLY_SENT: |