161 ClrBit(*trackdirs, first);
234 return (
Track)(t ^ 1);
265 return (
Track)(trackdir & 0x7);
333 return HasBit(tracks, track);
345 return HasBit(trackdirs, trackdir);
622 if (
HasBit(tracks, track))
return true;
634 return (dir & 0x07) >= 6;
645 return (dir & 0x06) == 0;
Functions related to bit mathematics.
constexpr uint8_t FindFirstBit(T x)
Search the first set bit in a value.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
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.
bool IsDiagonalDirection(Direction dir)
Checks if a given Direction is diagonal.
DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
EnumIndexArray< T, DiagDirection, DiagDirection::End > DiagDirectionIndexArray
Array with DiagDirection as index.
Direction
Defines the 8 directions on the map.
Axis
Enumeration for the two axis X and Y.
DiagDirection
Enumeration for diagonal directions.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
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.
Corner
Enumeration of tile corners.
Slope
Enumeration for the slope-type.
EnumIndexArray< T, Corner, CORNER_END > CornerIndexArray
Array with Corner as index.
Iterable ensemble of each set bit in a value.
const TrackIndexArray< DiagDirectionIndexArray< Trackdir > > _track_enterdir_to_trackdir
Maps a track and an (4-way) dir to the trackdir that represents the track with the entry in the given...
const TrackIndexArray< TrackdirBits > _track_crosses_trackdirs
Maps a trackdir to all trackdirs that make 90 deg turns with it.
const DiagDirectionIndexArray< TrackdirBits > _exitdir_reaches_trackdirs
Maps a diagonal direction to the all trackdirs that are connected to any track entering in this direc...
const CornerIndexArray< TrackBits > _corner_to_trackbits
Maps a single horizontal/vertical trackbit that is in a specific tile corner.
const TrackdirIndexArray< DiagDirection > _trackdir_to_exitdir
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
const TrackdirIndexArray< Trackdir > _next_trackdir
Next trackdir to use when moving to a new tile for each current trackdir.
const DiagDirectionIndexArray< Trackdir > _dir_to_diag_trackdir
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
const TrackIndexArray< DirectionIndexArray< Trackdir > > _track_direction_to_trackdir
Maps a track and a full (8-way) direction to the trackdir that represents the track running in the gi...
const TrackIndexArray< TrackBits > _track_crosses_tracks
Maps a track to all tracks that make 90 deg turns with it.
const TrackIndexArray< DiagDirectionIndexArray< Trackdir > > _track_exitdir_to_trackdir
Maps a track and an (4-way) dir to the trackdir that represents the track with the exit in the given ...
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.
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.
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 DiagDirection to the associated diagonal TrackBits.
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.
Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track Axis::X -> TRACK_X Axis::Y -> TRACK_Y Uses the fact that t...
Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
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 DiagDirection to the associated diagonal Track.
TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
Discards all directional information from a TrackdirBits value.
All types related to tracks.
TrackBits
Bitfield corresponding to Track.
@ TRACK_BIT_UPPER
Upper track.
@ TRACK_BIT_LEFT
Left track.
@ 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.
EnumIndexArray< T, Trackdir, TRACKDIR_END > TrackdirIndexArray
Allow incrementing of Trackdir variables.
EnumIndexArray< T, Track, TRACK_END > TrackIndexArray
Allow incrementing of Track variables.
Trackdir
Enumeration for tracks and directions.
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
@ TRACKDIR_END
Used for iterations.
TrackdirBits
Enumeration of bitmasks for the TrackDirs.
@ 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).