Change various asserts to not be included in release builds

This commit is contained in:
Jonathan G Rennison
2022-10-22 12:34:54 +01:00
parent 071ac374e8
commit 29a1e49c28
53 changed files with 522 additions and 520 deletions

View File

@@ -30,7 +30,7 @@ static inline uint TileHeight(TileIndex tile)
{
/* this method is inlined in many places and is performance-critical, drop assertion in non-debug builds */
#ifdef _DEBUG
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
#endif
return _m[tile].height;
}
@@ -59,8 +59,8 @@ static inline uint TileHeightOutsideMap(int x, int y)
*/
static inline void SetTileHeight(TileIndex tile, uint height)
{
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
assert(height <= MAX_TILE_HEIGHT);
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
dbg_assert(height <= MAX_TILE_HEIGHT);
_m[tile].height = height;
}
@@ -100,7 +100,7 @@ static inline TileType GetTileType(TileIndex tile)
{
/* this method is inlined in many places and is performance-critical, drop assertion in non-debug builds */
#ifdef _DEBUG
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
#endif
return (TileType)GB(_m[tile].type, 4, 4);
}
@@ -114,7 +114,7 @@ static inline TileType GetTileType(TileIndex tile)
*/
static inline bool IsInnerTile(TileIndex tile)
{
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
uint x = TileX(tile);
uint y = TileY(tile);
@@ -136,11 +136,11 @@ static inline bool IsInnerTile(TileIndex tile)
*/
static inline void SetTileType(TileIndex tile, TileType type)
{
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X, type: %d", tile, MapSize(), type);
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X, type: %d", tile, MapSize(), type);
/* VOID tiles (and no others) are exactly allowed at the lower left and right
* edges of the map. If _settings_game.construction.freeform_edges is true,
* the upper edges of the map are also VOID tiles. */
assert_msg(IsInnerTile(tile) == (type != MP_VOID), "tile: 0x%X (%d), type: %d", tile, IsInnerTile(tile), type);
dbg_assert_msg(IsInnerTile(tile) == (type != MP_VOID), "tile: 0x%X (%d), type: %d", tile, IsInnerTile(tile), type);
SB(_m[tile].type, 4, 4, type);
}
@@ -183,8 +183,8 @@ static inline bool IsValidTile(TileIndex tile)
*/
static inline Owner GetTileOwner(TileIndex tile)
{
assert_msg(IsValidTile(tile), "tile: 0x%X, size: 0x%X", tile, MapSize());
assert_msg(!IsTileType(tile, MP_HOUSE) && !IsTileType(tile, MP_INDUSTRY), "tile: 0x%X (%d)", tile, GetTileType(tile));
dbg_assert_msg(IsValidTile(tile), "tile: 0x%X, size: 0x%X", tile, MapSize());
dbg_assert_msg(!IsTileType(tile, MP_HOUSE) && !IsTileType(tile, MP_INDUSTRY), "tile: 0x%X (%d)", tile, GetTileType(tile));
return (Owner)GB(_m[tile].m1, 0, 5);
}
@@ -202,8 +202,8 @@ static inline Owner GetTileOwner(TileIndex tile)
*/
static inline void SetTileOwner(TileIndex tile, Owner owner)
{
assert_msg(IsValidTile(tile), "tile: 0x%X, size: 0x%X, owner: %d", tile, MapSize(), owner);
assert_msg(!IsTileType(tile, MP_HOUSE) && !IsTileType(tile, MP_INDUSTRY), "tile: 0x%X (%d), owner: %d", tile, GetTileType(tile), owner);
dbg_assert_msg(IsValidTile(tile), "tile: 0x%X, size: 0x%X, owner: %d", tile, MapSize(), owner);
dbg_assert_msg(!IsTileType(tile, MP_HOUSE) && !IsTileType(tile, MP_INDUSTRY), "tile: 0x%X (%d), owner: %d", tile, GetTileType(tile), owner);
SB(_m[tile].m1, 0, 5, owner);
}
@@ -228,8 +228,8 @@ static inline bool IsTileOwner(TileIndex tile, Owner owner)
*/
static inline void SetTropicZone(TileIndex tile, TropicZone type)
{
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X, type: %d", tile, MapSize(), type);
assert_msg(!IsTileType(tile, MP_VOID) || type == TROPICZONE_NORMAL, "tile: 0x%X (%d), type: %d", tile, GetTileType(tile), type);
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X, type: %d", tile, MapSize(), type);
dbg_assert_msg(!IsTileType(tile, MP_VOID) || type == TROPICZONE_NORMAL, "tile: 0x%X (%d), type: %d", tile, GetTileType(tile), type);
SB(_m[tile].type, 0, 2, type);
}
@@ -241,7 +241,7 @@ static inline void SetTropicZone(TileIndex tile, TropicZone type)
*/
static inline TropicZone GetTropicZone(TileIndex tile)
{
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
dbg_assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
return (TropicZone)GB(_m[tile].type, 0, 2);
}
@@ -253,7 +253,7 @@ static inline TropicZone GetTropicZone(TileIndex tile)
*/
static inline byte GetAnimationFrame(TileIndex t)
{
assert_msg(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_STATION), "tile: 0x%X (%d)", t, GetTileType(t));
dbg_assert_msg(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_STATION), "tile: 0x%X (%d)", t, GetTileType(t));
return _me[t].m7;
}
@@ -265,7 +265,7 @@ static inline byte GetAnimationFrame(TileIndex t)
*/
static inline void SetAnimationFrame(TileIndex t, byte frame)
{
assert_msg(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_STATION), "tile: 0x%X (%d)", t, GetTileType(t));
dbg_assert_msg(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_STATION), "tile: 0x%X (%d)", t, GetTileType(t));
_me[t].m7 = frame;
}