From ec627dedf884069a1cbca8ebf524d761e755493c Mon Sep 17 00:00:00 2001 From: smatz Date: Wed, 14 May 2008 18:31:21 +0000 Subject: (svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits --- src/track_func.h | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'src/track_func.h') diff --git a/src/track_func.h b/src/track_func.h index 88d8d423e..e6591212a 100644 --- a/src/track_func.h +++ b/src/track_func.h @@ -24,8 +24,6 @@ static inline Track AxisToTrack(Axis a) return (Track)a; } - - /** * Maps a Track to the corresponding TrackBits value * @param track the track to convert @@ -277,7 +275,7 @@ 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. + * @return The TrackdirBits containing of bits in both directions. */ static inline TrackdirBits TrackBitsToTrackdirBits(TrackBits bits) { @@ -435,6 +433,28 @@ static inline Trackdir TrackDirectionToTrackdir(Track track, Direction dir) return _track_direction_to_trackdir[track][dir]; } +/** + * Maps a (4-way) direction to the diagonal track incidating with that diagdir + * + * @param diagdir The direction + * @return The resulting Track + */ +static inline Track DiagDirToDiagTrack(DiagDirection diagdir) +{ + return (Track)(diagdir & 1); +} + +/** + * Maps a (4-way) direction to the diagonal track bits incidating with that diagdir + * + * @param diagdir The direction + * @return The resulting TrackBits + */ +static inline TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir) +{ + return TrackToTrackBits(DiagDirToDiagTrack(diagdir)); +} + /** * Maps a (4-way) direction to the diagonal trackdir that runs in that * direction. @@ -442,7 +462,7 @@ static inline Trackdir TrackDirectionToTrackdir(Track track, Direction dir) * @param diagdir The direction * @return The resulting Trackdir direction */ -static inline Trackdir DiagdirToDiagTrackdir(DiagDirection diagdir) +static inline Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir) { extern const Trackdir _dir_to_diag_trackdir[DIAGDIR_END]; return _dir_to_diag_trackdir[diagdir]; -- cgit v1.2.3-54-g00ecf