summaryrefslogtreecommitdiff
path: root/src/water_map.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-10-16 19:48:58 +0000
committerrubidium <rubidium@openttd.org>2007-10-16 19:48:58 +0000
commitba7c595d846245659c569e0510c3642e88d6992c (patch)
tree45653866becd6ad493d17cf4b6e65801597a47b5 /src/water_map.h
parent4f512a70c360e2aa45e80aacdbcc95d2a754b987 (diff)
downloadopenttd-ba7c595d846245659c569e0510c3642e88d6992c.tar.xz
(svn r11276) -Codechange: be more consistent with naming of some accessors.
-Fix: make sure canals are never owned by water. Based on a patch by boekabart.
Diffstat (limited to 'src/water_map.h')
-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 77fce0a17..b1c8f4c16 100644
--- a/src/water_map.h
+++ b/src/water_map.h
@@ -27,6 +27,8 @@ enum LockPart {
static inline WaterTileType GetWaterTileType(TileIndex t)
{
+ assert(IsTileType(t, MP_WATER));
+
if (_m[t].m5 == 0) return WATER_TILE_CLEAR;
if (_m[t].m5 == 1) return WATER_TILE_COAST;
if (IS_INT_INSIDE(_m[t].m5, LOCK_MIDDLE, LOCK_END)) return WATER_TILE_LOCK;
@@ -35,11 +37,19 @@ static inline WaterTileType GetWaterTileType(TileIndex t)
return WATER_TILE_DEPOT;
}
+/** IsWater return true if any type of clear water like ocean, river, canal */
static inline bool IsWater(TileIndex t)
{
return GetWaterTileType(t) == WATER_TILE_CLEAR;
}
+static inline bool IsSea(TileIndex t)
+{
+ if (GetWaterTileType(t) != WATER_TILE_CLEAR) return false;
+ if (!IsTileOwner(t, OWNER_WATER)) return false; // 'Human' built water = canal, not sea
+ return true;
+}
+
static inline bool IsCoast(TileIndex t)
{
return GetWaterTileType(t) == WATER_TILE_COAST;
@@ -50,9 +60,9 @@ static inline bool IsCanal(TileIndex t)
return GetWaterTileType(t) == WATER_TILE_CLEAR && GetTileOwner(t) != OWNER_WATER;
}
-static inline bool IsClearWaterTile(TileIndex t)
+static inline bool IsWaterTile(TileIndex t)
{
- return IsTileType(t, MP_WATER) && IsWater(t) && GetTileSlope(t, NULL) == SLOPE_FLAT;
+ return IsTileType(t, MP_WATER) && IsWater(t);
}
static inline TileIndex GetOtherShipDepotTile(TileIndex t)
@@ -109,6 +119,7 @@ static inline void MakeShore(TileIndex t)
static inline void MakeCanal(TileIndex t, Owner o)
{
+ assert(o != OWNER_WATER);
SetTileType(t, MP_WATER);
SetTileOwner(t, o);
_m[t].m2 = 0;