summaryrefslogtreecommitdiff
path: root/src/track_func.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-02-20 17:49:50 +0000
committerfrosch <frosch@openttd.org>2008-02-20 17:49:50 +0000
commitb7993793c813359ba4963df93d49a80335ddca36 (patch)
treed325400c42801ac23226ccaf0d71008e4e3598ec /src/track_func.h
parent9e651575481dbdd4b587fe22e2d79b998bcbbe15 (diff)
downloadopenttd-b7993793c813359ba4963df93d49a80335ddca36.tar.xz
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
Diffstat (limited to 'src/track_func.h')
-rw-r--r--src/track_func.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/track_func.h b/src/track_func.h
index 47364b8c0..38a1bba66 100644
--- a/src/track_func.h
+++ b/src/track_func.h
@@ -274,6 +274,64 @@ static inline TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
}
/**
+ * Converts TrackBits to TrackdirBits while allowing both directions.
+ *
+ * @param bits The TrackBits
+ * @return The TrackDirBits containing of bits in both directions.
+ */
+static inline TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
+{
+ return (TrackdirBits)(bits * 0x101);
+}
+
+/**
+ * Returns the present-trackdir-information of a TrackStatus.
+ *
+ * @param ts The TrackStatus returned by GetTileTrackStatus()
+ * @return the present trackdirs
+ */
+static inline TrackdirBits TrackStatusToTrackdirBits(TrackStatus ts)
+{
+ return (TrackdirBits)(ts & TRACKDIR_BIT_MASK);
+}
+
+/**
+ * Returns the present-track-information of a TrackStatus.
+ *
+ * @param ts The TrackStatus returned by GetTileTrackStatus()
+ * @return the present tracks
+ */
+static inline TrackBits TrackStatusToTrackBits(TrackStatus ts)
+{
+ return TrackdirBitsToTrackBits(TrackStatusToTrackdirBits(ts));
+}
+
+/**
+ * Returns the red-signal-information of a TrackStatus.
+ *
+ * Note: The result may contain red signals for non-present tracks.
+ *
+ * @param ts The TrackStatus returned by GetTileTrackStatus()
+ * @return the The trackdirs that are blocked by red-signals
+ */
+static inline TrackdirBits TrackStatusToRedSignals(TrackStatus ts)
+{
+ return (TrackdirBits)((ts >> 16) & TRACKDIR_BIT_MASK);
+}
+
+/**
+ * Builds a TrackStatus
+ *
+ * @param trackdirbits present trackdirs
+ * @param red_signals red signals
+ * @return the TrackStatus representing the given information
+ */
+static inline TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
+{
+ return (TrackStatus)(trackdirbits | (red_signals << 16));
+}
+
+/**
* Maps a trackdir to the trackdir that you will end up on if you go straight
* ahead.
*