OpenTTD Source: src/rail_map.h File Reference

OpenTTD Source 15.0-beta1

Enumerations | Functions
rail_map.h File Reference

Hides the direct accesses to the map array with map accessors. More...

`#include "rail_type.h"`
`#include "depot_type.h"`
`#include "signal_func.h"`
`#include "track_func.h"`
`#include "tile_map.h"`
`#include "water_map.h"`
`#include "signal_type.h"`

Go to the source code of this file.

## Enumerations
enum | RailTileType { RAIL_TILE_NORMAL = 0 , RAIL_TILE_SIGNALS = 1 , RAIL_TILE_DEPOT = 3 }
| Different types of Rail-related tiles. More...
enum | RailGroundType { RAIL_GROUND_BARREN = 0 , RAIL_GROUND_GRASS = 1 , RAIL_GROUND_FENCE_NW = 2 , RAIL_GROUND_FENCE_SE = 3 , RAIL_GROUND_FENCE_SENW = 4 , RAIL_GROUND_FENCE_NE = 5 , RAIL_GROUND_FENCE_SW = 6 , RAIL_GROUND_FENCE_NESW = 7 , RAIL_GROUND_FENCE_VERT1 = 8 , RAIL_GROUND_FENCE_VERT2 = 9 , RAIL_GROUND_FENCE_HORIZ1 = 10 , RAIL_GROUND_FENCE_HORIZ2 = 11 , RAIL_GROUND_ICE_DESERT = 12 , RAIL_GROUND_WATER = 13 , RAIL_GROUND_HALF_SNOW = 14 }
| The ground 'under' the rail. More...

## Functions
static debug_inline RailTileType | GetRailTileType (Tile t)
| Returns the RailTileType (normal with or without signals, waypoint or depot).
static debug_inline bool | IsPlainRail (Tile t)
| Returns whether this is plain rails, with or without signals.
static debug_inline bool | IsPlainRailTile (Tile t)
| Checks whether the tile is a rail tile or rail tile with signals.
bool | HasSignals (Tile t)
| Checks if a rail tile has signals.
void | SetHasSignals (Tile tile, bool signals)
| Add/remove the 'has signal' bit from the RailTileType.
static debug_inline bool | IsRailDepot (Tile t)
| Is this rail tile a rail depot?
static debug_inline bool | IsRailDepotTile (Tile t)
| Is this tile rail tile and a rail depot?
RailType | GetRailType (Tile t)
| Gets the rail type of the given tile.
void | SetRailType (Tile t, RailType r)
| Sets the rail type of the given tile.
TrackBits | GetTrackBits (Tile tile)
| Gets the track bits of the given tile.
void | SetTrackBits (Tile t, TrackBits b)
| Sets the track bits of the given tile.
bool | HasTrack (Tile tile, Track track)
| Returns whether the given track is present on the given tile.
DiagDirection | GetRailDepotDirection (Tile t)
| Returns the direction the depot is facing to.
Track | GetRailDepotTrack (Tile t)
| Returns the track of a depot, ignoring direction.
TrackBits | GetRailReservationTrackBits (Tile t)
| Returns the reserved track bits of the tile.
void | SetTrackReservation (Tile t, TrackBits b)
| Sets the reserved track bits of the tile.
bool | TryReserveTrack (Tile tile, Track t)
| Try to reserve a specific track on a tile.
void | UnreserveTrack (Tile tile, Track t)
| Lift the reservation of a specific track on a tile.
bool | HasDepotReservation (Tile t)
| Get the reservation state of the depot.
void | SetDepotReservation (Tile t, bool b)
| Set the reservation state of the depot.
TrackBits | GetDepotReservationTrackBits (Tile t)
| Get the reserved track bits for a depot.
bool | IsPbsSignal (SignalType s)
SignalType | GetSignalType (Tile t, Track track)
void | SetSignalType (Tile t, Track track, SignalType s)
bool | IsPresignalEntry (Tile t, Track track)
bool | IsPresignalExit (Tile t, Track track)
bool | IsOnewaySignal (Tile t, Track track)
| One-way signals can't be passed the 'wrong' way.
void | CycleSignalSide (Tile t, Track track)
SignalVariant | GetSignalVariant (Tile t, Track track)
void | SetSignalVariant (Tile t, Track track, SignalVariant v)
void | SetSignalStates (Tile tile, uint state)
| Set the states of the signals (Along/AgainstTrackDir)
uint | GetSignalStates (Tile tile)
| Set the states of the signals (Along/AgainstTrackDir)
SignalState | GetSingleSignalState (Tile t, uint8_t signalbit)
| Get the state of a single signal.
void | SetPresentSignals (Tile tile, uint signals)
| Set whether the given signals are present (Along/AgainstTrackDir)
uint | GetPresentSignals (Tile tile)
| Get whether the given signals are present (Along/AgainstTrackDir)
bool | IsSignalPresent (Tile t, uint8_t signalbit)
| Checks whether the given signals is present.
bool | HasSignalOnTrack (Tile tile, Track track)
| Checks for the presence of signals (either way) on the given track on the given rail tile.
bool | HasSignalOnTrackdir (Tile tile, Trackdir trackdir)
| Checks for the presence of signals along the given trackdir on the given rail tile.
SignalState | GetSignalStateByTrackdir (Tile tile, Trackdir trackdir)
| Gets the state of the signal along the given trackdir.
void | SetSignalStateByTrackdir (Tile tile, Trackdir trackdir, SignalState state)
| Sets the state of the signal along the given trackdir.
bool | HasPbsSignalOnTrackdir (Tile tile, Trackdir td)
| Is a pbs signal present along the trackdir?
bool | HasOnewaySignalBlockingTrackdir (Tile tile, Trackdir td)
| Is a one-way signal blocking the trackdir? A one-way signal on the trackdir against will block, but signals on both trackdirs won't.
RailType | GetTileRailType (Tile tile)
| Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
void | SetRailGroundType (Tile t, RailGroundType rgt)
RailGroundType | GetRailGroundType (Tile t)
bool | IsSnowRailGround (Tile t)
void | MakeRailNormal (Tile t, Owner o, TrackBits b, RailType r)
void | SetRailDepotExitDirection (Tile tile, DiagDirection dir)
| Sets the exit direction of a rail depot.
void | MakeRailDepot (Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RailType rail_type)
| Make a rail depot.

