summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-09-05 13:18:26 +0000
committerfrosch <frosch@openttd.org>2010-09-05 13:18:26 +0000
commit435c8d33b0658c97648f18fbc38682ce09e321b2 (patch)
treea61736fe54da9ff7e6aa4b3d7e762b78a0242e08
parenta9d2ba60698edaee5c4d363cbd655f82c151b246 (diff)
downloadopenttd-435c8d33b0658c97648f18fbc38682ce09e321b2.tar.xz
(svn r20740) -Codechange: Add HasTileWaterClass() to test for tiletypes with WaterClass.
-rw-r--r--src/water_map.h15
1 files changed, 13 insertions, 2 deletions
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
@@ -65,6 +65,17 @@ static inline WaterTileType GetWaterTileType(TileIndex t)
}
/**
+ * 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.
* @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)
@@ -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);
}