diff -r d9525e4e85f5 -r fd862a55c47f src/track_func.h --- a/src/track_func.h Wed Feb 20 17:12:08 2008 +0000 +++ b/src/track_func.h Wed Feb 20 17:49:50 2008 +0000 @@ -274,6 +274,64 @@ } /** + * 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. *