Different functions related to conversions between directions. More...
#include "direction_type.h"
Go to the source code of this file.
Functions | |
static Direction | ReverseDir (Direction d) |
Return the reverse of a direction. | |
static DirDiff | DirDifference (Direction d0, Direction d1) |
Calculate the difference between to directions. | |
static DirDiff | ChangeDirDiff (DirDiff d, DirDiff delta) |
Applies two differences together. | |
static Direction | ChangeDir (Direction d, DirDiff delta) |
Change a direction by a given difference. | |
static DiagDirection | ReverseDiagDir (DiagDirection d) |
Returns the reverse direction of the given DiagDirection. | |
static DiagDirection | ChangeDiagDir (DiagDirection d, DiagDirDiff delta) |
Applies a difference on a DiagDirection. | |
static DiagDirection | DirToDiagDir (Direction dir) |
Convert a Direction to a DiagDirection. | |
static Direction | DiagDirToDir (DiagDirection dir) |
Convert a DiagDirection to a Direction. | |
static Axis | OtherAxis (Axis a) |
Select the other axis as provided. | |
static Axis | DiagDirToAxis (DiagDirection d) |
Convert a DiagDirection to the axis. | |
static DiagDirection | AxisToDiagDir (Axis a) |
Converts an Axis to a DiagDirection. | |
static Direction | AxisToDirection (Axis a) |
Converts an Axis to a Direction. | |
static DiagDirection | XYNSToDiagDir (Axis xy, uint ns) |
Convert an axis and a flag for north/south into a DiagDirection. | |
static bool | IsValidDiagDirection (DiagDirection d) |
Checks if an interger value is a valid DiagDirection. | |
static bool | IsValidDirection (Direction d) |
Checks if an integer value is a valid Direction. | |
static bool | IsValidAxis (Axis d) |
Checks if an integer value is a valid Axis. | |
static bool | IsDiagonalDirection (Direction dir) |
Checks if a given Direction is diagonal. |
Different functions related to conversions between directions.
Definition in file direction_func.h.
static DiagDirection AxisToDiagDir | ( | Axis | a | ) | [inline, static] |
Converts an Axis to a DiagDirection.
This function returns the DiagDirection which belongs to the axis. As 2 directions are mapped to an axis this function returns the one which points to south, either south-west (on X axis) or south-east (on Y axis)
a | The axis |
Definition at line 177 of file direction_func.h.
Referenced by CmdBuildBridge(), CmdBuildLongRoad(), CmdBuildRailWaypoint(), DrawBridgePillars(), GetNorthernBridgeEnd(), GetSouthernBridgeEnd(), and TrainApproachingCrossing().
Converts an Axis to a Direction.
This function returns the Direction which belongs to the axis. As 2 directions are mapped to an axis this function returns the one which points to south, either south-west (on X axis) or south-east (on Y axis)
a | The axis |
Definition at line 193 of file direction_func.h.
Referenced by AfterLoadGame().
static DiagDirection ChangeDiagDir | ( | DiagDirection | d, | |
DiagDirDiff | delta | |||
) | [inline, static] |
Applies a difference on a DiagDirection.
This function applies a difference on a DiagDirection and returns the new DiagDirection.
d | The DiagDirection | |
delta | The difference to applie on |
Definition at line 99 of file direction_func.h.
Referenced by AircraftGetEntryPoint(), GrowTownInTile(), IsNeighborRoadTile(), and TrainExitDir().
Change a direction by a given difference.
This functions returns a new direction of the given direction which is rotated by the given difference.
d | The direction to get a new direction from | |
delta | The offset/drift applied to the direction |
Definition at line 70 of file direction_func.h.
Referenced by AircraftController(), ChangeTrainDirRandomly(), DisasterTick_Submarine(), Airport::GetHangarExitDirection(), HandleCrashedAircraft(), and RotateAirportMovingData().
Applies two differences together.
This function adds two differences together and return the resulting difference. So adding two DIRDIFF_REVERSE together results in the DIRDIFF_SAME difference.
d | The first difference | |
delta | The second difference to add on |
Definition at line 54 of file direction_func.h.
static Axis DiagDirToAxis | ( | DiagDirection | d | ) | [inline, static] |
Convert a DiagDirection to the axis.
This function returns the axis which belongs to the given DiagDirection. The axis X belongs to the DiagDirection north-east and south-west.
d | The DiagDirection |
Definition at line 160 of file direction_func.h.
Referenced by AfterLoadGame(), CanEnterTileOwnerCheck(), CheckFlatLandRoadStop(), CleanUpRoadBits(), CmdBuildBridge(), CmdBuildRoad(), CmdBuildRoadStop(), CmdBuildTunnel(), DrawCatenaryRailway(), DrawTile_TunnelBridge(), ExploreSegment(), GetAnyRoadBits(), GetBridgeHeight(), IsRoadAllowedHere(), IsWateredTile(), MakeDock(), PlaceRoad_BusStation(), PlaceRoad_TruckStation(), RemoveRoad(), RoadFindPathToDest(), SetRailStationPlatformReservation(), CYapfCostBase::stSlopeCost(), TrainApproachingCrossingTile(), GroundVehicle< RoadVehicle, VEH_ROAD >::UpdateZPosition(), and VehicleEnter_Track().
static Direction DiagDirToDir | ( | DiagDirection | dir | ) | [inline, static] |
Convert a DiagDirection to a Direction.
This function can be used to convert the 4-way DiagDirection to the 8-way Direction. As 4-way are less than 8-way not all possible directions can be calculated.
dir | The direction to convert |
Definition at line 130 of file direction_func.h.
Referenced by AfterLoadGame(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), TrainCanLeaveTile(), and VehicleEnter_Track().
Calculate the difference between to directions.
d0 | The first direction as the base | |
d1 | The second direction as the offset from the base |
Definition at line 36 of file direction_func.h.
Referenced by AircraftController(), Train::GetCurveSpeedLimit(), Airport::GetHangarExitDirection(), and TrainController().
static DiagDirection DirToDiagDir | ( | Direction | dir | ) | [inline, static] |
Convert a Direction to a DiagDirection.
This function can be used to convert the 8-way Direction to the 4-way DiagDirection. If the direction cannot be mapped its "rounded clockwise". So DIR_N becomes DIAGDIR_NE.
dir | The direction to convert |
Definition at line 115 of file direction_func.h.
Referenced by AfterLoadGame(), AircraftGetEntryPoint(), CmdTurnRoadVeh(), DisasterTick_Submarine(), RoadStop::Enter(), FindVehiclesInRoadStop(), GetTrainStopLocation(), Train::GetVehicleTrackdir(), Ship::GetVehicleTrackdir(), RoadVehicle::GetVehicleTrackdir(), IsWateredTile(), RoadStop::Leave(), TrainExitDir(), and GroundVehicle< RoadVehicle, VEH_ROAD >::UpdateZPosition().
static bool IsDiagonalDirection | ( | Direction | dir | ) | [inline, static] |
Checks if a given Direction is diagonal.
dir | The given direction. |
Definition at line 248 of file direction_func.h.
Referenced by TrainApproachingLineEnd(), Train::UpdateDeltaXY(), and RoadVehicle::UpdateDeltaXY().
static bool IsValidAxis | ( | Axis | d | ) | [inline, static] |
Checks if an integer value is a valid Axis.
d | The value to check |
Definition at line 237 of file direction_func.h.
Referenced by CmdBuildRoadStop(), and PlaceRail_Waypoint().
static bool IsValidDiagDirection | ( | DiagDirection | d | ) | [inline, static] |
Checks if an interger value is a valid DiagDirection.
d | The value to check |
Definition at line 215 of file direction_func.h.
Referenced by ChooseShipTrack(), CmdBuildRoadStop(), GetOtherAqueductEnd(), BuildDocksToolbarWindow::OnPlacePresize(), OPFShipChooseTrack(), TileIndexDiffCByDiagDir(), TileOffsByDiagDir(), and TrainController().
static bool IsValidDirection | ( | Direction | d | ) | [inline, static] |
Checks if an integer value is a valid Direction.
d | The value to check |
Definition at line 226 of file direction_func.h.
Referenced by TileIndexDiffCByDir(), and TileOffsByDir().
Select the other axis as provided.
This is basically the not-operator for the axis.
a | The given axis |
Definition at line 144 of file direction_func.h.
Referenced by CmdBuildRailWaypoint(), CmdBuildRoad(), DrawBridgePillars(), and GetCrossingRailAxis().
static DiagDirection ReverseDiagDir | ( | DiagDirection | d | ) | [inline, static] |
Returns the reverse direction of the given DiagDirection.
d | The DiagDirection to get the reverse from |
Definition at line 83 of file direction_func.h.
Referenced by AfterLoadGame(), AircraftGetEntryPoint(), CanEnterTile(), CcBuildBridge(), CcBuildRoadTunnel(), CcRoadStop(), CheckTownBuild2House(), CheckTownBuild2x2House(), ClearPathReservation(), CmdBuildBridge(), CmdBuildDock(), CmdBuildLongRoad(), CmdBuildTunnel(), ConnectRoadToStructure(), DoClearBridge(), DoClearTunnel(), DrawBridgePillars(), DrawCatenaryRailway(), ExploreSegment(), FixOwnerOfRailTrack(), GetAnyRoadBits(), GetBridgeEnd(), GetNorthernBridgeEnd(), GetOtherAqueductEnd(), GetOtherTunnelEnd(), GetTownRoadGridElement(), GrowTownAtRoad(), GrowTownInTile(), GrowTownWithBridge(), IsNeighborRoadTile(), IsWateredTile(), MaskWireBits(), BuildDocksToolbarWindow::OnPlaceObject(), BuildDocksToolbarWindow::OnPlacePresize(), OPFShipChooseTrack(), CYapfCostRailT< Types >::PfCalcCost(), RoadStop::Entry::Rebuild(), TrainApproachingCrossing(), TrainCanLeaveTile(), TrainCheckIfLineEnds(), TrainController(), UpdateSignalsInBuffer(), and VehicleEnter_Track().
Return the reverse of a direction.
d | The direction to get the reverse from |
Definition at line 23 of file direction_func.h.
Referenced by AfterLoadGame(), DrawCatenaryOnBridge(), Train::GetImage(), TileLoop_Water(), UpdateStatusAfterSwap(), and VehicleEnter_Track().
static DiagDirection XYNSToDiagDir | ( | Axis | xy, | |
uint | ns | |||
) | [inline, static] |
Convert an axis and a flag for north/south into a DiagDirection.
xy | axis to convert | |
ns | north -> 0, south -> 1 |
Definition at line 204 of file direction_func.h.
Referenced by AfterLoadGame(), and GetShipDepotDirection().