summaryrefslogtreecommitdiff
path: root/src/clear_map.h
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-01-04 18:33:43 +0000
committeryexo <yexo@openttd.org>2010-01-04 18:33:43 +0000
commitb378e82676b299dc8d579cd2ac020758fbf52f84 (patch)
tree044688328cdbf84c799fd452f4c38c3132943db1 /src/clear_map.h
parent3e131e2fece740591d9187e19789a34b36c763fa (diff)
downloadopenttd-b378e82676b299dc8d579cd2ac020758fbf52f84.tar.xz
(svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
Diffstat (limited to 'src/clear_map.h')
-rw-r--r--src/clear_map.h68
1 files changed, 66 insertions, 2 deletions
diff --git a/src/clear_map.h b/src/clear_map.h
index c9a74295e..0177e5f7f 100644
--- a/src/clear_map.h
+++ b/src/clear_map.h
@@ -29,18 +29,42 @@ enum ClearGround {
/**
- * Get the type of clear tile.
+ * Test if a tile is covered with snow.
+ * @param t the tile to check
+ * @pre IsTileType(t, MP_CLEAR)
+ * @return whether the tile is covered with snow.
+ */
+static inline bool IsSnowTile(TileIndex t)
+{
+ assert(IsTileType(t, MP_CLEAR));
+ return HasBit(_m[t].m3, 4);
+}
+
+/**
+ * Get the type of clear tile but never return CLEAR_SNOW.
* @param t the tile to get the clear ground type of
* @pre IsTileType(t, MP_CLEAR)
* @return the ground type
*/
-static inline ClearGround GetClearGround(TileIndex t)
+static inline ClearGround GetRawClearGround(TileIndex t)
{
assert(IsTileType(t, MP_CLEAR));
return (ClearGround)GB(_m[t].m5, 2, 3);
}
/**
+ * Get the type of clear tile.
+ * @param t the tile to get the clear ground type of
+ * @pre IsTileType(t, MP_CLEAR)
+ * @return the ground type
+ */
+static inline ClearGround GetClearGround(TileIndex t)
+{
+ if (IsSnowTile(t)) return CLEAR_SNOW;
+ return GetRawClearGround(t);
+}
+
+/**
* Set the type of clear tile.
* @param t the tile to set the clear ground type of
* @param ct the ground type
@@ -76,6 +100,18 @@ static inline void AddClearDensity(TileIndex t, int d)
_m[t].m5 += d;
}
+/**
+ * Set the density of a non-field clear tile.
+ * @param t the tile to set the density of
+ * @param d the new density
+ * @pre IsTileType(t, MP_CLEAR)
+ */
+static inline void SetClearDensity(TileIndex t, uint d)
+{
+ assert(IsTileType(t, MP_CLEAR));
+ SB(_m[t].m5, 0, 2, d);
+}
+
/**
* Get the counter used to advance to the next clear density/field type.
@@ -269,4 +305,32 @@ static inline void MakeField(TileIndex t, uint field_type, IndustryID industry)
_me[t].m7 = 0;
}
+/**
+ * Make a snow tile.
+ * @param t the tile to make snowy
+ * @pre GetClearGround(t) != CLEAR_SNOW
+ */
+static inline void MakeSnow(TileIndex t)
+{
+ assert(GetClearGround(t) != CLEAR_SNOW);
+ SetBit(_m[t].m3, 4);
+ if (GetClearGround(t) == CLEAR_FIELDS) {
+ SetClearGroundDensity(t, CLEAR_GRASS, 0);
+ } else {
+ SetClearDensity(t, 0);
+ }
+}
+
+/**
+ * Clear the snow from a tile and return it to it's previous type.
+ * @param t the tile to clear of snow
+ * @pre GetClearGround(t) == CLEAR_SNOW
+ */
+static inline void ClearSnow(TileIndex t)
+{
+ assert(GetClearGround(t) == CLEAR_SNOW);
+ ClrBit(_m[t].m3, 4);
+ SetClearDensity(t, 3);
+}
+
#endif /* CLEAR_MAP_H */