summaryrefslogtreecommitdiff
path: root/rail_map.h
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-17 07:02:34 +0000
committertron <tron@openttd.org>2006-03-17 07:02:34 +0000
commit853a9b2da417e0b170c6ead38421e1b282b208a9 (patch)
tree19da767d52de6c69209573814c662ab191b10726 /rail_map.h
parent4fb11f23adf3cb0100e39fc1fbf5b99c079781f4 (diff)
downloadopenttd-853a9b2da417e0b170c6ead38421e1b282b208a9.tar.xz
(svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
Diffstat (limited to 'rail_map.h')
-rw-r--r--rail_map.h70
1 files changed, 67 insertions, 3 deletions
diff --git a/rail_map.h b/rail_map.h
index ab09db4ed..b6f9512fe 100644
--- a/rail_map.h
+++ b/rail_map.h
@@ -3,9 +3,73 @@
#ifndef RAIL_MAP_H
#define RAIL_MAP_H
-#include "rail.h"
+#include "direction.h"
#include "tile.h"
-#include "waypoint.h"
+
+
+typedef enum RailTileType {
+ RAIL_TYPE_NORMAL = 0x0,
+ RAIL_TYPE_SIGNALS = 0x40,
+ RAIL_TYPE_UNUSED = 0x80, /* XXX: Maybe this could become waypoints? */
+ RAIL_TYPE_DEPOT_WAYPOINT = 0xC0, /* Is really depots and waypoints... */
+ RAIL_TILE_TYPE_MASK = 0xC0
+} RailTileType;
+
+static inline RailTileType GetRailTileType(TileIndex t)
+{
+ assert(IsTileType(t, MP_RAILWAY));
+ return _m[t].m5 & RAIL_TILE_TYPE_MASK;
+}
+
+
+/** These specify the subtype when the main rail type is
+ * RAIL_TYPE_DEPOT_WAYPOINT */
+typedef enum RailTileSubtypes {
+ RAIL_SUBTYPE_DEPOT = 0x00,
+ RAIL_SUBTYPE_WAYPOINT = 0x04,
+ RAIL_SUBTYPE_MASK = 0x3C
+} RailTileSubtype;
+
+
+typedef enum RailTypes {
+ RAILTYPE_RAIL = 0,
+ RAILTYPE_MONO = 1,
+ RAILTYPE_MAGLEV = 2,
+ RAILTYPE_END,
+ RAILTYPE_MASK = 0x3,
+ INVALID_RAILTYPE = 0xFF
+} RailType;
+
+static inline RailType GetRailType(TileIndex t)
+{
+ return (RailType)GB(_m[t].m3, 0, 4);
+}
+
+
+/** These are used to specify a single track.
+ * Can be translated to a trackbit with TrackToTrackbit */
+typedef enum Track {
+ TRACK_X = 0,
+ TRACK_Y = 1,
+ TRACK_UPPER = 2,
+ TRACK_LOWER = 3,
+ TRACK_LEFT = 4,
+ TRACK_RIGHT = 5,
+ TRACK_END,
+ INVALID_TRACK = 0xFF
+} Track;
+
+
+/** Bitfield corresponding to Track */
+typedef enum TrackBits {
+ TRACK_BIT_X = 1U << TRACK_X,
+ TRACK_BIT_Y = 1U << TRACK_Y,
+ TRACK_BIT_UPPER = 1U << TRACK_UPPER,
+ TRACK_BIT_LOWER = 1U << TRACK_LOWER,
+ TRACK_BIT_LEFT = 1U << TRACK_LEFT,
+ TRACK_BIT_RIGHT = 1U << TRACK_RIGHT,
+ TRACK_BIT_MASK = 0x3FU
+} TrackBits;
static inline DiagDirection GetRailDepotDirection(TileIndex t)
@@ -16,7 +80,7 @@ static inline DiagDirection GetRailDepotDirection(TileIndex t)
static inline TrackBits GetRailWaypointBits(TileIndex t)
{
- return _m[t].m5 & RAIL_WAYPOINT_TRACK_MASK ? TRACK_BIT_Y : TRACK_BIT_X;
+ return _m[t].m5 & 1 ? TRACK_BIT_Y : TRACK_BIT_X;
}