(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().

This commit is contained in:
frosch
2008-02-20 17:49:50 +00:00
parent 9e65157548
commit b7993793c8
30 changed files with 180 additions and 134 deletions

View File

@@ -273,6 +273,64 @@ static inline TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
return (TrackBits)((bits | (bits >> 8)) & TRACK_BIT_MASK);
}
/**
* 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.