Codechange: encapsulate reading the size of a Packet

This commit is contained in:
Rubidium
2021-04-18 12:29:34 +02:00
committed by rubidium42
parent 6f161f6559
commit f71fb0f54a
5 changed files with 17 additions and 4 deletions

View File

@@ -247,7 +247,7 @@ Packet *ServerNetworkGameSocketHandler::ReceivePacket()
/* We can receive a packet, so try that and if needed account for
* the amount of received data. */
Packet *p = this->NetworkTCPSocketHandler::ReceivePacket();
if (p != nullptr) this->receive_limit -= p->size;
if (p != nullptr) this->receive_limit -= p->Size();
return p;
}
@@ -1832,7 +1832,7 @@ void NetworkServer_Tick(bool send_frame)
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
/* We allow a number of bytes per frame, but only to the burst amount
* to be available for packet receiving at any particular time. */
cs->receive_limit = std::min<int>(cs->receive_limit + _settings_client.network.bytes_per_frame,
cs->receive_limit = std::min<size_t>(cs->receive_limit + _settings_client.network.bytes_per_frame,
_settings_client.network.bytes_per_frame_burst);
/* Check if the speed of the client is what we can expect from a client */