diff --git a/lib/mapping/CMap.cpp b/lib/mapping/CMap.cpp index f4ad85b46..824dca05e 100644 --- a/lib/mapping/CMap.cpp +++ b/lib/mapping/CMap.cpp @@ -334,7 +334,11 @@ bool CMap::isCoastalTile(const int3 & pos) const bool CMap::isInTheMap(const int3 & pos) const { - return pos.x >= 0 && pos.y >= 0 && pos.z >= 0 && pos.x < width && pos.y < height && pos.z <= (twoLevel ? 1 : 0); + // Check whether coord < 0 is done implicitly. Negative signed int overflows to unsigned number larger than all signed ints. + return + static_cast(pos.x) < static_cast(width) && + static_cast(pos.y) < static_cast(height) && + static_cast(pos.z) <= (twoLevel ? 1 : 0); } TerrainTile & CMap::getTile(const int3 & tile)