summaryrefslogtreecommitdiff
path: root/src/connection.cpp
diff options
context:
space:
mode:
authorCraig Robbins <kde.psych@gmail.com>2014-12-29 23:53:08 +1000
committerCraig Robbins <kde.psych@gmail.com>2014-12-29 23:56:40 +1000
commit3993102e880f2a31b6fef9484b8527a58e850744 (patch)
tree780f07bbcddbf5ec0e2b820d675aff615cab0476 /src/connection.cpp
parent5038b9aaeced00396e37f4d6665f8afe21169a8a (diff)
downloadminetest-3993102e880f2a31b6fef9484b8527a58e850744.tar.gz
minetest-3993102e880f2a31b6fef9484b8527a58e850744.tar.bz2
minetest-3993102e880f2a31b6fef9484b8527a58e850744.zip
Fix -Wtype-limits warnings and remove disabling of -Wtype-limits
Diffstat (limited to 'src/connection.cpp')
-rw-r--r--src/connection.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/connection.cpp b/src/connection.cpp
index a9f1d5457..02ca91a91 100644
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -2334,6 +2334,11 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
u8 type = readU8(&(packetdata[0]));
+ if (MAX_UDP_PEERS <= 65535 && peer_id >= MAX_UDP_PEERS) {
+ errorstream << "Something is wrong with peer_id" << std::endl;
+ assert(0);
+ }
+
if(type == TYPE_CONTROL)
{
if(packetdata.getSize() < 2)
@@ -2341,8 +2346,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
u8 controltype = readU8(&(packetdata[1]));
- if( (controltype == CONTROLTYPE_ACK)
- && (peer_id <= MAX_UDP_PEERS))
+ if(controltype == CONTROLTYPE_ACK)
{
assert(channel != 0);
if(packetdata.getSize() < 4)
@@ -2399,8 +2403,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
}
throw ProcessedSilentlyException("Got an ACK");
}
- else if((controltype == CONTROLTYPE_SET_PEER_ID)
- && (peer_id <= MAX_UDP_PEERS))
+ else if(controltype == CONTROLTYPE_SET_PEER_ID)
{
// Got a packet to set our peer id
if(packetdata.getSize() < 4)
@@ -2432,8 +2435,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
throw ProcessedSilentlyException("Got a SET_PEER_ID");
}
- else if((controltype == CONTROLTYPE_PING)
- && (peer_id <= MAX_UDP_PEERS))
+ else if(controltype == CONTROLTYPE_PING)
{
// Just ignore it, the incoming data already reset
// the timeout counter
@@ -2455,8 +2457,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
throw ProcessedSilentlyException("Got a DISCO");
}
- else if((controltype == CONTROLTYPE_ENABLE_BIG_SEND_WINDOW)
- && (peer_id <= MAX_UDP_PEERS))
+ else if(controltype == CONTROLTYPE_ENABLE_BIG_SEND_WINDOW)
{
dynamic_cast<UDPPeer*>(&peer)->setNonLegacyPeer();
throw ProcessedSilentlyException("Got non legacy control");
@@ -2514,7 +2515,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
//TODO throw some error
}
}
- else if((peer_id <= MAX_UDP_PEERS) && (type == TYPE_RELIABLE))
+ else if(type == TYPE_RELIABLE)
{
assert(channel != 0);
// Recursive reliable packets not allowed