From 736983a06ddc3fb61727e7ff371963ae7f70ff92 Mon Sep 17 00:00:00 2001 From: celestar Date: Fri, 31 Mar 2006 18:36:13 +0000 Subject: (svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles --- water_map.h | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'water_map.h') diff --git a/water_map.h b/water_map.h index 8fbc770f1..b83d590dc 100644 --- a/water_map.h +++ b/water_map.h @@ -3,6 +3,13 @@ #ifndef WATER_MAP_H #define WATER_MAP_H +typedef enum WaterTileType { + WATER_CLEAR, + WATER_COAST, + WATER_LOCK, + WATER_DEPOT, +} WaterTileType; + typedef enum DepotPart { DEPOT_NORTH = 0x80, DEPOT_SOUTH = 0x81, @@ -12,15 +19,28 @@ typedef enum DepotPart { typedef enum LockPart { LOCK_MIDDLE = 0x10, LOCK_LOWER = 0x14, - LOCK_UPPER = 0x18 + LOCK_UPPER = 0x18, + LOCK_END = 0x1C } LockPart; -static inline bool IsClearWaterTile(TileIndex tile) +static inline WaterTileType GetWaterTileType(TileIndex t) +{ + if (_m[t].m5 == 0) return WATER_CLEAR; + if (_m[t].m5 == 1) return WATER_COAST; + if (IS_INT_INSIDE(_m[t].m5, LOCK_MIDDLE, LOCK_END)) return WATER_LOCK; + if (IS_INT_INSIDE(_m[t].m5, DEPOT_NORTH, DEPOT_END)) return WATER_DEPOT; + + assert(0); +} + +static inline bool IsWater(TileIndex t) +{ + return GetWaterTileType(t) == WATER_CLEAR; +} + +static inline bool IsClearWaterTile(TileIndex t) { - return - IsTileType(tile, MP_WATER) && - _m[tile].m5 == 0 && - GetTileSlope(tile, NULL) == 0; + return IsTileType(t, MP_WATER) && IsWater(t) && GetTileSlope(t, NULL) == 0; } static inline TileIndex GetOtherShipDepotTile(TileIndex t) -- cgit v1.2.3-54-g00ecf