summaryrefslogtreecommitdiff
path: root/rail_map.h
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-04-12 11:58:07 +0000
committercelestar <celestar@openttd.org>2006-04-12 11:58:07 +0000
commitee7eaef29d5c65a3e4c5ae317c0c2dd3ebe9651f (patch)
treefb4534a61881057170e33d730788aafffcf40aaa /rail_map.h
parent923a0e60d6df0b334dd9371ef8a8f486295ea421 (diff)
downloadopenttd-ee7eaef29d5c65a3e4c5ae317c0c2dd3ebe9651f.tar.xz
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
Diffstat (limited to 'rail_map.h')
-rw-r--r--rail_map.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/rail_map.h b/rail_map.h
index f3a7a4626..1fe1d71f4 100644
--- a/rail_map.h
+++ b/rail_map.h
@@ -202,6 +202,50 @@ static inline void SetSignalVariant(TileIndex t, SignalVariant v)
}
+typedef enum RailGroundType {
+ RAIL_MAP2LO_GROUND_MASK = 0xF,
+ RAIL_GROUND_BARREN = 0,
+ RAIL_GROUND_GRASS = 1,
+ RAIL_GROUND_FENCE_NW = 2,
+ RAIL_GROUND_FENCE_SE = 3,
+ RAIL_GROUND_FENCE_SENW = 4,
+ RAIL_GROUND_FENCE_NE = 5,
+ RAIL_GROUND_FENCE_SW = 6,
+ RAIL_GROUND_FENCE_NESW = 7,
+ RAIL_GROUND_FENCE_VERT1 = 8,
+ RAIL_GROUND_FENCE_VERT2 = 9,
+ RAIL_GROUND_FENCE_HORIZ1 = 10,
+ RAIL_GROUND_FENCE_HORIZ2 = 11,
+ RAIL_GROUND_ICE_DESERT = 12,
+} RailGroundType;
+
+static inline void SetRailGroundType(TileIndex t, RailGroundType rgt)
+{
+ if (GetRailTileType(t) == RAIL_TYPE_DEPOT_WAYPOINT) {
+ SB(_m[t].m4, 0, 4, rgt);
+ return;
+ }
+ SB(_m[t].m2, 0, 4, rgt);
+}
+
+static inline RailGroundType GetRailGroundType(TileIndex t)
+{
+ /* TODO Unify this */
+ if (GetRailTileType(t) == RAIL_TYPE_DEPOT_WAYPOINT) return GB(_m[t].m4, 0, 4);
+ return GB(_m[t].m2, 0, 4);
+}
+
+static inline bool IsBarrenRailGround(TileIndex t)
+{
+ return GetRailGroundType(t) == RAIL_GROUND_BARREN;
+}
+
+static inline bool IsSnowRailGround(TileIndex t)
+{
+ return GetRailGroundType(t) == RAIL_GROUND_ICE_DESERT;
+}
+
+
static inline void MakeRailNormal(TileIndex t, Owner o, TrackBits b, RailType r)
{
SetTileType(t, MP_RAILWAY);