OpenTTD Source
20240915-master-g3784a3d3d6
|
Go to the documentation of this file.
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]) {
TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction.
Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
bool IsUphillTrackdir(Slope slope, Trackdir dir)
Checks whether a trackdir on a specific slope is going uphill.
TrackdirBits TrackStatusToTrackdirBits(TrackStatus ts)
Returns the present-trackdir-information of a TrackStatus.
Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.
DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
static constexpr Slope RemoveHalftileSlope(Slope s)
Removes a halftile slope from a slope.
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 ...
bool IsValidTrackdirForRoadVehicle(Trackdir trackdir)
Checks if a Trackdir is valid for road vehicles.
TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir)
Maps a Trackdir to the corresponding TrackdirBits value.
@ TRACK_BIT_HORZ
Upper and lower track.
@ DIR_END
Used to iterate.
Trackdir FindFirstTrackdir(TrackdirBits trackdirs)
Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR.
bool TrackOverlapsTracks(TrackBits tracks, Track track)
Check if a given track is contained within or overlaps some other tracks.
@ DIAGDIRDIFF_90LEFT
90 degrees left
@ TRACK_BIT_VERT
Left and right track.
DiagDirection
Enumeration for diagonal directions.
bool IsValidTrack(Track track)
Checks if a Track is valid.
Trackdir NextTrackdir(Trackdir trackdir)
Maps a trackdir to the trackdir that you will end up on if you go straight ahead.
constexpr T KillFirstBit(T value)
Clear the first bit in an integer.
@ TRACK_END
Used for iterations.
@ TRACK_BIT_MASK
Bitmask for the first 6 bits.
TrackdirBits TrackStatusToRedSignals(TrackStatus ts)
Returns the red-signal-information of a TrackStatus.
TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
bool TracksOverlap(TrackBits bits)
Checks if the given tracks overlap, ie form a crossing.
TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir.
@ TRACK_BIT_NONE
No track.
Trackdir TrackToTrackdir(Track track)
Returns a Trackdir for the given Track.
TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
Iterable ensemble of each set bit in a value.
Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
TrackdirBits TrackToTrackdirBits(Track track)
Returns a TrackdirBit mask from a given Track.
DiagDirection ChangeDiagDir(DiagDirection d, DiagDirDiff delta)
Applies a difference on a DiagDirection.
Track TrackBitsToTrack(TrackBits tracks)
Converts TrackBits to Track.
bool IsStraightRoadTrackdir(Trackdir dir)
Checks whether the given trackdir is a straight road.
TrackBits
Allow incrementing of Track variables.
bool IsValidDirection(Direction d)
Checks if an integer value is a valid Direction.
TrackBits TrackCrossesTracks(Track track)
Maps a track to all tracks that make 90 deg turns with it.
@ TRACKDIR_BIT_NONE
No track build.
static constexpr bool IsValidCorner(Corner corner)
Rangecheck for Corner enumeration.
Corner
Enumeration of tile corners.
@ TRACK_BIT_LEFT
Left track.
TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir)
Maps a trackdir to the trackdirs that can be reached from it (ie, when entering the next tile.
Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir)
Returns all trackdirs that can be reached when entering a tile from a given (diagonal) direction.
TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
Discards all directional information from a TrackdirBits value.
DiagDirection VehicleExitDir(Direction direction, TrackBits track)
Determine the side in which the vehicle will leave the tile.
Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs)
Removes first Trackdir from TrackdirBits and returns it.
DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
Builds a TrackStatus.
TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
bool HasTrack(TrackBits tracks, Track track)
Checks whether a TrackBits has a given Track.
@ TRACK_BIT_UPPER
Upper track.
bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
Track
These are used to specify a single track.
@ TRACKDIR_BIT_MASK
Bitmask for bit-operations.
bool IsDiagonalTrack(Track track)
Checks if a given Track is diagonal.
@ TRACK_BIT_RIGHT
Right track.
Trackdir
Enumeration for tracks and directions.
Slope
Enumeration for the slope-type.
Axis
Allow incrementing of DiagDirDiff variables.
@ DIAGDIR_END
Used for iterations.
Direction
Defines the 8 directions on the map.
@ TRACKDIR_END
Used for iterations.
Track DiagDirToDiagTrack(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track incidating with that diagdir.
bool IsReversingRoadTrackdir(Trackdir dir)
Checks whether the trackdir means that we are reversing.
bool IsDiagonalTrackdir(Trackdir trackdir)
Checks if a given Trackdir is diagonal.
Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track AXIS_X -> TRACK_X AXIS_Y -> TRACK_Y Uses the fact that the...
@ INVALID_TRACK_BIT
Flag for an invalid trackbits value.
@ TRACK_BIT_LOWER
Lower track.
TrackBits AxisToTrackBits(Axis a)
Maps an Axis to the corresponding TrackBits value.
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...
TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
Maps a trackdir to all trackdirs that make 90 deg turns with it.
TrackdirBits
Allow incrementing of Trackdir variables.
@ TRACK_Y
Track along the y-axis (north-west to south-east)
bool HasTrackdir(TrackdirBits trackdirs, Trackdir trackdir)
Checks whether a TrackdirBits has a given Trackdir.
bool IsValidTrackdir(Trackdir trackdir)
Checks if a Trackdir is valid for non-road vehicles.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
@ INVALID_TRACK
Flag for an invalid track.
Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
@ TRACK_X
Track along the x-axis (north-east to south-west)
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...
TrackBits CornerToTrackBits(Corner corner)
Returns a single horizontal/vertical trackbit that is in a specific tile corner.
@ INVALID_TRACKDIR_BIT
Flag for an invalid trackdirbit value.
Track TrackToOppositeTrack(Track t)
Find the opposite track to a given track.
constexpr uint8_t FindFirstBit(T x)
Search the first set bit in a value.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.