summaryrefslogtreecommitdiff
path: root/rail.h
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-07-22 08:59:52 +0000
committertron <tron@openttd.org>2006-07-22 08:59:52 +0000
commit7ec704564a35940442d5ad52b39c850465685f31 (patch)
tree3cd7af50d593f93b4699b58b3293d63c0a9c7eef /rail.h
parent475f2767691da03e22cdcd6eb7bfd305c093166c (diff)
downloadopenttd-7ec704564a35940442d5ad52b39c850465685f31.tar.xz
(svn r5582) Add and use AxisToTrack{Bits,}()
Diffstat (limited to 'rail.h')
-rw-r--r--rail.h31
1 files changed, 26 insertions, 5 deletions
diff --git a/rail.h b/rail.h
index 62a633aae..b3ce18798 100644
--- a/rail.h
+++ b/rail.h
@@ -34,6 +34,17 @@ typedef enum Track {
} Track;
+/** Convert an Axis to the corresponding Track
+ * AXIS_X -> TRACK_X
+ * AXIS_Y -> TRACK_Y
+ * Uses the fact that they share the same internal encoding
+ */
+static inline Track AxisToTrack(Axis a)
+{
+ return (Track)a;
+}
+
+
/** Bitfield corresponding to Track */
typedef enum TrackBits {
TRACK_BIT_NONE = 0U,
@@ -55,6 +66,21 @@ typedef enum TrackBits {
} TrackBits;
+/**
+ * Maps a Track to the corresponding TrackBits value
+ */
+static inline TrackBits TrackToTrackBits(Track track)
+{
+ return (TrackBits)(1 << track);
+}
+
+
+static inline TrackBits AxisToTrackBits(Axis a)
+{
+ return TrackToTrackBits(AxisToTrack(a));
+}
+
+
/** These are a combination of tracks and directions. Values are 0-5 in one
direction (corresponding to the Track enum) and 8-13 in the other direction. */
typedef enum Trackdirs {
@@ -242,11 +268,6 @@ static inline Trackdir ReverseTrackdir(Trackdir trackdir) {
}
/**
- * Maps a Track to the corresponding TrackBits value
- */
-static inline TrackBits TrackToTrackBits(Track track) { return (TrackBits)(1 << track); }
-
-/**
* Returns the Track that a given Trackdir represents
*/
static inline Track TrackdirToTrack(Trackdir trackdir) { return (Track)(trackdir & 0x7); }