## Detailed Description

Hides the direct accesses to the map array with map accessors.

Definition in file rail_map.h.

## Enumeration Type Documentation

## ◆ RailGroundType

enum RailGroundType

The ground 'under' the rail.

Enumerator
RAIL_GROUND_BARREN | Nothing (dirt)
RAIL_GROUND_GRASS | Grassy.
RAIL_GROUND_FENCE_NW | Grass with a fence at the NW edge.
RAIL_GROUND_FENCE_SE | Grass with a fence at the SE edge.
RAIL_GROUND_FENCE_SENW | Grass with a fence at the NW and SE edges.
RAIL_GROUND_FENCE_NE | Grass with a fence at the NE edge.
RAIL_GROUND_FENCE_SW | Grass with a fence at the SW edge.
RAIL_GROUND_FENCE_NESW | Grass with a fence at the NE and SW edges.
RAIL_GROUND_FENCE_VERT1 | Grass with a fence at the eastern side.
RAIL_GROUND_FENCE_VERT2 | Grass with a fence at the western side.
RAIL_GROUND_FENCE_HORIZ1 | Grass with a fence at the southern side.
RAIL_GROUND_FENCE_HORIZ2 | Grass with a fence at the northern side.
RAIL_GROUND_ICE_DESERT | Icy or sandy.
RAIL_GROUND_WATER | Grass with a fence and shore or water on the free halftile.
RAIL_GROUND_HALF_SNOW | Snow only on higher part of slope (steep or one corner raised)

Definition at line 485 of file rail_map.h.

## ◆ RailTileType

enum RailTileType

Different types of Rail-related tiles.

Enumerator
RAIL_TILE_NORMAL | Normal rail tile without signals.
RAIL_TILE_SIGNALS | Normal rail tile with signals.
RAIL_TILE_DEPOT | Depot (one entrance)

Definition at line 23 of file rail_map.h.

## Function Documentation

## ◆ CycleSignalSide()

void CycleSignalSide | ( | Tile | t,
|  | Track | track
| ) |  |
| inline

Definition at line 324 of file rail_map.h.

## ◆ GetDepotReservationTrackBits()

TrackBits GetDepotReservationTrackBits | ( | Tile | t | ) |
| inline

Get the reserved track bits for a depot.

Precondition
  IsRailDepot(t)

Parameters

  t | the tile

Returns
  reserved track bits

Definition at line 282 of file rail_map.h.

References GetRailDepotTrack(), HasDepotReservation(), TRACK_BIT_NONE, and TrackToTrackBits().

