29 #define FOR_EACH_SET_TRACK(var, track_bits) FOR_EACH_SET_BIT_EX(Track, var, TrackBits, track_bits) 111 extern const TrackBits _corner_to_trackbits[];
113 return _corner_to_trackbits[corner];
171 ClrBit(*trackdirs, first);
244 return (
Track)(t ^ 1);
275 return (
Track)(trackdir & 0x7);
378 return (TrackStatus)(trackdirbits | (red_signals << 16));
395 return _next_trackdir[trackdir];
412 return _track_crosses_tracks[track];
431 return _trackdir_to_exitdir[trackdir];
454 return _track_exitdir_to_trackdir[track][diagdir];
479 return _track_enterdir_to_trackdir[track][diagdir];
491 return _track_direction_to_trackdir[track][dir];
503 return (
Track)(diagdir & 1);
529 return _dir_to_diag_trackdir[diagdir];
547 return _exitdir_reaches_trackdirs[diagdir];
652 if (
HasBit(tracks, track))
return true;
664 return (dir & 0x07) >= 6;
675 return (dir & 0x06) == 0;
All types related to tracks.
Corner
Enumeration of tile corners.
static bool IsValidDirection(Direction d)
Checks if an integer value is a valid Direction.
Bitmask for the first 6 bits.
static bool IsReversingRoadTrackdir(Trackdir dir)
Checks whether the trackdir means that we are reversing.
static Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.
Flag for an invalid trackdirbit value.
Track
These are used to specify a single track.
static TrackBits AxisToTrackBits(Axis a)
Maps an Axis to the corresponding TrackBits value.
static TrackdirBits TrackToTrackdirBits(Track track)
Returns a TrackdirBit mask from a given Track.
static bool IsValidCorner(Corner corner)
Rangecheck for Corner enumeration.
static TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir. ...
static 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...
static Trackdir NextTrackdir(Trackdir trackdir)
Maps a trackdir to the trackdir that you will end up on if you go straight ahead. ...
Functions related to bit mathematics.
static Track TrackToOppositeTrack(Track t)
Find the opposite track to a given track.
static Track DiagDirToDiagTrack(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track incidating with that diagdir.
static Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track AXIS_X -> TRACK_X AXIS_Y -> TRACK_Y Uses the fact that the...
static TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir)
Returns all trackdirs that can be reached when entering a tile from a given (diagonal) direction...
static DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
Direction
Defines the 8 directions on the map.
static TrackBits CornerToTrackBits(Corner corner)
Returns a single horizontal/vertical trackbit that is in a specific tile corner.
static bool IsStraightRoadTrackdir(Trackdir dir)
Checks whether the given trackdir is a straight road.
static bool IsUphillTrackdir(Slope slope, Trackdir dir)
Checks whether a trackdir on a specific slope is going uphill.
static Track TrackBitsToTrack(TrackBits tracks)
Converts TrackBits to Track.
TrackBits
Bitfield corresponding to Track.
static bool TrackOverlapsTracks(TrackBits tracks, Track track)
Check if a given track is contained within or overlaps some other tracks.
static bool IsValidTrackdir(Trackdir trackdir)
Checks if a Trackdir is valid for non-road vehicles.
Flag for an invalid trackbits value.
Track along the y-axis (north-west to south-east)
static bool IsValidTrack(Track track)
Checks if a Track is valid.
#define FIND_FIRST_BIT(x)
Returns the first non-zero bit in a 6-bit value (from right).
static TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir)
Maps a Trackdir to the corresponding TrackdirBits value.
Functions related to slopes.
static bool IsValidTrackdirForRoadVehicle(Trackdir trackdir)
Checks if a Trackdir is valid for road vehicles.
static Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs)
Removes first Trackdir from TrackdirBits and returns it.
Trackdir
Enumeration for tracks and directions.
static TrackdirBits TrackStatusToRedSignals(TrackStatus ts)
Returns the red-signal-information of a TrackStatus.
static bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
static 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...
static Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
DiagDirection
Enumeration for diagonal directions.
Bitmask for bit-operations.
static TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir)
Maps a trackdir to the trackdirs that can be reached from it (ie, when entering the next tile...
static TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
Builds a TrackStatus.
static Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
static Slope RemoveHalftileSlope(Slope s)
Removes a halftile slope from a slope.
static TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction...
static bool IsDiagonalTrack(Track track)
Checks if a given Track is diagonal.
static TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
static T KillFirstBit(T value)
Clear the first bit in an integer.
Flag for an invalid track.
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
static Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
static Trackdir TrackToTrackdir(Track track)
Returns a Trackdir for the given Track.
static bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
static bool IsDiagonalTrackdir(Trackdir trackdir)
Checks if a given Trackdir is diagonal.
Slope
Enumeration for the slope-type.
static uint8 FindFirstBit2x64(const int value)
Finds the position of the first non-zero bit in an integer.
static Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
TrackdirBits
Enumeration of bitmasks for the TrackDirs.
static 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 ...
static TrackBits TrackCrossesTracks(Track track)
Maps a track to all tracks that make 90 deg turns with it.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
static TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
static TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
Discards all directional information from a TrackdirBits value.
Different functions related to conversions between directions.
Flag for an invalid trackdir.
Track along the x-axis (north-east to south-west)
static TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
Maps a trackdir to all trackdirs that make 90 deg turns with it.
static TrackdirBits TrackStatusToTrackdirBits(TrackStatus ts)
Returns the present-trackdir-information of a TrackStatus.
Axis
Allow incrementing of DiagDirDiff variables.
static bool TracksOverlap(TrackBits bits)
Checks if the given tracks overlap, ie form a crossing.
static Trackdir FindFirstTrackdir(TrackdirBits trackdirs)
Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR.