Loading

Revision differences

Old revision #p7c0fpuuhNew revision #plko4pjxx
1Index: water_map.h  1Index: src/water_map.h
2===================================================================  2===================================================================  
3--- water_map.h    (revision 27210)  3--- src/water_map.h    (revision 27212)
4+++ water_map.h    (working copy)  4+++ src/water_map.h    (working copy)
5@@ -16,25 +16,26 @@  5@@ -16,25 +16,26 @@  
6 #include "tile_map.h"  6 #include "tile_map.h"  
7   7   
  
41+    WBL_DEPOT_AXIS        = 1,   ///< Depot axis flag, in m5.  41+    WBL_DEPOT_AXIS        = 1,   ///< Depot axis flag, in m5.  
42 };  42 };  
43   43   
44 /** Available water tile types. */  44 /** Available water tile types. */
45@@ -55,6 +56,12 @@    
46 /** Helper information for extract tool. */    
47 template <> struct EnumPropsT<WaterClass> : MakeEnumPropsT<WaterClass, byte, WATER_CLASS_SEA, WATER_CLASS_INVALID, WATER_CLASS_INVALID, 2> {};    
48     
49+/** Bases of a canal (for #WATER_CLASS_CANAL class of water). */    
50+enum CanalBase {    
51+    WCC_WITHOUT_RIVER = 0, ///< Without a river under it    
52+    WCC_WITH_RIVER    = 1, ///< With a river under it    
53+};    
54+    
55 /** Sections of the water depot. */    
56 enum DepotPart {    
57     DEPOT_PART_NORTH = 0, ///< Northern part of a depot.    
58@@ -122,6 +129,40 @@    
59 }    
60     
61 /**    
62+ * Get the base of the canal at a tile.    
63+ * @param t Water tile to query.    
64+ * @pre GetWaterClass(t) == WATER_CLASS_CANAL    
65+ * @return Base of the canal at the tile.    
66+ */    
67+static inline CanalBase GetCanalBase(TileIndex t)    
68+{    
69+    assert(GetWaterClass(t) == WATER_CLASS_CANAL);    
70+    return (CanalBase)HasBit(_me[t].m6, WBL_RIVER_FLAG) ? WCC_WITH_RIVER : WCC_WITHOUT_RIVER;    
71+}    
72+    
73+/**    
74+ * Set the base of the canal to indicate there is a river under a tile.    
75+ * @param t Water tile of water class canal to query.    
76+ * @pre GetWaterClass(t) == WATER_CLASS_CANAL    
77+ */    
78+static inline void SetCanalOnRiver(TileIndex t)    
79+{    
80+    assert(GetWaterClass(t) == WATER_CLASS_CANAL);    
81+    SB(_me[t].m6, 0, WBL_RIVER_FLAG, WCC_WITH_RIVER);    
82+}    
83+    
84+/**    
85+ * Checks whether the canal at a tile has a river under it.    
86+ * @param t Water tile of water class canal to query.    
87+ * @pre GetWaterClass(t) == WATER_CLASS_CANAL    
88+ * @return true if the canal has a river under it.    
89+ */    
90+static inline bool HasTileCanalOnRiver(TileIndex t)    
91+{    
92+    return HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_CANAL && GetCanalBase(t) == WCC_WITH_RIVER;    
93+}    
94+    
95+/**    
96  * Tests if the tile was built on water.    
97  * @param t the tile to check    
98  * @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)