25 LOCK_END = 0x1C |
25 LOCK_END = 0x1C |
26 }; |
26 }; |
27 |
27 |
28 static inline WaterTileType GetWaterTileType(TileIndex t) |
28 static inline WaterTileType GetWaterTileType(TileIndex t) |
29 { |
29 { |
|
30 assert(IsTileType(t, MP_WATER)); |
|
31 |
30 if (_m[t].m5 == 0) return WATER_TILE_CLEAR; |
32 if (_m[t].m5 == 0) return WATER_TILE_CLEAR; |
31 if (_m[t].m5 == 1) return WATER_TILE_COAST; |
33 if (_m[t].m5 == 1) return WATER_TILE_COAST; |
32 if (IS_INT_INSIDE(_m[t].m5, LOCK_MIDDLE, LOCK_END)) return WATER_TILE_LOCK; |
34 if (IS_INT_INSIDE(_m[t].m5, LOCK_MIDDLE, LOCK_END)) return WATER_TILE_LOCK; |
33 |
35 |
34 assert(IS_INT_INSIDE(_m[t].m5, DEPOT_NORTH, DEPOT_END)); |
36 assert(IS_INT_INSIDE(_m[t].m5, DEPOT_NORTH, DEPOT_END)); |
35 return WATER_TILE_DEPOT; |
37 return WATER_TILE_DEPOT; |
36 } |
38 } |
37 |
39 |
|
40 /** IsWater return true if any type of clear water like ocean, river, canal */ |
38 static inline bool IsWater(TileIndex t) |
41 static inline bool IsWater(TileIndex t) |
39 { |
42 { |
40 return GetWaterTileType(t) == WATER_TILE_CLEAR; |
43 return GetWaterTileType(t) == WATER_TILE_CLEAR; |
|
44 } |
|
45 |
|
46 static inline bool IsSea(TileIndex t) |
|
47 { |
|
48 if (GetWaterTileType(t) != WATER_TILE_CLEAR) return false; |
|
49 if (!IsTileOwner(t, OWNER_WATER)) return false; // 'Human' built water = canal, not sea |
|
50 return true; |
41 } |
51 } |
42 |
52 |
43 static inline bool IsCoast(TileIndex t) |
53 static inline bool IsCoast(TileIndex t) |
44 { |
54 { |
45 return GetWaterTileType(t) == WATER_TILE_COAST; |
55 return GetWaterTileType(t) == WATER_TILE_COAST; |
48 static inline bool IsCanal(TileIndex t) |
58 static inline bool IsCanal(TileIndex t) |
49 { |
59 { |
50 return GetWaterTileType(t) == WATER_TILE_CLEAR && GetTileOwner(t) != OWNER_WATER; |
60 return GetWaterTileType(t) == WATER_TILE_CLEAR && GetTileOwner(t) != OWNER_WATER; |
51 } |
61 } |
52 |
62 |
53 static inline bool IsClearWaterTile(TileIndex t) |
63 static inline bool IsWaterTile(TileIndex t) |
54 { |
64 { |
55 return IsTileType(t, MP_WATER) && IsWater(t) && GetTileSlope(t, NULL) == SLOPE_FLAT; |
65 return IsTileType(t, MP_WATER) && IsWater(t); |
56 } |
66 } |
57 |
67 |
58 static inline TileIndex GetOtherShipDepotTile(TileIndex t) |
68 static inline TileIndex GetOtherShipDepotTile(TileIndex t) |
59 { |
69 { |
60 return t + (HASBIT(_m[t].m5, 0) ? -1 : 1) * (HASBIT(_m[t].m5, 1) ? TileDiffXY(0, 1) : TileDiffXY(1, 0)); |
70 return t + (HASBIT(_m[t].m5, 0) ? -1 : 1) * (HASBIT(_m[t].m5, 1) ? TileDiffXY(0, 1) : TileDiffXY(1, 0)); |