src/track_func.h
branchNewGRF_ports
changeset 10724 68a692eacf22
parent 6878 7d1ff2f621c7
equal deleted inserted replaced
10349:ff900a23e102 10724:68a692eacf22
    21  */
    21  */
    22 static inline Track AxisToTrack(Axis a)
    22 static inline Track AxisToTrack(Axis a)
    23 {
    23 {
    24 	return (Track)a;
    24 	return (Track)a;
    25 }
    25 }
    26 
       
    27 
       
    28 
    26 
    29 /**
    27 /**
    30  * Maps a Track to the corresponding TrackBits value
    28  * Maps a Track to the corresponding TrackBits value
    31  * @param track the track to convert
    29  * @param track the track to convert
    32  * @return the converted TrackBits value of the track
    30  * @return the converted TrackBits value of the track
   275 
   273 
   276 /**
   274 /**
   277  * Converts TrackBits to TrackdirBits while allowing both directions.
   275  * Converts TrackBits to TrackdirBits while allowing both directions.
   278  *
   276  *
   279  * @param bits The TrackBits
   277  * @param bits The TrackBits
   280  * @return The TrackDirBits containing of bits in both directions.
   278  * @return The TrackdirBits containing of bits in both directions.
   281  */
   279  */
   282 static inline TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
   280 static inline TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
   283 {
   281 {
   284 	return (TrackdirBits)(bits * 0x101);
   282 	return (TrackdirBits)(bits * 0x101);
   285 }
   283 }
   434 	extern const Trackdir _track_direction_to_trackdir[TRACK_END][DIR_END];
   432 	extern const Trackdir _track_direction_to_trackdir[TRACK_END][DIR_END];
   435 	return _track_direction_to_trackdir[track][dir];
   433 	return _track_direction_to_trackdir[track][dir];
   436 }
   434 }
   437 
   435 
   438 /**
   436 /**
       
   437  * Maps a (4-way) direction to the diagonal track incidating with that diagdir
       
   438  *
       
   439  * @param diagdir The direction
       
   440  * @return The resulting Track
       
   441  */
       
   442 static inline Track DiagDirToDiagTrack(DiagDirection diagdir)
       
   443 {
       
   444 	return (Track)(diagdir & 1);
       
   445 }
       
   446 
       
   447 /**
       
   448  * Maps a (4-way) direction to the diagonal track bits incidating with that diagdir
       
   449  *
       
   450  * @param diagdir The direction
       
   451  * @return The resulting TrackBits
       
   452  */
       
   453 static inline TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
       
   454 {
       
   455 	return TrackToTrackBits(DiagDirToDiagTrack(diagdir));
       
   456 }
       
   457 
       
   458 /**
   439  * Maps a (4-way) direction to the diagonal trackdir that runs in that
   459  * Maps a (4-way) direction to the diagonal trackdir that runs in that
   440  * direction.
   460  * direction.
   441  *
   461  *
   442  * @param diagdir The direction
   462  * @param diagdir The direction
   443  * @return The resulting Trackdir direction
   463  * @return The resulting Trackdir direction
   444  */
   464  */
   445 static inline Trackdir DiagdirToDiagTrackdir(DiagDirection diagdir)
   465 static inline Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
   446 {
   466 {
   447 	extern const Trackdir _dir_to_diag_trackdir[DIAGDIR_END];
   467 	extern const Trackdir _dir_to_diag_trackdir[DIAGDIR_END];
   448 	return _dir_to_diag_trackdir[diagdir];
   468 	return _dir_to_diag_trackdir[diagdir];
   449 }
   469 }
   450 
   470