OpenTTD Source
12.0-beta2
|
#include "core/bitmath_func.hpp"
#include "track_type.h"
#include "direction_func.h"
#include "slope_func.h"
Go to the source code of this file.
Typedefs | |
using | SetTrackBitIterator = SetBitIterator< Track, TrackBits > |
Functions | |
static bool | IsValidTrack (Track track) |
Checks if a Track is valid. More... | |
static bool | IsValidTrackdirForRoadVehicle (Trackdir trackdir) |
Checks if a Trackdir is valid for road vehicles. More... | |
static bool | IsValidTrackdir (Trackdir trackdir) |
Checks if a Trackdir is valid for non-road vehicles. More... | |
static Track | AxisToTrack (Axis a) |
Convert an Axis to the corresponding Track AXIS_X -> TRACK_X AXIS_Y -> TRACK_Y Uses the fact that they share the same internal encoding. More... | |
static TrackBits | TrackToTrackBits (Track track) |
Maps a Track to the corresponding TrackBits value. More... | |
static TrackBits | AxisToTrackBits (Axis a) |
Maps an Axis to the corresponding TrackBits value. More... | |
static TrackBits | CornerToTrackBits (Corner corner) |
Returns a single horizontal/vertical trackbit that is in a specific tile corner. More... | |
static TrackdirBits | TrackdirToTrackdirBits (Trackdir trackdir) |
Maps a Trackdir to the corresponding TrackdirBits value. More... | |
static Track | RemoveFirstTrack (TrackBits *tracks) |
Removes first Track from TrackBits and returns it. More... | |
static Trackdir | RemoveFirstTrackdir (TrackdirBits *trackdirs) |
Removes first Trackdir from TrackdirBits and returns it. More... | |
static Track | FindFirstTrack (TrackBits tracks) |
Returns first Track from TrackBits or INVALID_TRACK. More... | |
static Track | TrackBitsToTrack (TrackBits tracks) |
Converts TrackBits to Track. More... | |
static Trackdir | FindFirstTrackdir (TrackdirBits trackdirs) |
Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR. More... | |
static Track | TrackToOppositeTrack (Track t) |
Find the opposite track to a given track. More... | |
static Trackdir | ReverseTrackdir (Trackdir trackdir) |
Maps a trackdir to the reverse trackdir. More... | |
static Track | TrackdirToTrack (Trackdir trackdir) |
Returns the Track that a given Trackdir represents. More... | |
static Trackdir | TrackToTrackdir (Track track) |
Returns a Trackdir for the given Track. More... | |
static TrackdirBits | TrackToTrackdirBits (Track track) |
Returns a TrackdirBit mask from a given Track. More... | |
static TrackBits | TrackdirBitsToTrackBits (TrackdirBits bits) |
Discards all directional information from a TrackdirBits value. More... | |
static TrackdirBits | TrackBitsToTrackdirBits (TrackBits bits) |
Converts TrackBits to TrackdirBits while allowing both directions. More... | |
static bool | HasTrack (TrackBits tracks, Track track) |
Checks whether a TrackBits has a given Track. More... | |
static bool | HasTrackdir (TrackdirBits trackdirs, Trackdir trackdir) |
Checks whether a TrackdirBits has a given Trackdir. More... | |
static TrackdirBits | TrackStatusToTrackdirBits (TrackStatus ts) |
Returns the present-trackdir-information of a TrackStatus. More... | |
static TrackBits | TrackStatusToTrackBits (TrackStatus ts) |
Returns the present-track-information of a TrackStatus. More... | |
static TrackdirBits | TrackStatusToRedSignals (TrackStatus ts) |
Returns the red-signal-information of a TrackStatus. More... | |
static TrackStatus | CombineTrackStatus (TrackdirBits trackdirbits, TrackdirBits red_signals) |
Builds a TrackStatus. More... | |
static Trackdir | NextTrackdir (Trackdir trackdir) |
Maps a trackdir to the trackdir that you will end up on if you go straight ahead. More... | |
static TrackBits | TrackCrossesTracks (Track track) |
Maps a track to all tracks that make 90 deg turns with it. More... | |
static DiagDirection | TrackdirToExitdir (Trackdir trackdir) |
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir. More... | |
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 direction. More... | |
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 direction. More... | |
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 given direction. | |
static Track | DiagDirToDiagTrack (DiagDirection diagdir) |
Maps a (4-way) direction to the diagonal track incidating with that diagdir. More... | |
static TrackBits | DiagDirToDiagTrackBits (DiagDirection diagdir) |
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir. More... | |
static Trackdir | DiagDirToDiagTrackdir (DiagDirection diagdir) |
Maps a (4-way) direction to the diagonal trackdir that runs in that direction. More... | |
static TrackdirBits | DiagdirReachesTrackdirs (DiagDirection diagdir) |
Returns all trackdirs that can be reached when entering a tile from a given (diagonal) direction. More... | |
static TrackBits | DiagdirReachesTracks (DiagDirection diagdir) |
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction. More... | |
static TrackdirBits | TrackdirReachesTrackdirs (Trackdir trackdir) |
Maps a trackdir to the trackdirs that can be reached from it (ie, when entering the next tile. More... | |
static TrackdirBits | TrackdirCrossesTrackdirs (Trackdir trackdir) |
Maps a trackdir to all trackdirs that make 90 deg turns with it. More... | |
static bool | IsDiagonalTrack (Track track) |
Checks if a given Track is diagonal. More... | |
static bool | IsDiagonalTrackdir (Trackdir trackdir) |
Checks if a given Trackdir is diagonal. More... | |
static bool | TracksOverlap (TrackBits bits) |
Checks if the given tracks overlap, ie form a crossing. More... | |
static bool | TrackOverlapsTracks (TrackBits tracks, Track track) |
Check if a given track is contained within or overlaps some other tracks. More... | |
static bool | IsReversingRoadTrackdir (Trackdir dir) |
Checks whether the trackdir means that we are reversing. More... | |
static bool | IsStraightRoadTrackdir (Trackdir dir) |
Checks whether the given trackdir is a straight road. More... | |
static bool | IsUphillTrackdir (Slope slope, Trackdir dir) |
Checks whether a trackdir on a specific slope is going uphill. More... | |
static DiagDirection | VehicleExitDir (Direction direction, TrackBits track) |
Determine the side in which the vehicle will leave the tile. More... | |
Different conversion functions from one kind of track to another.
Definition in file track_func.h.
Convert an Axis to the corresponding Track AXIS_X -> TRACK_X AXIS_Y -> TRACK_Y Uses the fact that they share the same internal encoding.
a | the axis to convert |
Definition at line 65 of file track_func.h.
References IsValidAxis().
Referenced by AxisToTrackBits(), GetCrossingRailTrack(), and GetRailStationTrack().
Maps an Axis to the corresponding TrackBits value.
a | the axis to convert |
Definition at line 87 of file track_func.h.
References AxisToTrack(), and TrackToTrackBits().
Referenced by GetCrossingRailBits(), and GetRailStationTrackBits().
|
inlinestatic |
Builds a TrackStatus.
trackdirbits | present trackdirs |
red_signals | red signals |
Definition at line 387 of file track_func.h.
Returns a single horizontal/vertical trackbit that is in a specific tile corner.
corner | The corner of a tile. |
Definition at line 98 of file track_func.h.
Referenced by GetRailFoundation().
|
inlinestatic |
Returns all trackdirs that can be reached when entering a tile from a given (diagonal) direction.
This will obviously include 90 degree turns, since no information is available about the exact angle of entering
diagdir | The joining direction |
Definition at line 554 of file track_func.h.
References IsValidDiagDirection().
Referenced by DiagdirReachesTracks(), TrainCheckIfLineEnds(), TrainController(), TryPathReserve(), and CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::TryReverse().
|
inlinestatic |
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction.
This will obviously include 90 degree turns, since no information is available about the exact angle of entering
diagdir | The joining direction |
Definition at line 572 of file track_func.h.
References DiagdirReachesTrackdirs(), and TrackdirBitsToTrackBits().
Referenced by PlaceExtraDepotRail(), and TryPathReserve().
|
inlinestatic |
Maps a (4-way) direction to the diagonal track incidating with that diagdir.
diagdir | The direction |
Definition at line 511 of file track_func.h.
References IsValidDiagDirection().
Referenced by CmdConvertRail(), DiagDirToDiagTrackBits(), GetRailDepotTrack(), and Train::ReserveTrackUnderConsist().
|
inlinestatic |
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir.
diagdir | The direction |
Definition at line 523 of file track_func.h.
References DiagDirToDiagTrack(), IsValidDiagDirection(), and TrackToTrackBits().
Referenced by CollectTrackbitsFromCrashedVehiclesEnum(), DeleteLastWagon(), GetRailTrackBitsUniversal(), and GetTunnelBridgeReservationTrackBits().
|
inlinestatic |
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
diagdir | The direction |
Definition at line 536 of file track_func.h.
References IsValidDiagDirection().
Referenced by FollowReservation(), Ship::GetVehicleTrackdir(), Train::GetVehicleTrackdir(), RoadVehicle::GetVehicleTrackdir(), and CYapfCostRoadT< Types >::PfCalcCost().
Returns first Track from TrackBits or INVALID_TRACK.
This function returns the first Track found in the TrackBits value as Track-value. It returns INVALID_TRACK if the parameter is TRACK_BIT_NONE or INVALID_TRACK_BIT.
tracks | The TrackBits value |
Definition at line 176 of file track_func.h.
References FIND_FIRST_BIT, INVALID_TRACK, INVALID_TRACK_BIT, and TRACK_BIT_NONE.
Referenced by ChooseShipTrack(), Ship::GetVehicleTrackdir(), Train::GetVehicleTrackdir(), TrainCheckIfLineEnds(), TrainController(), and YapfTrainChooseTrack().
|
inlinestatic |
Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR.
This function returns the first Trackdir in the given TrackdirBits value or INVALID_TRACKDIR if the value is TRACKDIR_BIT_NONE. The TrackdirBits must not be INVALID_TRACKDIR_BIT.
trackdirs | The TrackdirBits value |
Definition at line 210 of file track_func.h.
References FindFirstBit2x64(), INVALID_TRACKDIR, TRACKDIR_BIT_MASK, and TRACKDIR_BIT_NONE.
Referenced by ExtendTrainReservation(), and FollowReservation().
Checks whether a TrackBits has a given Track.
tracks | The track bits. |
track | The track to check. |
Definition at line 328 of file track_func.h.
References HasBit(), and IsValidTrack().
|
inlinestatic |
Checks whether a TrackdirBits has a given Trackdir.
trackdirs | The trackdir bits. |
trackdir | The trackdir to check. |
Definition at line 339 of file track_func.h.
References HasBit(), and IsValidTrackdir().
Referenced by CYapfCostRailT< Types >::PfCalcCost(), CYapfDestinationTileT< Types >::PfDetectDestination(), CYapfFollowRoadT< Types >::SetOriginFromVehiclePos(), and YapfRoadVehicleFindNearestDepot().
|
inlinestatic |
Checks if a given Track is diagonal.
track | The given track to check |
Definition at line 618 of file track_func.h.
References IsValidTrack(), TRACK_X, and TRACK_Y.
Referenced by ChooseShipTrack(), and IsDiagonalTrackdir().
|
inlinestatic |
Checks if a given Trackdir is diagonal.
trackdir | The given trackdir |
Definition at line 630 of file track_func.h.
References IsDiagonalTrack(), IsValidTrackdir(), and TrackdirToTrack().
Referenced by CYapfCostRoadT< Types >::OneTileCost(), CYapfCostRailT< Types >::OneTileCost(), CYapfCostShipT< Types >::PfCalcCost(), and CYapfCostBase::stSlopeCost().
|
inlinestatic |
Checks whether the trackdir means that we are reversing.
dir | the trackdir to check |
Definition at line 672 of file track_func.h.
References IsValidTrackdirForRoadVehicle().
Referenced by RoadVehicle::GetVehicleTrackdir(), and RoadVehicle::HasToUseGetSlopePixelZ().
|
inlinestatic |
Checks whether the given trackdir is a straight road.
dir | the trackdir to check |
Definition at line 683 of file track_func.h.
References IsValidTrackdirForRoadVehicle().
Checks whether a trackdir on a specific slope is going uphill.
Valid for rail and road tracks. Valid for tile-slopes (under foundation) and foundation-slopes (on foundation).
slope | The slope of the tile. |
dir | The trackdir of interest. |
Definition at line 699 of file track_func.h.
References IsValidTrackdirForRoadVehicle().
Referenced by CYapfCostBase::stSlopeCost().
|
inlinestatic |
Checks if a Track is valid.
track | The value to check |
Definition at line 27 of file track_func.h.
References TRACK_END.
Referenced by HasSignalOnTrack(), HasTrack(), IsDiagonalTrack(), TrackCrossesTracks(), TrackDirectionToTrackdir(), TrackEnterdirToTrackdir(), TrackExitdirToTrackdir(), TrackToOppositeTrack(), TrackToTrackBits(), and TrackToTrackdir().
|
inlinestatic |
Checks if a Trackdir is valid for non-road vehicles.
trackdir | The value to check |
Definition at line 51 of file track_func.h.
References INVALID_TRACKDIR, TRACKDIR_BIT_MASK, and TRACKDIR_BIT_NONE.
Referenced by GetSignalStateByTrackdir(), HasSignalOnTrackdir(), HasTrackdir(), IsDiagonalTrackdir(), NextTrackdir(), TrackdirReachesTrackdirs(), TrackdirToTrack(), and TrackdirToTrackdirBits().
|
inlinestatic |
Checks if a Trackdir is valid for road vehicles.
trackdir | The value to check |
Definition at line 39 of file track_func.h.
References TRACKDIR_END.
Referenced by IsReversingRoadTrackdir(), IsStraightRoadTrackdir(), IsUphillTrackdir(), ReverseTrackdir(), TrackdirCrossesTrackdirs(), and TrackdirToExitdir().
Maps a trackdir to the trackdir that you will end up on if you go straight ahead.
This will be the same trackdir for diagonal trackdirs, but a different (alternating) one for straight trackdirs
trackdir | The given trackdir |
Definition at line 402 of file track_func.h.
References IsValidTrackdir().
Removes first Track from TrackBits and returns it.
This function searches for the first bit in the TrackBits, remove this bit from the parameter and returns the found bit as Track value. It returns INVALID_TRACK if the parameter was TRACK_BIT_NONE or INVALID_TRACK_BIT. This is basically used in while-loops to get up to 6 possible tracks on a tile until the parameter becomes TRACK_BIT_NONE.
tracks | The value with the TrackBits |
Definition at line 130 of file track_func.h.
References ClrBit(), FIND_FIRST_BIT, INVALID_TRACK, INVALID_TRACK_BIT, TRACK_BIT_MASK, and TRACK_BIT_NONE.
Referenced by CmdConvertRail(), and SetTrackReservation().
|
inlinestatic |
Removes first Trackdir from TrackdirBits and returns it.
This function searches for the first bit in the TrackdirBits parameter, remove this bit from the parameter and returns the fnound bit as Trackdir value. It returns INVALID_TRACKDIR if the trackdirs is TRACKDIR_BIT_NONE or INVALID_TRACKDIR_BIT. This is basically used in a while-loop to get all track-directions step by step until the value reaches TRACKDIR_BIT_NONE.
trackdirs | The value with the TrackdirBits |
Definition at line 155 of file track_func.h.
References ClrBit(), FindFirstBit2x64(), INVALID_TRACKDIR, INVALID_TRACKDIR_BIT, TRACKDIR_BIT_MASK, and TRACKDIR_BIT_NONE.
Maps a trackdir to the reverse trackdir.
Returns the reverse trackdir of a Trackdir value. The reverse trackdir is the same track with the other direction on it.
trackdir | The Trackdir value |
Definition at line 246 of file track_func.h.
References IsValidTrackdirForRoadVehicle().
Referenced by FollowTrainReservation(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::ForcedReverse(), FreeTrainReservation(), GetTrainForReservation(), HasOnewaySignalBlockingTrackdir(), CYapfCostRailT< Types >::IsAnyStationTileReserved(), NPFTrainFindNearestDepot(), CYapfReserveTrack< Types >::ReserveSingleTrack(), RestoreTrainReservation(), TrackToTrackdirBits(), CYapfReserveTrack< Types >::UnreserveSingleTrack(), YapfShipCheckReverse(), YapfTrainCheckReverse(), and YapfTrainFindNearestDepot().
Converts TrackBits to Track.
This function converts a TrackBits value to a Track value. As it is not possible to convert two or more tracks to one track the parameter must contain only one track or be the INVALID_TRACK_BIT value.
tracks | The TrackBits value to convert |
Definition at line 192 of file track_func.h.
References FIND_FIRST_BIT, INVALID_TRACK, INVALID_TRACK_BIT, KillFirstBit(), TRACK_BIT_MASK, and TRACK_BIT_NONE.
Referenced by ChooseShipTrack(), DeleteLastWagon(), and Train::ReserveTrackUnderConsist().
|
inlinestatic |
Converts TrackBits to TrackdirBits while allowing both directions.
bits | The TrackBits |
Definition at line 318 of file track_func.h.
Referenced by FollowReservation().
Maps a track to all tracks that make 90 deg turns with it.
For the diagonal directions these are the complement of the direction, for the straight directions these are the two vertical or horizontal tracks, depend on the given direction
track | The given track |
Definition at line 419 of file track_func.h.
References IsValidTrack().
Referenced by TrainCheckIfLineEnds(), TrainController(), and TryPathReserve().
|
inlinestatic |
Discards all directional information from a TrackdirBits value.
Any Track which is present in either direction will be present in the result.
bits | The TrackdirBits to get the TrackBits from |
Definition at line 307 of file track_func.h.
References TRACK_BIT_MASK.
Referenced by DiagdirReachesTracks(), ExtendTrainReservation(), TrackStatusToTrackBits(), TrainCheckIfLineEnds(), TrainController(), and TryPathReserve().
|
inlinestatic |
Maps a trackdir to all trackdirs that make 90 deg turns with it.
For the diagonal tracks this returns the track direction bits of the other axis in both directions, which cannot be joined by the given track direction. For the straight tracks this returns all possible 90 deg turns either on the current tile (which no train can joined) or on the bordering tiles.
trackdir | The track direction |
Definition at line 605 of file track_func.h.
References IsValidTrackdirForRoadVehicle().
Referenced by ExtendTrainReservation().
|
inlinestatic |
Maps a trackdir to the trackdirs that can be reached from it (ie, when entering the next tile.
This will include 90 degree turns!
trackdir | The track direction which will be leaved |
Definition at line 583 of file track_func.h.
References IsValidTrackdir().
Referenced by ExtendTrainReservation().
|
inlinestatic |
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
For the diagonal directions these are the same directions. For the straight directions these are the directions from the imagined base-tile to the bordering tile which will be joined if the given straight direction is leaved from the base-tile.
trackdir | The given track direction |
Definition at line 438 of file track_func.h.
References IsValidTrackdirForRoadVehicle().
Referenced by ClearPathReservation(), FollowTrainReservation(), FreeTrainReservation(), GetTrainForReservation(), CYapfCostRailT< Types >::IsAnyStationTileReserved(), NPFSaveTargetData(), CYapfCostRoadT< Types >::OneTileCost(), CYapfDestinationTileWaterT< Types >::PfCalcEstimate(), CYapfDestinationTileT< Types >::PfCalcEstimate(), CYapfDestinationTileOrStationRailT< Types >::PfCalcEstimate(), CYapfDestinationTileRoadT< Types >::PfCalcEstimate(), CYapfReserveTrack< Types >::ReserveSingleTrack(), RestoreTrainReservation(), CYapfCostBase::stSlopeCost(), TryPathReserve(), CYapfReserveTrack< Types >::UnreserveSingleTrack(), and YapfTrainCheckReverse().
Returns the Track that a given Trackdir represents.
This function filters the Track which is used in the Trackdir value and returns it as a Track value.
trackdir | The trackdir value |
Definition at line 261 of file track_func.h.
References IsValidTrackdir().
Referenced by ChooseShipTrack(), ClearPathReservation(), ExtendTrainReservation(), FindTrainOnTrackEnum(), FollowReservation(), GetSignalStateByTrackdir(), HasOnewaySignalBlockingTrackdir(), IsDiagonalTrackdir(), IsWaitingPositionFree(), NPFSaveTargetData(), CYapfReserveTrack< Types >::ReserveSingleTrack(), TryPathReserve(), CYapfReserveTrack< Types >::UnreserveSingleTrack(), and YapfTrainChooseTrack().
|
inlinestatic |
Maps a Trackdir to the corresponding TrackdirBits value.
trackdir | the track direction to convert |
Definition at line 110 of file track_func.h.
References IsValidTrackdir().
Referenced by CYapfFollowShipT< Types >::CheckShipReverse(), CYapfFollowRoadT< Types >::FindNearestDepot(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::ForcedReverse(), and TrackToTrackdirBits().
|
inlinestatic |
Maps a track and an (4-way) dir to the trackdir that represents the track with the entry in the given direction.
For the diagonal tracks the return value is clear, its either the matching track direction or INVALID_TRACKDIR. For the straight tracks this returns the track direction which results if you follow the DiagDirection and then turn by 45 deg left or right on the next tile. The new direction on the new track will be the returning Trackdir value. If the parameters makes no sense like the track TRACK_UPPER and the direction DIAGDIR_NE (target track cannot be reached) this function returns INVALID_TRACKDIR.
track | The target track |
diagdir | The direction to "come from" |
Definition at line 485 of file track_func.h.
References IsValidDiagDirection(), and IsValidTrack().
|
inlinestatic |
Maps a track and an (4-way) dir to the trackdir that represents the track with the exit in the given direction.
For the diagonal tracks the resulting track direction are clear for a given DiagDirection. It either matches the direction or it returns INVALID_TRACKDIR, as a TRACK_X cannot be applied with DIAG_SE. For the straight tracks the resulting track direction will be the direction which the DiagDirection is pointing. But this will be INVALID_TRACKDIR if the DiagDirection is pointing 'away' the track.
track | The track to apply an direction on |
diagdir | The DiagDirection to apply on |
Definition at line 460 of file track_func.h.
References IsValidDiagDirection(), and IsValidTrack().
Check if a given track is contained within or overlaps some other tracks.
tracks | Tracks to be tested against |
track | The track to test |
Definition at line 661 of file track_func.h.
References HasBit(), TracksOverlap(), and TrackToTrackBits().
Referenced by IsWaitingPositionFree().
|
inlinestatic |
Checks if the given tracks overlap, ie form a crossing.
Basically this means when there is more than one track on the tile, except when there are two parallel tracks.
bits | The tracks present. |
Definition at line 644 of file track_func.h.
References KillFirstBit(), TRACK_BIT_HORZ, TRACK_BIT_NONE, and TRACK_BIT_VERT.
Referenced by AfterLoadCompanyStats(), CmdConvertRail(), GetRailFoundation(), SetTrackReservation(), TrackOverlapsTracks(), and TryReserveTrack().
|
inlinestatic |
Returns the red-signal-information of a TrackStatus.
Note: The result may contain red signals for non-present tracks.
ts | The TrackStatus returned by GetTileTrackStatus() |
Definition at line 375 of file track_func.h.
References TRACKDIR_BIT_MASK.
Referenced by TrainCheckIfLineEnds(), and TrainController().
|
inlinestatic |
Returns the present-track-information of a TrackStatus.
ts | The TrackStatus returned by GetTileTrackStatus() |
Definition at line 362 of file track_func.h.
References TrackdirBitsToTrackBits(), and TrackStatusToTrackdirBits().
Referenced by DisasterTick_Submarine(), GenericPlaceSignals(), TryReserveRailTrack(), UnreserveRailTrack(), and UpdateSignalsInBuffer().
|
inlinestatic |
Returns the present-trackdir-information of a TrackStatus.
ts | The TrackStatus returned by GetTileTrackStatus() |
Definition at line 351 of file track_func.h.
References TRACKDIR_BIT_MASK.
Referenced by CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GetDriveableTrackdirBits(), GetTrackdirBitsForRoad(), TrackStatusToTrackBits(), TrainCheckIfLineEnds(), TrainController(), and TryPathReserve().
Find the opposite track to a given track.
TRACK_LOWER -> TRACK_UPPER and vice versa, likewise for left/right. TRACK_X is mapped to TRACK_Y and reversed.
t | the track to convert |
Definition at line 230 of file track_func.h.
References IsValidTrack().
Referenced by ChooseShipTrack(), and GetRailReservationTrackBits().
Maps a Track to the corresponding TrackBits value.
track | the track to convert |
Definition at line 76 of file track_func.h.
References IsValidTrack().
Referenced by AdvanceWagonsAfterSwap(), AxisToTrackBits(), DiagDirToDiagTrackBits(), EnsureNoTrainOnTrack(), FollowReservation(), GetDepotReservationTrackBits(), GetRailReservationTrackBits(), GetRailTrackBitsUniversal(), GetTrainForReservation(), TrackOverlapsTracks(), TryReserveTrack(), and UnreserveTrack().
Returns a Trackdir for the given Track.
Since every Track corresponds to two Trackdirs, we choose the one which points between NE and S. Note that the actual implementation is quite futile, but this might change in the future.
track | The given Track |
Definition at line 278 of file track_func.h.
References IsValidTrack().
Referenced by GetTrainForReservation(), and TrackToTrackdirBits().
|
inlinestatic |
Returns a TrackdirBit mask from a given Track.
The TrackdirBit mask contains the two TrackdirBits that correspond with the given Track (one for each direction).
track | The track to get the TrackdirBits from |
Definition at line 293 of file track_func.h.
References ReverseTrackdir(), TrackdirToTrackdirBits(), and TrackToTrackdir().
|
inlinestatic |
Determine the side in which the vehicle will leave the tile.
direction | vehicle direction |
track | vehicle track bits |
Definition at line 713 of file track_func.h.
References ChangeDiagDir(), DIAGDIR_END, DIAGDIRDIFF_90LEFT, DirToDiagDir(), HasBit(), TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_RIGHT, and TRACK_BIT_UPPER.
Referenced by TrainApproachingCrossingTile(), and TrainCheckIfLineEnds().