From 435c8d33b0658c97648f18fbc38682ce09e321b2 Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 5 Sep 2010 13:18:26 +0000 Subject: (svn r20740) -Codechange: Add HasTileWaterClass() to test for tiletypes with WaterClass. --- src/water_map.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/water_map.h b/src/water_map.h index c5759c0d8..07819e182 100644 --- a/src/water_map.h +++ b/src/water_map.h @@ -64,6 +64,17 @@ static inline WaterTileType GetWaterTileType(TileIndex t) return WATER_TILE_DEPOT; } +/** + * Checks whether the tile has an waterclass associated. + * You can then subsequently call GetWaterClass(). + * @param t Tile to query. + * @return True if the tiletype has a waterclass. + */ +static inline bool HasTileWaterClass(TileIndex t) +{ + return IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT); +} + /** * Get the water class at a tile. * @param t Water tile to query. @@ -72,7 +83,7 @@ static inline WaterTileType GetWaterTileType(TileIndex t) */ static inline WaterClass GetWaterClass(TileIndex t) { - assert(IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)); + assert(HasTileWaterClass(t)); return (WaterClass)GB(_m[t].m1, 5, 2); } @@ -84,7 +95,7 @@ static inline WaterClass GetWaterClass(TileIndex t) */ static inline void SetWaterClass(TileIndex t, WaterClass wc) { - assert(IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)); + assert(HasTileWaterClass(t)); SB(_m[t].m1, 5, 2, wc); } -- cgit v1.2.3-70-g09d2