2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file track_func.h Different conversion functions from one kind of track to another. */
13 #include "core/bitmath_func.hpp"
14 #include "track_type.h"
15 #include "direction_func.h"
16 #include "slope_func.h"
18 using SetTrackBitIterator
= SetBitIterator
<Track
, TrackBits
>;
19 using SetTrackdirBitIterator
= SetBitIterator
<Trackdir
, TrackdirBits
>;
22 * Checks if a Track is valid.
24 * @param track The value to check
25 * @return true if the given value is a valid track.
26 * @note Use this in an assert()
28 inline bool IsValidTrack(Track track
)
30 return track
< TRACK_END
;
34 * Checks if a Trackdir is valid for road vehicles.
36 * @param trackdir The value to check
37 * @return true if the given value is a valid Trackdir
38 * @note Use this in an assert()
40 inline bool IsValidTrackdirForRoadVehicle(Trackdir trackdir
)
42 return trackdir
< TRACKDIR_END
;
46 * Checks if a Trackdir is valid for non-road vehicles.
48 * @param trackdir The value to check
49 * @return true if the given value is a valid Trackdir
50 * @note Use this in an assert()
52 inline bool IsValidTrackdir(Trackdir trackdir
)
54 return trackdir
!= INVALID_TRACKDIR
&& ((1 << trackdir
& TRACKDIR_BIT_MASK
) != TRACKDIR_BIT_NONE
);
58 * Convert an Axis to the corresponding Track
61 * Uses the fact that they share the same internal encoding
63 * @param a the axis to convert
64 * @return the track corresponding to the axis
66 inline Track
AxisToTrack(Axis a
)
68 assert(IsValidAxis(a
));
73 * Maps a Track to the corresponding TrackBits value
74 * @param track the track to convert
75 * @return the converted TrackBits value of the track
77 inline TrackBits
TrackToTrackBits(Track track
)
79 assert(IsValidTrack(track
));
80 return (TrackBits
)(1 << track
);
84 * Maps an Axis to the corresponding TrackBits value
85 * @param a the axis to convert
86 * @return the converted TrackBits value of the axis
88 inline TrackBits
AxisToTrackBits(Axis a
)
90 return TrackToTrackBits(AxisToTrack(a
));
94 * Returns a single horizontal/vertical trackbit that is in a specific tile corner.
96 * @param corner The corner of a tile.
97 * @return The TrackBits of the track in the corner.
99 inline TrackBits
CornerToTrackBits(Corner corner
)
101 extern const TrackBits _corner_to_trackbits
[];
102 assert(IsValidCorner(corner
));
103 return _corner_to_trackbits
[corner
];
107 * Maps a Trackdir to the corresponding TrackdirBits value
108 * @param trackdir the track direction to convert
109 * @return the converted TrackdirBits value
111 inline TrackdirBits
TrackdirToTrackdirBits(Trackdir trackdir
)
113 assert(IsValidTrackdir(trackdir
));
114 return (TrackdirBits
)(1 << trackdir
);
118 * Removes first Track from TrackBits and returns it
120 * This function searches for the first bit in the TrackBits,
121 * remove this bit from the parameter and returns the found
122 * bit as Track value. It returns INVALID_TRACK if the
123 * parameter was TRACK_BIT_NONE or INVALID_TRACK_BIT. This
124 * is basically used in while-loops to get up to 6 possible
125 * tracks on a tile until the parameter becomes TRACK_BIT_NONE.
127 * @param tracks The value with the TrackBits
128 * @return The first Track from the TrackBits value
129 * @see FindFirstTrack
131 inline Track
RemoveFirstTrack(TrackBits
*tracks
)
133 if (*tracks
!= TRACK_BIT_NONE
&& *tracks
!= INVALID_TRACK_BIT
) {
134 assert((*tracks
& ~TRACK_BIT_MASK
) == TRACK_BIT_NONE
);
135 Track first
= (Track
)FindFirstBit(*tracks
);
136 ClrBit(*tracks
, first
);
139 return INVALID_TRACK
;
143 * Removes first Trackdir from TrackdirBits and returns it
145 * This function searches for the first bit in the TrackdirBits parameter,
146 * remove this bit from the parameter and returns the fnound bit as
147 * Trackdir value. It returns INVALID_TRACKDIR if the trackdirs is
148 * TRACKDIR_BIT_NONE or INVALID_TRACKDIR_BIT. This is basically used in a
149 * while-loop to get all track-directions step by step until the value
150 * reaches TRACKDIR_BIT_NONE.
152 * @param trackdirs The value with the TrackdirBits
153 * @return The first Trackdir from the TrackdirBits value
154 * @see FindFirstTrackdir
156 inline Trackdir
RemoveFirstTrackdir(TrackdirBits
*trackdirs
)
158 if (*trackdirs
!= TRACKDIR_BIT_NONE
&& *trackdirs
!= INVALID_TRACKDIR_BIT
) {
159 assert((*trackdirs
& ~TRACKDIR_BIT_MASK
) == TRACKDIR_BIT_NONE
);
160 Trackdir first
= (Trackdir
)FindFirstBit(*trackdirs
);
161 ClrBit(*trackdirs
, first
);
164 return INVALID_TRACKDIR
;
168 * Returns first Track from TrackBits or INVALID_TRACK
170 * This function returns the first Track found in the TrackBits value as Track-value.
171 * It returns INVALID_TRACK if the parameter is TRACK_BIT_NONE or INVALID_TRACK_BIT.
173 * @param tracks The TrackBits value
174 * @return The first Track found or INVALID_TRACK
175 * @see RemoveFirstTrack
177 inline Track
FindFirstTrack(TrackBits tracks
)
179 return (tracks
!= TRACK_BIT_NONE
&& tracks
!= INVALID_TRACK_BIT
) ? (Track
)FindFirstBit(tracks
) : INVALID_TRACK
;
183 * Converts TrackBits to Track.
185 * This function converts a TrackBits value to a Track value. As it
186 * is not possible to convert two or more tracks to one track the
187 * parameter must contain only one track or be the INVALID_TRACK_BIT value.
189 * @param tracks The TrackBits value to convert
190 * @return The Track from the value or INVALID_TRACK
191 * @pre tracks must contains only one Track or be INVALID_TRACK_BIT
193 inline Track
TrackBitsToTrack(TrackBits tracks
)
195 assert(tracks
== INVALID_TRACK_BIT
|| (tracks
!= TRACK_BIT_NONE
&& KillFirstBit(tracks
& TRACK_BIT_MASK
) == TRACK_BIT_NONE
));
196 return tracks
!= INVALID_TRACK_BIT
? (Track
)FindFirstBit(tracks
& TRACK_BIT_MASK
) : INVALID_TRACK
;
200 * Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR
202 * This function returns the first Trackdir in the given TrackdirBits value or
203 * INVALID_TRACKDIR if the value is TRACKDIR_BIT_NONE. The TrackdirBits must
204 * not be INVALID_TRACKDIR_BIT.
206 * @param trackdirs The TrackdirBits value
207 * @return The first Trackdir from the TrackdirBits or INVALID_TRACKDIR on TRACKDIR_BIT_NONE.
208 * @pre trackdirs must not be INVALID_TRACKDIR_BIT
209 * @see RemoveFirstTrackdir
211 inline Trackdir
FindFirstTrackdir(TrackdirBits trackdirs
)
213 assert((trackdirs
& ~TRACKDIR_BIT_MASK
) == TRACKDIR_BIT_NONE
);
214 return (trackdirs
!= TRACKDIR_BIT_NONE
) ? (Trackdir
)FindFirstBit(trackdirs
) : INVALID_TRACKDIR
;
218 * Functions describing logical relations between Tracks, TrackBits, Trackdirs
219 * TrackdirBits, Direction and DiagDirections.
223 * Find the opposite track to a given track.
225 * TRACK_LOWER -> TRACK_UPPER and vice versa, likewise for left/right.
226 * TRACK_X is mapped to TRACK_Y and reversed.
228 * @param t the track to convert
229 * @return the opposite track
231 inline Track
TrackToOppositeTrack(Track t
)
233 assert(IsValidTrack(t
));
234 return (Track
)(t
^ 1);
238 * Maps a trackdir to the reverse trackdir.
240 * Returns the reverse trackdir of a Trackdir value. The reverse trackdir
241 * is the same track with the other direction on it.
243 * @param trackdir The Trackdir value
244 * @return The reverse trackdir
245 * @pre trackdir must not be INVALID_TRACKDIR
247 inline Trackdir
ReverseTrackdir(Trackdir trackdir
)
249 assert(IsValidTrackdirForRoadVehicle(trackdir
));
250 return (Trackdir
)(trackdir
^ 8);
254 * Returns the Track that a given Trackdir represents
256 * This function filters the Track which is used in the Trackdir value and
257 * returns it as a Track value.
259 * @param trackdir The trackdir value
260 * @return The Track which is used in the value
262 inline Track
TrackdirToTrack(Trackdir trackdir
)
264 assert(IsValidTrackdir(trackdir
));
265 return (Track
)(trackdir
& 0x7);
269 * Returns a Trackdir for the given Track
271 * Since every Track corresponds to two Trackdirs, we choose the
272 * one which points between NE and S. Note that the actual
273 * implementation is quite futile, but this might change
276 * @param track The given Track
277 * @return The Trackdir from the given Track
279 inline Trackdir
TrackToTrackdir(Track track
)
281 assert(IsValidTrack(track
));
282 return (Trackdir
)track
;
286 * Returns a TrackdirBit mask from a given Track
288 * The TrackdirBit mask contains the two TrackdirBits that
289 * correspond with the given Track (one for each direction).
291 * @param track The track to get the TrackdirBits from
292 * @return The TrackdirBits which the selected tracks
294 inline TrackdirBits
TrackToTrackdirBits(Track track
)
296 Trackdir td
= TrackToTrackdir(track
);
297 return (TrackdirBits
)(TrackdirToTrackdirBits(td
) | TrackdirToTrackdirBits(ReverseTrackdir(td
)));
301 * Discards all directional information from a TrackdirBits value
303 * Any Track which is present in either direction will be present in the result.
305 * @param bits The TrackdirBits to get the TrackBits from
306 * @return The TrackBits
308 inline TrackBits
TrackdirBitsToTrackBits(TrackdirBits bits
)
310 return (TrackBits
)((bits
| (bits
>> 8)) & TRACK_BIT_MASK
);
314 * Converts TrackBits to TrackdirBits while allowing both directions.
316 * @param bits The TrackBits
317 * @return The TrackdirBits containing of bits in both directions.
319 inline TrackdirBits
TrackBitsToTrackdirBits(TrackBits bits
)
321 return (TrackdirBits
)(bits
* 0x101);
325 * Checks whether a TrackBits has a given Track.
326 * @param tracks The track bits.
327 * @param track The track to check.
329 inline bool HasTrack(TrackBits tracks
, Track track
)
331 assert(IsValidTrack(track
));
332 return HasBit(tracks
, track
);
336 * Checks whether a TrackdirBits has a given Trackdir.
337 * @param trackdirs The trackdir bits.
338 * @param trackdir The trackdir to check.
340 inline bool HasTrackdir(TrackdirBits trackdirs
, Trackdir trackdir
)
342 assert(IsValidTrackdir(trackdir
));
343 return HasBit(trackdirs
, trackdir
);
347 * Returns the present-trackdir-information of a TrackStatus.
349 * @param ts The TrackStatus returned by GetTileTrackStatus()
350 * @return the present trackdirs
352 inline TrackdirBits
TrackStatusToTrackdirBits(TrackStatus ts
)
354 return (TrackdirBits
)(ts
& TRACKDIR_BIT_MASK
);
358 * Returns the present-track-information of a TrackStatus.
360 * @param ts The TrackStatus returned by GetTileTrackStatus()
361 * @return the present tracks
363 inline TrackBits
TrackStatusToTrackBits(TrackStatus ts
)
365 return TrackdirBitsToTrackBits(TrackStatusToTrackdirBits(ts
));
369 * Returns the red-signal-information of a TrackStatus.
371 * Note: The result may contain red signals for non-present tracks.
373 * @param ts The TrackStatus returned by GetTileTrackStatus()
374 * @return the The trackdirs that are blocked by red-signals
376 inline TrackdirBits
TrackStatusToRedSignals(TrackStatus ts
)
378 return (TrackdirBits
)((ts
>> 16) & TRACKDIR_BIT_MASK
);
382 * Builds a TrackStatus
384 * @param trackdirbits present trackdirs
385 * @param red_signals red signals
386 * @return the TrackStatus representing the given information
388 inline TrackStatus
CombineTrackStatus(TrackdirBits trackdirbits
, TrackdirBits red_signals
)
390 return (TrackStatus
)(trackdirbits
| (red_signals
<< 16));
394 * Maps a trackdir to the trackdir that you will end up on if you go straight
397 * This will be the same trackdir for diagonal trackdirs, but a
398 * different (alternating) one for straight trackdirs
400 * @param trackdir The given trackdir
401 * @return The next Trackdir value of the next tile.
403 inline Trackdir
NextTrackdir(Trackdir trackdir
)
405 assert(IsValidTrackdir(trackdir
));
406 extern const Trackdir _next_trackdir
[TRACKDIR_END
];
407 return _next_trackdir
[trackdir
];
411 * Maps a track to all tracks that make 90 deg turns with it.
413 * For the diagonal directions these are the complement of the
414 * direction, for the straight directions these are the
415 * two vertical or horizontal tracks, depend on the given direction
417 * @param track The given track
418 * @return The TrackBits with the tracks marked which cross the given track by 90 deg.
420 inline TrackBits
TrackCrossesTracks(Track track
)
422 assert(IsValidTrack(track
));
423 extern const TrackBits _track_crosses_tracks
[TRACK_END
];
424 return _track_crosses_tracks
[track
];
428 * Maps a trackdir to the (4-way) direction the tile is exited when following
431 * For the diagonal directions these are the same directions. For
432 * the straight directions these are the directions from the imagined
433 * base-tile to the bordering tile which will be joined if the given
434 * straight direction is leaved from the base-tile.
436 * @param trackdir The given track direction
437 * @return The direction which points to the resulting tile if following the Trackdir
439 inline DiagDirection
TrackdirToExitdir(Trackdir trackdir
)
441 assert(IsValidTrackdirForRoadVehicle(trackdir
));
442 extern const DiagDirection _trackdir_to_exitdir
[TRACKDIR_END
];
443 return _trackdir_to_exitdir
[trackdir
];
447 * Maps a track and an (4-way) dir to the trackdir that represents the track
448 * with the exit in the given direction.
450 * For the diagonal tracks the resulting track direction are clear for a given
451 * DiagDirection. It either matches the direction or it returns INVALID_TRACKDIR,
452 * as a TRACK_X cannot be applied with DIAG_SE.
453 * For the straight tracks the resulting track direction will be the
454 * direction which the DiagDirection is pointing. But this will be INVALID_TRACKDIR
455 * if the DiagDirection is pointing 'away' the track.
457 * @param track The track to apply an direction on
458 * @param diagdir The DiagDirection to apply on
459 * @return The resulting track direction or INVALID_TRACKDIR if not possible.
461 inline Trackdir
TrackExitdirToTrackdir(Track track
, DiagDirection diagdir
)
463 assert(IsValidTrack(track
));
464 assert(IsValidDiagDirection(diagdir
));
465 extern const Trackdir _track_exitdir_to_trackdir
[TRACK_END
][DIAGDIR_END
];
466 return _track_exitdir_to_trackdir
[track
][diagdir
];
470 * Maps a track and an (4-way) dir to the trackdir that represents the track
471 * with the entry in the given direction.
473 * For the diagonal tracks the return value is clear, its either the matching
474 * track direction or INVALID_TRACKDIR.
475 * For the straight tracks this returns the track direction which results if
476 * you follow the DiagDirection and then turn by 45 deg left or right on the
477 * next tile. The new direction on the new track will be the returning Trackdir
478 * value. If the parameters makes no sense like the track TRACK_UPPER and the
479 * direction DIAGDIR_NE (target track cannot be reached) this function returns
482 * @param track The target track
483 * @param diagdir The direction to "come from"
484 * @return the resulting Trackdir or INVALID_TRACKDIR if not possible.
486 inline Trackdir
TrackEnterdirToTrackdir(Track track
, DiagDirection diagdir
)
488 assert(IsValidTrack(track
));
489 assert(IsValidDiagDirection(diagdir
));
490 extern const Trackdir _track_enterdir_to_trackdir
[TRACK_END
][DIAGDIR_END
];
491 return _track_enterdir_to_trackdir
[track
][diagdir
];
495 * Maps a track and a full (8-way) direction to the trackdir that represents
496 * the track running in the given direction.
498 inline Trackdir
TrackDirectionToTrackdir(Track track
, Direction dir
)
500 assert(IsValidTrack(track
));
501 assert(IsValidDirection(dir
));
502 extern const Trackdir _track_direction_to_trackdir
[TRACK_END
][DIR_END
];
503 return _track_direction_to_trackdir
[track
][dir
];
507 * Maps a (4-way) direction to the diagonal track incidating with that diagdir
509 * @param diagdir The direction
510 * @return The resulting Track
512 inline Track
DiagDirToDiagTrack(DiagDirection diagdir
)
514 assert(IsValidDiagDirection(diagdir
));
515 return (Track
)(diagdir
& 1);
519 * Maps a (4-way) direction to the diagonal track bits incidating with that diagdir
521 * @param diagdir The direction
522 * @return The resulting TrackBits
524 inline TrackBits
DiagDirToDiagTrackBits(DiagDirection diagdir
)
526 assert(IsValidDiagDirection(diagdir
));
527 return TrackToTrackBits(DiagDirToDiagTrack(diagdir
));
531 * Maps a (4-way) direction to the diagonal trackdir that runs in that
534 * @param diagdir The direction
535 * @return The resulting Trackdir direction
537 inline Trackdir
DiagDirToDiagTrackdir(DiagDirection diagdir
)
539 assert(IsValidDiagDirection(diagdir
));
540 extern const Trackdir _dir_to_diag_trackdir
[DIAGDIR_END
];
541 return _dir_to_diag_trackdir
[diagdir
];
545 * Returns all trackdirs that can be reached when entering a tile from a given
546 * (diagonal) direction.
548 * This will obviously include 90 degree turns, since no information is available
549 * about the exact angle of entering
551 * @param diagdir The joining direction
552 * @return The TrackdirBits which can be used from the given direction
553 * @see DiagdirReachesTracks
555 inline TrackdirBits
DiagdirReachesTrackdirs(DiagDirection diagdir
)
557 assert(IsValidDiagDirection(diagdir
));
558 extern const TrackdirBits _exitdir_reaches_trackdirs
[DIAGDIR_END
];
559 return _exitdir_reaches_trackdirs
[diagdir
];
563 * Returns all tracks that can be reached when entering a tile from a given
564 * (diagonal) direction.
566 * This will obviously include 90 degree turns, since no
567 * information is available about the exact angle of entering
569 * @param diagdir The joining direction
570 * @return The tracks which can be used
571 * @see DiagdirReachesTrackdirs
573 inline TrackBits
DiagdirReachesTracks(DiagDirection diagdir
) { return TrackdirBitsToTrackBits(DiagdirReachesTrackdirs(diagdir
)); }
576 * Maps a trackdir to the trackdirs that can be reached from it (ie, when
577 * entering the next tile.
579 * This will include 90 degree turns!
581 * @param trackdir The track direction which will be leaved
582 * @return The track directions which can be used from this direction (in the next tile)
584 inline TrackdirBits
TrackdirReachesTrackdirs(Trackdir trackdir
)
586 assert(IsValidTrackdir(trackdir
));
587 extern const TrackdirBits _exitdir_reaches_trackdirs
[DIAGDIR_END
];
588 return _exitdir_reaches_trackdirs
[TrackdirToExitdir(trackdir
)];
590 /* Note that there is no direct table for this function (there used to be),
591 * but it uses two simpler tables to achieve the result */
594 * Maps a trackdir to all trackdirs that make 90 deg turns with it.
596 * For the diagonal tracks this returns the track direction bits
597 * of the other axis in both directions, which cannot be joined by
598 * the given track direction.
599 * For the straight tracks this returns all possible 90 deg turns
600 * either on the current tile (which no train can joined) or on the
603 * @param trackdir The track direction
604 * @return The TrackdirBits which are (more or less) 90 deg turns.
606 inline TrackdirBits
TrackdirCrossesTrackdirs(Trackdir trackdir
)
608 assert(IsValidTrackdirForRoadVehicle(trackdir
));
609 extern const TrackdirBits _track_crosses_trackdirs
[TRACK_END
];
610 return _track_crosses_trackdirs
[TrackdirToTrack(trackdir
)];
614 * Checks if a given Track is diagonal
616 * @param track The given track to check
617 * @return true if diagonal, else false
619 inline bool IsDiagonalTrack(Track track
)
621 assert(IsValidTrack(track
));
622 return (track
== TRACK_X
) || (track
== TRACK_Y
);
626 * Checks if a given Trackdir is diagonal.
628 * @param trackdir The given trackdir
629 * @return true if the trackdir use a diagonal track
631 inline bool IsDiagonalTrackdir(Trackdir trackdir
)
633 assert(IsValidTrackdir(trackdir
));
634 return IsDiagonalTrack(TrackdirToTrack(trackdir
));
639 * Checks if the given tracks overlap, ie form a crossing. Basically this
640 * means when there is more than one track on the tile, except when there are
641 * two parallel tracks.
642 * @param bits The tracks present.
643 * @return Whether the tracks present overlap in any way.
645 inline bool TracksOverlap(TrackBits bits
)
647 /* With no, or only one track, there is no overlap */
648 if (bits
== TRACK_BIT_NONE
|| KillFirstBit(bits
) == TRACK_BIT_NONE
) return false;
649 /* We know that there are at least two tracks present. When there are more
650 * than 2 tracks, they will surely overlap. When there are two, they will
651 * always overlap unless they are lower & upper or right & left. */
652 return bits
!= TRACK_BIT_HORZ
&& bits
!= TRACK_BIT_VERT
;
656 * Check if a given track is contained within or overlaps some other tracks.
658 * @param tracks Tracks to be tested against
659 * @param track The track to test
660 * @return true if the track is already in the tracks or overlaps the tracks.
662 inline bool TrackOverlapsTracks(TrackBits tracks
, Track track
)
664 if (HasBit(tracks
, track
)) return true;
665 return TracksOverlap(tracks
| TrackToTrackBits(track
));
669 * Checks whether the trackdir means that we are reversing.
670 * @param dir the trackdir to check
671 * @return true if it is a reversing road trackdir
673 inline bool IsReversingRoadTrackdir(Trackdir dir
)
675 assert(IsValidTrackdirForRoadVehicle(dir
));
676 return (dir
& 0x07) >= 6;
680 * Checks whether the given trackdir is a straight road
681 * @param dir the trackdir to check
682 * @return true if it is a straight road trackdir
684 inline bool IsStraightRoadTrackdir(Trackdir dir
)
686 assert(IsValidTrackdirForRoadVehicle(dir
));
687 return (dir
& 0x06) == 0;
691 * Checks whether a trackdir on a specific slope is going uphill.
693 * Valid for rail and road tracks.
694 * Valid for tile-slopes (under foundation) and foundation-slopes (on foundation).
696 * @param slope The slope of the tile.
697 * @param dir The trackdir of interest.
698 * @return true iff the track goes upwards.
700 inline bool IsUphillTrackdir(Slope slope
, Trackdir dir
)
702 assert(IsValidTrackdirForRoadVehicle(dir
));
703 extern const TrackdirBits _uphill_trackdirs
[];
704 return HasBit(_uphill_trackdirs
[RemoveHalftileSlope(slope
)], dir
);
708 * Determine the side in which the vehicle will leave the tile
710 * @param direction vehicle direction
711 * @param track vehicle track bits
712 * @return side of tile the vehicle will leave
714 inline DiagDirection
VehicleExitDir(Direction direction
, TrackBits track
)
716 static const TrackBits state_dir_table
[DIAGDIR_END
] = { TRACK_BIT_RIGHT
, TRACK_BIT_LOWER
, TRACK_BIT_LEFT
, TRACK_BIT_UPPER
};
718 DiagDirection diagdir
= DirToDiagDir(direction
);
720 /* Determine the diagonal direction in which we will exit this tile */
721 if (!HasBit(direction
, 0) && track
!= state_dir_table
[diagdir
]) {
722 diagdir
= ChangeDiagDir(diagdir
, DIAGDIRDIFF_90LEFT
);
728 #endif /* TRACK_FUNC_H */