summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/network/network_server.cpp8
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: