aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt5
-rw-r--r--src/connection.cpp19
-rw-r--r--src/map.cpp6
-rw-r--r--src/serialization.h4
-rw-r--r--src/server.cpp2
-rw-r--r--src/tile.cpp2
6 files changed, 20 insertions, 18 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 47fa5e216..2fc30b842 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -643,11 +643,6 @@ else()
if(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-but-set-variable")
endif(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
-
- CHECK_CXX_COMPILER_FLAG("-Wno-type-limits" HAS_TYPE_LIMITS_WARNING)
- if(HAS_TYPE_LIMITS_WARNING)
- set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-type-limits")
- endif(HAS_TYPE_LIMITS_WARNING)
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
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
diff --git a/src/map.cpp b/src/map.cpp
index 7a58c90c7..1c1cd7c28 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -1766,7 +1766,11 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
content_t new_node_content;
s8 new_node_level = -1;
s8 max_node_level = -1;
- u8 range = rangelim(nodemgr->get(liquid_kind).liquid_range, 0, LIQUID_LEVEL_MAX+1);
+
+ u8 range = nodemgr->get(liquid_kind).liquid_range;
+ if (range > LIQUID_LEVEL_MAX+1)
+ range = LIQUID_LEVEL_MAX+1;
+
if ((num_sources >= 2 && nodemgr->get(liquid_kind).liquid_renewable) || liquid_type == LIQUID_SOURCE) {
// liquid_kind will be set to either the flowing alternative of the node (if it's a liquid)
// or the flowing alternative of the first of the surrounding sources (if it's air), so
diff --git a/src/serialization.h b/src/serialization.h
index 41a505455..caa1a66da 100644
--- a/src/serialization.h
+++ b/src/serialization.h
@@ -72,7 +72,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// Lowest supported serialization version
#define SER_FMT_VER_LOWEST 0
-#define ser_ver_supported(v) (v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST_READ)
+inline bool ser_ver_supported(s32 v) {
+ return v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST_READ;
+}
/*
Misc. serialization functions
diff --git a/src/server.cpp b/src/server.cpp
index 161aaafc7..a52cd639d 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -1361,7 +1361,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
u8 client_max = data[2];
u8 our_max = SER_FMT_VER_HIGHEST_READ;
// Use the highest version supported by both
- u8 deployed = std::min(client_max, our_max);
+ int deployed = std::min(client_max, our_max);
// If it's lower than the lowest supported, give up.
if(deployed < SER_FMT_VER_LOWEST)
deployed = SER_FMT_VER_INVALID;
diff --git a/src/tile.cpp b/src/tile.cpp
index fa2f4c84e..e7e37a4fe 100644
--- a/src/tile.cpp
+++ b/src/tile.cpp
@@ -1859,7 +1859,7 @@ void imageTransform(u32 transform, video::IImage *src, video::IImage *dst)
core::dimension2d<u32> dstdim = dst->getDimension();
assert(dstdim == imageTransformDimension(transform, srcdim));
- assert(transform >= 0 && transform <= 7);
+ assert(transform <= 7);
/*
Compute the transformation from source coordinates (sx,sy)