Referenced by FollowTrainReservation(), and GetReservedTrackbits().

## ◆ GetPresentSignals()

uint GetPresentSignals | ( | Tile | tile | ) |
| inline

Get whether the given signals are present (Along/AgainstTrackDir)

Parameters

  tile | the tile to get the present signals for

Returns
  the signals that are present

Definition at line 393 of file rail_map.h.

References GB(), and Tile::m3().

Referenced by CmdBuildSingleSignal(), CmdRemoveSingleSignal(), CmdSignalTrackHelper(), HasSignalOnTrack(), HasSignalOnTrackdir(), and IsSignalPresent().

## ◆ GetRailDepotDirection()

DiagDirection GetRailDepotDirection | ( | Tile | t | ) |
| inline

Returns the direction the depot is facing to.

Parameters

  t | the tile to get the depot facing from

Precondition
  IsRailDepotTile(t)

Returns
  the direction the depot is facing

Definition at line 171 of file rail_map.h.

References GB(), and Tile::m5().

Referenced by CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CanEnterNewTile(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildTrainDepot(), DrawRailCatenary(), ExploreSegment(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::ForcedReverse(), FreeTrainTrackReservation(), GetRailDepotTrack(), Train::GetVehicleTrackdir(), ReverseTrainDirection(), TicksToLeaveDepot(), TrainCanLeaveTile(), TryPathReserve(), UpdateSignalsInBuffer(), and VehicleEnter_Track().

## ◆ GetRailDepotTrack()

Track GetRailDepotTrack | ( | Tile | t | ) |
| inline

Returns the track of a depot, ignoring direction.

Precondition
  IsRailDepotTile(t)

Parameters

  t | the tile to get the depot track from

Returns
  the track of the depot

Definition at line 182 of file rail_map.h.

References DiagDirToDiagTrack(), and GetRailDepotDirection().

Referenced by AdvanceWagonsAfterSwap(), CmdConvertRail(), FixupTrainLengths(), and GetDepotReservationTrackBits().

## ◆ GetRailGroundType()

RailGroundType GetRailGroundType | ( | Tile | t | ) |
| inline

Definition at line 508 of file rail_map.h.

## ◆ GetRailReservationTrackBits()

TrackBits GetRailReservationTrackBits | ( | Tile | t | ) |
| inline

Returns the reserved track bits of the tile.

Precondition
  IsPlainRailTile(t)

Parameters

  t | the tile to query

Returns
  the track bits

Definition at line 194 of file rail_map.h.

References GB(), HasBit(), IsPlainRailTile(), Tile::m2(), TRACK_BIT_NONE, TrackToOppositeTrack(), and TrackToTrackBits().

Referenced by CheckFlatLandRailStation(), CmdBuildRailWaypoint(), CmdBuildRoad(), CmdBuildSingleSignal(), CmdRemoveSingleRail(), DrawTrackBits(), GetReservedTrackbits(), TryReserveTrack(), UnreserveTrack(), and UpdateSignalsAroundSegment().

## ◆ GetRailTileType()

static debug_inline RailTileType GetRailTileType | ( | Tile | t | ) |
| static

Returns the RailTileType (normal with or without signals, waypoint or depot).

Parameters

  t | the tile to get the information from

Precondition
  IsTileType(t, MP_RAILWAY)

Returns
  the RailTileType

Definition at line 36 of file rail_map.h.

References GB(), IsTileType(), Tile::m5(), and MP_RAILWAY.

Referenced by CmdBuildRoad(), CmdConvertRail(), GetAxisForNewRailWaypoint(), GetRailTrackBitsUniversal(), HasSignalOnTrack(), HasSignalOnTrackdir(), HasSignals(), IsPlainRail(), IsPossibleCrossing(), IsRailDepot(), MoveWaypointsToBaseStations(), and PlaceExtraDepotRail().

## ◆ GetRailType()

RailType GetRailType | ( | Tile | t | ) |
| inline

Gets the rail type of the given tile.

Parameters

  t | the tile to get the rail type from

Returns
  the rail type of the tile

Definition at line 115 of file rail_map.h.

References GB(), and Tile::m8().

Referenced by AfterLoadGame(), CheckFlatLandRailStation(), CmdBuildBridge(), CmdBuildRailStation(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRailWaypoint(), CmdBuildRoad(), CmdBuildSingleRail(), CmdBuildTrainDepot(), CmdConvertRail(), CmdRemoveSingleRail(), ConvertRailTypes(), DoClearBridge(), DoClearTunnel(), DrawBridgeMiddle(), DrawRailCatenaryRailway(), DrawTile_Road(), DrawTile_TunnelBridge(), DrawTrackBits(), Train::GetCurveSpeedLimit(), Train::GetMaxTrackSpeed(), Train::GetPower(), Train::GetPoweredPartPower(), GetPylonBase(), GetRailTrackBitsUniversal(), GetSmallMapRoutesPixels(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSpeedLimit(), GetTileRailType(), StationScopeResolver::GetVariable(), GetWireBase(), IsCompatibleTrainStationTile(), MoveWaypointsToBaseStations(), RemoveFromRailBaseStation(), RemoveRoad(), SetDefaultRailGui(), TunnelBridgeClearCost(), and BuildVehicleWindow::UpdateFilterByTile().

## ◆ GetSignalStateByTrackdir()

SignalState GetSignalStateByTrackdir | ( | Tile | tile,
|  | Trackdir | trackdir
| ) |  |
| inline

Gets the state of the signal along the given trackdir.

Along meaning if you are currently driving on the given trackdir, this is the signal that is facing us (for which we stop when it's red).

Definition at line 438 of file rail_map.h.

References GetSignalStates(), HasSignalOnTrack(), IsValidTrackdir(), SIGNAL_STATE_GREEN, SIGNAL_STATE_RED, SignalAlongTrackdir(), and TrackdirToTrack().

Referenced by CheckNextTrainTile(), ExploreSegment(), ExtendTrainReservation(), FreeTrainTrackReservation(), CYapfCostRailT< Types >::PfCalcCost(), CYapfReserveTrack< Types >::ReserveSingleTrack(), and UpdateSignalsAroundSegment().

## ◆ GetSignalStates()

uint GetSignalStates | ( | Tile | tile | ) |
| inline

Set the states of the signals (Along/AgainstTrackDir)

Parameters

  tile | the tile to set the states for

Returns
  the state of the signals

Definition at line 362 of file rail_map.h.

References GB(), and Tile::m4().

Referenced by CmdBuildSingleSignal(), GetSignalStateByTrackdir(), GetSingleSignalState(), and SetSignalStateByTrackdir().

## ◆ GetSignalType()

SignalType GetSignalType | ( | Tile | t,
|  | Track | track
| ) |  |
| inline

Definition at line 293 of file rail_map.h.

## ◆ GetSignalVariant()

SignalVariant GetSignalVariant | ( | Tile | t,
|  | Track | track
| ) |  |
| inline

Definition at line 334 of file rail_map.h.

## ◆ GetSingleSignalState()

SignalState GetSingleSignalState | ( | Tile | t,
|  | uint8_t | signalbit
| ) |  |
| inline

Get the state of a single signal.

Parameters

  t | the tile to get the signal state for
  signalbit | the signal

Returns
  the state of the signal

Definition at line 373 of file rail_map.h.

References GetSignalStates(), and HasBit().

## ◆ GetTileRailType()

RailType GetTileRailType | ( | Tile | tile | ) |

Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.

Definition at line 155 of file rail.cpp.

References GetRailType(), GetTileType(), GetTunnelBridgeTransportType(), HasStationRail(), INVALID_RAILTYPE, IsLevelCrossing(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, and TRANSPORT_RAIL.

Referenced by CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CanEnterNewTile(), CheckNextTrainTile(), ExtendTrainReservation(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GetTrainForReservation(), IsSafeWaitingPosition(), IsWaitingPositionFree(), MaskWireBits(), Vehicle::ShowVisualEffect(), TrainCheckIfLineEnds(), TrainController(), and TryPathReserve().

## ◆ GetTrackBits()

TrackBits GetTrackBits | ( | Tile | tile | ) |
| inline

Gets the track bits of the given tile.

Parameters

  tile | the tile to get the track bits from

Returns
  the track bits of the tile

Definition at line 136 of file rail_map.h.

References GB(), IsPlainRailTile(), and Tile::m5().

Referenced by ChangeOwnershipOfCompanyItems(), CheckFlatLandRailStation(), CheckTrackCombination(), CmdBuildRoad(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdConvertRail(), CmdRemoveSingleRail(), DoDryUp(), ExploreSegment(), FloodHalftile(), GetAxisForNewRailWaypoint(), GetRailTrackBitsUniversal(), HasTrack(), IsPossibleCrossing(), PlaceExtraDepotRail(), and CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::QueryNewTileTrackStatus().

## ◆ HasDepotReservation()

bool HasDepotReservation | ( | Tile | t | ) |
| inline

Get the reservation state of the depot.

Precondition
  IsRailDepot(t)

Parameters

  t | the depot tile

Returns
  reservation state

Definition at line 258 of file rail_map.h.

References HasBit(), IsRailDepot(), and Tile::m5().

Referenced by CheckTrainStayInDepot(), GetDepotReservationTrackBits(), TryPathReserve(), and TryReserveRailTrack().

## ◆ HasOnewaySignalBlockingTrackdir()

bool HasOnewaySignalBlockingTrackdir | ( | Tile | tile,
|  | Trackdir | td
| ) |  |
| inline

Is a one-way signal blocking the trackdir? A one-way signal on the trackdir against will block, but signals on both trackdirs won't.

Parameters

  tile | the tile to check
  td | the trackdir to check

Definition at line 475 of file rail_map.h.

References HasSignalOnTrackdir(), IsOnewaySignal(), IsTileType(), MP_RAILWAY, ReverseTrackdir(), and TrackdirToTrack().

Referenced by ExtendTrainReservation(), FollowReservation(), GetTrainForReservation(), CYapfCostRailT< Types >::PfCalcCost(), and TrainController().

## ◆ HasPbsSignalOnTrackdir()

bool HasPbsSignalOnTrackdir | ( | Tile | tile,
|  | Trackdir | td
| ) |  |
| inline

Is a pbs signal present along the trackdir?

Parameters

  tile | the tile to check
  td | the trackdir to check

Definition at line 463 of file rail_map.h.

References HasSignalOnTrackdir(), IsTileType(), MP_RAILWAY, and TrackdirToTrack().

Referenced by CheckNextTrainTile(), ExtendTrainReservation(), FreeTrainTrackReservation(), GetTrainForReservation(), IsSafeWaitingPosition(), CYapfReserveTrack< Types >::ReserveSingleTrack(), and TrainController().

## ◆ HasSignalOnTrack()

bool HasSignalOnTrack | ( | Tile | tile,
|  | Track | track
| ) |  |
| inline

Checks for the presence of signals (either way) on the given track on the given rail tile.

Definition at line 413 of file rail_map.h.

References GetPresentSignals(), GetRailTileType(), IsValidTrack(), RAIL_TILE_SIGNALS, and SignalOnTrack().

Referenced by ChangeOwnershipOfCompanyItems(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), CmdSignalTrackHelper(), ExploreSegment(), GenericPlaceSignals(), and GetSignalStateByTrackdir().

## ◆ HasSignalOnTrackdir()

bool HasSignalOnTrackdir | ( | Tile | tile,
|  | Trackdir | trackdir
| ) |  |
| inline

Checks for the presence of signals along the given trackdir on the given rail tile.

Along meaning if you are currently driving on the given trackdir, this is the signal that is facing us (for which we stop when it's red).

Definition at line 426 of file rail_map.h.

References GetPresentSignals(), GetRailTileType(), IsValidTrackdir(), RAIL_TILE_SIGNALS, and SignalAlongTrackdir().

Referenced by CheckNextTrainTile(), CmdRemoveSingleSignal(), ExploreSegment(), FollowReservation(), FreeTrainTrackReservation(), HasOnewaySignalBlockingTrackdir(), HasPbsSignalOnTrackdir(), IsSafeWaitingPosition(), IsWaitingPositionFree(), CYapfCostRailT< Types >::PfCalcCost(), ReverseTrainDirection(), TrainController(), and UpdateSignalsAroundSegment().

## ◆ HasSignals()

bool HasSignals | ( | Tile | t | ) |
| inline

Checks if a rail tile has signals.

Parameters

  t | the tile to get the information from

Precondition
  IsTileType(t, MP_RAILWAY)

Returns
  true if and only if the tile has signals

Definition at line 72 of file rail_map.h.

References GetRailTileType(), and RAIL_TILE_SIGNALS.

Referenced by AfterLoadGame(), ChangeOwnershipOfCompanyItems(), CheckFlatLandRailStation(), CmdBuildSingleRail(), CmdBuildSingleSignal(), ExploreSegment(), and TrainController().

## ◆ HasTrack()

bool HasTrack | ( | Tile | tile,
|  | Track | track
| ) |  |
| inline

Returns whether the given track is present on the given tile.

Parameters

  tile | the tile to check the track presence of
  track | the track to search for on the tile

Precondition
  IsPlainRailTile(tile)

Returns
  true if and only if the given track exists on the tile

Definition at line 160 of file rail_map.h.

References GetTrackBits(), and HasBit().

Referenced by CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdRemoveSingleSignal(), CmdSignalTrackHelper(), TryReserveRailTrack(), TryReserveTrack(), UnreserveRailTrack(), and UnreserveTrack().

## ◆ IsOnewaySignal()

bool IsOnewaySignal | ( | Tile | t,
|  | Track | track
| ) |  |
| inline

One-way signals can't be passed the 'wrong' way.

Definition at line 319 of file rail_map.h.

References SIGTYPE_PBS.

Referenced by ExploreSegment(), FreeTrainTrackReservation(), and HasOnewaySignalBlockingTrackdir().

## ◆ IsPbsSignal()

bool IsPbsSignal | ( | SignalType | s | ) |
| inline

Definition at line 288 of file rail_map.h.

## ◆ IsPlainRail()

static debug_inline bool IsPlainRail | ( | Tile | t | ) |
| static

Returns whether this is plain rails, with or without signals.

Iow, if this tiles RailTileType is RAIL_TILE_NORMAL or RAIL_TILE_SIGNALS.

Parameters

  t | the tile to get the information from

Precondition
  IsTileType(t, MP_RAILWAY)

Returns
  true if and only if the tile is normal rail (with or without signals)

Definition at line 49 of file rail_map.h.

References GetRailTileType(), RAIL_TILE_NORMAL, and RAIL_TILE_SIGNALS.

Referenced by AfterLoadGame(), CheckTrackCombination(), CmdBuildBridge(), CmdBuildSingleRail(), CmdRemoveSingleRail(), DoDryUp(), DoFloodTile(), ExtendTrainReservation(), GetReservedTrackbits(), IsPlainRailTile(), IsWateredTile(), TryReserveRailTrack(), and UnreserveRailTrack().

## ◆ IsPlainRailTile()

static debug_inline bool IsPlainRailTile | ( | Tile | t | ) |
| static

Checks whether the tile is a rail tile or rail tile with signals.

Parameters

  t | the tile to get the information from

Returns
  true if and only if the tile is normal rail (with or without signals)

Definition at line 60 of file rail_map.h.

References IsPlainRail(), IsTileType(), and MP_RAILWAY.

Referenced by AfterLoadGame(), CheckFlatLandRailStation(), CmdBuildSingleSignal(), CmdConvertRail(), CmdRemoveSingleSignal(), CmdSignalTrackHelper(), DisasterTick_Big_Ufo(), FixOwnerOfRailTrack(), FloodHalftile(), GenericPlaceSignals(), GetRailReservationTrackBits(), GetTrackBits(), GrowTownWithBridge(), MaskWireBits(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::QueryNewTileTrackStatus(), SetHasSignals(), SetTrackBits(), SetTrackReservation(), and TrainController().

## ◆ IsPresignalEntry()

bool IsPresignalEntry | ( | Tile | t,
|  | Track | track
| ) |  |
| inline

Definition at line 308 of file rail_map.h.

## ◆ IsPresignalExit()

bool IsPresignalExit | ( | Tile | t,
|  | Track | track
| ) |  |
| inline

Definition at line 313 of file rail_map.h.

## ◆ IsRailDepot()

static debug_inline bool IsRailDepot | ( | Tile | t | ) |
| static

Is this rail tile a rail depot?

Parameters

  t | the tile to get the information from

Precondition
  IsTileType(t, MP_RAILWAY)

Returns
  true if and only if the tile is a rail depot

Definition at line 95 of file rail_map.h.

References GetRailTileType(), and RAIL_TILE_DEPOT.

Referenced by AfterLoadGame(), DrawRailCatenary(), ExploreSegment(), GetReservedTrackbits(), HasDepotReservation(), IsRailDepotTile(), CYapfCostRailT< Types >::PfCalcCost(), SetDepotReservation(), TryReserveRailTrack(), UnreserveRailTrack(), and UpdateSignalsInBuffer().

## ◆ IsRailDepotTile()

static debug_inline bool IsRailDepotTile | ( | Tile | t | ) |
| static

Is this tile rail tile and a rail depot?

Parameters

  t | the tile to get the information from

Returns
  true if and only if the tile is a rail depot

Definition at line 105 of file rail_map.h.

References IsRailDepot(), IsTileType(), and MP_RAILWAY.

Referenced by AfterLoadGame(), CmdBuildTrainDepot(), CmdInsertOrder(), DeleteLastWagon(), FollowReservation(), FollowTrainReservation(), FreeTrainTrackReservation(), GetDepotIndex(), RailTypeScopeResolver::GetVariable(), IsDepotTile(), IsDepotTypeTile(), IsSafeWaitingPosition(), IsWaitingPositionFree(), CYapfCostRailT< Types >::PfCalcCost(), CYapfDestinationTileOrStationRailT< Types >::PfDetectDestination(), CYapfDestinationAnyDepotRailT< Types >::PfDetectDestination(), ReverseTrainDirection(), SetRailDepotExitDirection(), TrainCanLeaveTile(), and VehicleEnter_Track().

## ◆ IsSignalPresent()

bool IsSignalPresent | ( | Tile | t,
|  | uint8_t | signalbit
| ) |  |
| inline

Checks whether the given signals is present.

Parameters

  t | the tile to check on
  signalbit | the signal

Returns
  true if and only if the signal is present

Definition at line 404 of file rail_map.h.

References GetPresentSignals(), and HasBit().

## ◆ IsSnowRailGround()

bool IsSnowRailGround | ( | Tile | t | ) |
| inline

Definition at line 513 of file rail_map.h.

## ◆ MakeRailDepot()

void MakeRailDepot | ( | Tile | tile,
|  | Owner | owner,
|  | DepotID | depot_id,
|  | DiagDirection | dir,
|  | RailType | rail_type
| ) |  |
| inline

Make a rail depot.

Parameters

  tile | Tile to make a depot on.
  owner | New owner of the depot.
  depot_id | New depot ID.
  dir | Direction of the depot exit.
  rail_type | Rail type of the depot.

Definition at line 552 of file rail_map.h.

References Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), Tile::m8(), MP_RAILWAY, RAIL_TILE_DEPOT, SB(), SetDockingTile(), SetTileOwner(), and SetTileType().

Referenced by CmdBuildTrainDepot().

## ◆ MakeRailNormal()

void MakeRailNormal | ( | Tile | t,
|  | Owner | o,
|  | TrackBits | b,
|  | RailType | r
| ) |  |
| inline

Definition at line 519 of file rail_map.h.

## ◆ SetDepotReservation()

void SetDepotReservation | ( | Tile | t,
|  | bool | b
| ) |  |
| inline

Set the reservation state of the depot.

Precondition
  IsRailDepot(t)

Parameters

  t | the depot tile
  b | the reservation state

Definition at line 270 of file rail_map.h.

References AssignBit(), IsRailDepot(), and Tile::m5().

Referenced by AfterLoadGame(), CheckTrainStayInDepot(), TryPathReserve(), TryReserveRailTrack(), UnreserveRailTrack(), and VehicleEnterDepot().

## ◆ SetHasSignals()

void SetHasSignals | ( | Tile | tile,
|  | bool | signals
| ) |  |
| inline

Add/remove the 'has signal' bit from the RailTileType.

Parameters

  tile | the tile to add/remove the signals to/from
  signals | whether the rail tile should have signals or not

Precondition
  IsPlainRailTile(tile)

Definition at line 83 of file rail_map.h.

References AssignBit(), IsPlainRailTile(), and Tile::m5().

Referenced by CmdBuildSingleSignal(), and CmdRemoveSingleSignal().

## ◆ SetPresentSignals()

void SetPresentSignals | ( | Tile | tile,
|  | uint | signals
| ) |  |
| inline

Set whether the given signals are present (Along/AgainstTrackDir)

Parameters

  tile | the tile to set the present signals for
  signals | the signals that have to be present

Definition at line 383 of file rail_map.h.

References Tile::m3(), and SB().

Referenced by CmdBuildSingleSignal(), and CmdRemoveSingleSignal().

## ◆ SetRailDepotExitDirection()

void SetRailDepotExitDirection | ( | Tile | tile,
|  | DiagDirection | dir
| ) |  |
| inline

Sets the exit direction of a rail depot.

Parameters

  tile | Tile of the depot.
  dir | Direction of the depot exit.

Definition at line 538 of file rail_map.h.

References IsRailDepotTile(), Tile::m5(), and SB().

Referenced by CmdBuildTrainDepot().

## ◆ SetRailGroundType()

void SetRailGroundType | ( | Tile | t,
|  | RailGroundType | rgt
| ) |  |
| inline

Definition at line 503 of file rail_map.h.

## ◆ SetRailType()

void SetRailType | ( | Tile | t,
|  | RailType | r
| ) |  |
| inline

Sets the rail type of the given tile.

Parameters

  t | the tile to set the rail type of
  r | the new rail type for the tile

Definition at line 125 of file rail_map.h.

References Tile::m8(), and SB().

Referenced by AfterLoadGame(), CmdConvertRail(), ConvertRailTypes(), MakeRailBridgeRamp(), MakeRailStation(), MakeRailTunnel(), and MakeRailWaypoint().

## ◆ SetSignalStateByTrackdir()

void SetSignalStateByTrackdir | ( | Tile | tile,
|  | Trackdir | trackdir,
|  | SignalState | state
| ) |  |
| inline

Sets the state of the signal along the given trackdir.

Definition at line 449 of file rail_map.h.

References GetSignalStates(), SetSignalStates(), SIGNAL_STATE_GREEN, and SignalAlongTrackdir().

Referenced by ExtendTrainReservation(), FreeTrainTrackReservation(), CYapfReserveTrack< Types >::ReserveSingleTrack(), TrainController(), CYapfReserveTrack< Types >::TryReservePath(), and UpdateSignalsAroundSegment().

## ◆ SetSignalStates()

void SetSignalStates | ( | Tile | tile,
|  | uint | state
| ) |  |
| inline

Set the states of the signals (Along/AgainstTrackDir)

Parameters

  tile | the tile to set the states for
  state | the new state

Definition at line 352 of file rail_map.h.

References Tile::m4(), and SB().

Referenced by AfterLoadGame(), CmdBuildSingleSignal(), CmdRemoveSingleSignal(), and SetSignalStateByTrackdir().

## ◆ SetSignalType()

void SetSignalType | ( | Tile | t,
|  | Track | track,
|  | SignalType | s
| ) |  |
| inline

Definition at line 300 of file rail_map.h.

## ◆ SetSignalVariant()

void SetSignalVariant | ( | Tile | t,
|  | Track | track,
|  | SignalVariant | v
| ) |  |
| inline

Definition at line 340 of file rail_map.h.

## ◆ SetTrackBits()

void SetTrackBits | ( | Tile | t,
|  | TrackBits | b
| ) |  |
| inline

Sets the track bits of the given tile.

Parameters

  t | the tile to set the track bits of
  b | the new track bits for the tile

Definition at line 147 of file rail_map.h.

References IsPlainRailTile(), Tile::m5(), and SB().

Referenced by CmdBuildSingleRail(), and CmdRemoveSingleRail().

## ◆ SetTrackReservation()

void SetTrackReservation | ( | Tile | t,
|  | TrackBits | b
| ) |  |
| inline

Sets the reserved track bits of the tile.

Precondition
  IsPlainRailTile(t) && !TracksOverlap(b)

Parameters

  t | the tile to change
  b | the track bits

Definition at line 209 of file rail_map.h.

References AssignBit(), INVALID_TRACK, INVALID_TRACK_BIT, IsPlainRailTile(), Tile::m2(), RemoveFirstTrack(), SB(), TRACK_BIT_NONE, and TracksOverlap().

Referenced by AfterLoadGame(), CmdRemoveSingleRail(), RemoveRoad(), TryReserveTrack(), and UnreserveTrack().

## ◆ TryReserveTrack()

bool TryReserveTrack | ( | Tile | tile,
|  | Track | t
| ) |  |
| inline

Try to reserve a specific track on a tile.

Precondition
  IsPlainRailTile(t) && HasTrack(tile, t)

Parameters

  tile | the tile
  t | the rack to reserve

Returns
  true if successful

Definition at line 226 of file rail_map.h.

References GetRailReservationTrackBits(), HasTrack(), SetTrackReservation(), TRACK_BIT_NONE, TracksOverlap(), and TrackToTrackBits().

Referenced by TryReserveRailTrack().

## ◆ UnreserveTrack()

void UnreserveTrack | ( | Tile | tile,
|  | Track | t
| ) |  |
| inline

Lift the reservation of a specific track on a tile.

Precondition
  IsPlainRailTile(t) && HasTrack(tile, t)

Parameters

  tile | the tile
  t | the track to free

Definition at line 244 of file rail_map.h.

References GetRailReservationTrackBits(), HasTrack(), and SetTrackReservation().

Referenced by UnreserveRailTrack().