diff options
author | celestar <celestar@openttd.org> | 2006-03-31 18:36:13 +0000 |
---|---|---|
committer | celestar <celestar@openttd.org> | 2006-03-31 18:36:13 +0000 |
commit | 736983a06ddc3fb61727e7ff371963ae7f70ff92 (patch) | |
tree | 5094a48842981ecab0430ec1ffd795091ea6fb9c /water_map.h | |
parent | 949758e109855526cb7f70af426c9374907b0d01 (diff) | |
download | openttd-736983a06ddc3fb61727e7ff371963ae7f70ff92.tar.xz |
(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
Diffstat (limited to 'water_map.h')
-rw-r--r-- | water_map.h | 32 |
1 files changed, 26 insertions, 6 deletions
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) |