101 extern const TrackBits _corner_to_trackbits[];
103 return _corner_to_trackbits[corner];
161 ClrBit(*trackdirs, first);
234 return (
Track)(t ^ 1);
265 return (
Track)(trackdir & 0x7);
332 return HasBit(tracks, track);
343 return HasBit(trackdirs, trackdir);
390 return (TrackStatus)(trackdirbits | (red_signals << 16));
407 return _next_trackdir[trackdir];
424 return _track_crosses_tracks[track];
443 return _trackdir_to_exitdir[trackdir];
466 return _track_exitdir_to_trackdir[track][diagdir];
491 return _track_enterdir_to_trackdir[track][diagdir];
503 return _track_direction_to_trackdir[track][dir];
515 return (
Track)(diagdir & 1);
541 return _dir_to_diag_trackdir[diagdir];
559 return _exitdir_reaches_trackdirs[diagdir];
664 if (
HasBit(tracks, track))
return true;
676 return (dir & 0x07) >= 6;
687 return (dir & 0x06) == 0;
721 if (!
HasBit(direction, 0) && track != state_dir_table[diagdir]) {
Functions related to bit mathematics.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr uint8_t FindFirstBit(T x)
Search the first set bit in a value.
constexpr T KillFirstBit(T value)
Clear the first bit in an integer.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
Different functions related to conversions between directions.
bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
DiagDirection ChangeDiagDir(DiagDirection d, DiagDirDiff delta)
Applies a difference on a DiagDirection.
bool IsValidDirection(Direction d)
Checks if an integer value is a valid Direction.
DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
Direction
Defines the 8 directions on the map.
@ DIR_END
Used to iterate.
Axis
Allow incrementing of DiagDirDiff variables.
DiagDirection
Enumeration for diagonal directions.
@ DIAGDIR_END
Used for iterations.
@ DIAGDIRDIFF_90LEFT
90 degrees left
Functions related to slopes.
static constexpr Slope RemoveHalftileSlope(Slope s)
Removes a halftile slope from a slope.
static constexpr bool IsValidCorner(Corner corner)
Rangecheck for Corner enumeration.
Slope
Enumeration for the slope-type.
Corner
Enumeration of tile corners.
Iterable ensemble of each set bit in a value.
Trackdir TrackToTrackdir(Track track)
Returns a Trackdir for the given Track.
bool HasTrack(TrackBits tracks, Track track)
Checks whether a TrackBits has a given Track.
Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs)
Removes first Trackdir from TrackdirBits and returns it.
Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.
Track TrackToOppositeTrack(Track t)
Find the opposite track to a given track.
bool TrackOverlapsTracks(TrackBits tracks, Track track)
Check if a given track is contained within or overlaps some other tracks.
bool IsUphillTrackdir(Slope slope, Trackdir dir)
Checks whether a trackdir on a specific slope is going uphill.
TrackBits CornerToTrackBits(Corner corner)
Returns a single horizontal/vertical trackbit that is in a specific tile corner.
bool IsDiagonalTrack(Track track)
Checks if a given Track is diagonal.
TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
DiagDirection VehicleExitDir(Direction direction, TrackBits track)
Determine the side in which the vehicle will leave the tile.
TrackdirBits TrackStatusToTrackdirBits(TrackStatus ts)
Returns the present-trackdir-information of a TrackStatus.
bool IsReversingRoadTrackdir(Trackdir dir)
Checks whether the trackdir means that we are reversing.
Track TrackBitsToTrack(TrackBits tracks)
Converts TrackBits to Track.
TrackBits TrackCrossesTracks(Track track)
Maps a track to all tracks that make 90 deg turns with it.
Trackdir NextTrackdir(Trackdir trackdir)
Maps a trackdir to the trackdir that you will end up on if you go straight ahead.
Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
Builds a TrackStatus.
bool TracksOverlap(TrackBits bits)
Checks if the given tracks overlap, ie form a crossing.
Trackdir TrackDirectionToTrackdir(Track track, Direction dir)
Maps a track and a full (8-way) direction to the trackdir that represents the track running in the gi...
TrackBits AxisToTrackBits(Axis a)
Maps an Axis to the corresponding TrackBits value.
bool IsValidTrackdir(Trackdir trackdir)
Checks if a Trackdir is valid for non-road vehicles.
Trackdir FindFirstTrackdir(TrackdirBits trackdirs)
Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR.
bool IsValidTrackdirForRoadVehicle(Trackdir trackdir)
Checks if a Trackdir is valid for road vehicles.
TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
Maps a trackdir to all trackdirs that make 90 deg turns with it.
TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir)
Maps a trackdir to the trackdirs that can be reached from it (ie, when entering the next tile.
TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir)
Returns all trackdirs that can be reached when entering a tile from a given (diagonal) direction.
bool IsValidTrack(Track track)
Checks if a Track is valid.
Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
Trackdir TrackEnterdirToTrackdir(Track track, DiagDirection diagdir)
Maps a track and an (4-way) dir to the trackdir that represents the track with the entry in the given...
bool IsDiagonalTrackdir(Trackdir trackdir)
Checks if a given Trackdir is diagonal.
bool HasTrackdir(TrackdirBits trackdirs, Trackdir trackdir)
Checks whether a TrackdirBits has a given Trackdir.
TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction.
bool IsStraightRoadTrackdir(Trackdir dir)
Checks whether the given trackdir is a straight road.
TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir.
Trackdir TrackExitdirToTrackdir(Track track, DiagDirection diagdir)
Maps a track and an (4-way) dir to the trackdir that represents the track with the exit in the given ...
Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir)
Maps a Trackdir to the corresponding TrackdirBits value.
TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track AXIS_X -> TRACK_X AXIS_Y -> TRACK_Y Uses the fact that the...
Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
TrackdirBits TrackStatusToRedSignals(TrackStatus ts)
Returns the red-signal-information of a TrackStatus.
DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
TrackdirBits TrackToTrackdirBits(Track track)
Returns a TrackdirBit mask from a given Track.
Track DiagDirToDiagTrack(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track incidating with that diagdir.
TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
Discards all directional information from a TrackdirBits value.
All types related to tracks.
TrackBits
Allow incrementing of Track variables.
@ TRACK_BIT_UPPER
Upper track.
@ TRACK_BIT_LEFT
Left track.
@ INVALID_TRACK_BIT
Flag for an invalid trackbits value.
@ TRACK_BIT_HORZ
Upper and lower track.
@ TRACK_BIT_NONE
No track.
@ TRACK_BIT_MASK
Bitmask for the first 6 bits.
@ TRACK_BIT_LOWER
Lower track.
@ TRACK_BIT_RIGHT
Right track.
@ TRACK_BIT_VERT
Left and right track.
Trackdir
Enumeration for tracks and directions.
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
@ TRACKDIR_END
Used for iterations.
TrackdirBits
Allow incrementing of Trackdir variables.
@ TRACKDIR_BIT_NONE
No track build.
@ TRACKDIR_BIT_MASK
Bitmask for bit-operations.
@ INVALID_TRACKDIR_BIT
Flag for an invalid trackdirbit value.
Track
These are used to specify a single track.
@ INVALID_TRACK
Flag for an invalid track.
@ TRACK_Y
Track along the y-axis (north-west to south-east)
@ TRACK_END
Used for iterations.
@ TRACK_X
Track along the x-axis (north-east to south-west)