Fix various compiler warnings

See: #267
This commit is contained in:
Jonathan G Rennison
2021-06-11 22:54:27 +01:00
parent 97d5982cb5
commit 1002c6d9d2
46 changed files with 101 additions and 101 deletions

View File

@@ -425,7 +425,7 @@ void Packet::Recv_string(std::string &buffer, StringValidationSettings settings)
size_t length = ttd_strnlen((const char *)(this->buffer.data() + this->pos), this->Size() - this->pos - 1);
buffer.assign((const char *)(this->buffer.data() + this->pos), length);
this->pos += length + 1;
this->pos += (uint)length + 1;
str_validate_inplace(buffer, settings);
}

View File

@@ -95,13 +95,13 @@ void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool a
const uint PAYLOAD_MTU = MTU - (1 + 2 + 8 + 1 + 1 + 2);
const size_t packet_size = p->Size();
const uint8 frag_count = (packet_size + PAYLOAD_MTU - 1) / PAYLOAD_MTU;
const uint8 frag_count = (uint8)((packet_size + PAYLOAD_MTU - 1) / PAYLOAD_MTU);
Packet frag(PACKET_UDP_EX_MULTI);
uint8 current_frag = 0;
uint16 offset = 0;
while (offset < packet_size) {
uint16 payload_size = std::min<uint>(PAYLOAD_MTU, packet_size - offset);
uint16 payload_size = (uint16)std::min<size_t>(PAYLOAD_MTU, packet_size - offset);
frag.Send_uint64(token);
frag.Send_uint8 (current_frag);
frag.Send_uint8 (frag_count);
@@ -501,7 +501,7 @@ void NetworkUDPSocketHandler::Receive_EX_MULTI(Packet *p, NetworkAddress *client
for (auto &frag : fs.fragments) {
if (!frag.size()) return;
total_payload += frag.size();
total_payload += (uint)frag.size();
}
DEBUG(net, 6, "[udp] merged multi-part packet from %s: " OTTD_PRINTFHEX64 ", %u bytes",

View File

@@ -565,7 +565,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendDesyncLog(const std::strin
for (size_t offset = 0; offset < log.size();) {
Packet *p = new Packet(PACKET_CLIENT_DESYNC_LOG, SHRT_MAX);
size_t size = std::min<size_t>(log.size() - offset, SHRT_MAX - 2 - p->Size());
p->Send_uint16(size);
p->Send_uint16((uint16)size);
p->Send_binary(log.data() + offset, size);
my_client->SendPacket(p);

View File

@@ -254,7 +254,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
while (cv->size() > offset) {
Packet *p = new Packet(send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID, TCP_MTU);
const uint to_send = std::min<uint>(cv->size() - offset, max_per_packet);
const uint to_send = (uint)std::min<uint>(cv->size() - offset, max_per_packet);
p->Send_uint8(to_send);
for (uint i = 0; i < to_send; i++) {