# rail_map.h File Reference

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

`#include "rail_type.h"`
`#include "signal_func.h"`
`#include "direction_func.h"`
`#include "track_func.h"`
`#include "tile_map.h"`
`#include "signal_type.h"`
`#include "waypoint_type.h"`

Go to the source code of this file.

## Enumerations
enum | RailTileType { RAIL_TILE_NORMAL = 0, RAIL_TILE_SIGNALS = 1, RAIL_TILE_WAYPOINT = 2, RAIL_TILE_DEPOT = 3 }
| Different types of Rail-related tiles. More...
enum | SignalState { SIGNAL_STATE_RED = 0, SIGNAL_STATE_GREEN = 1 }
| These are states in which a signal can be. 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 RailTileType | GetRailTileType (TileIndex t)
| Returns the RailTileType (normal with or without signals, waypoint or depot).
static bool | IsPlainRail (TileIndex t)
| Returns whether this is plain rails, with or without signals.
static bool | IsPlainRailTile (TileIndex t)
| Checks whether the tile is a rail tile or rail tile with signals.
static bool | HasSignals (TileIndex t)
| Checks if a rail tile has signals.
static void | SetHasSignals (TileIndex tile, bool signals)
| Add/remove the 'has signal' bit from the RailTileType.
static bool | IsRailWaypoint (TileIndex t)
| Is this rail tile a rail waypoint?
static bool | IsRailWaypointTile (TileIndex t)
| Is this tile rail tile and a rail waypoint?
static bool | IsRailDepot (TileIndex t)
| Is this rail tile a rail depot?
static bool | IsRailDepotTile (TileIndex t)
| Is this tile rail tile and a rail depot?
static RailType | GetRailType (TileIndex t)
| Gets the rail type of the given tile.
static void | SetRailType (TileIndex t, RailType r)
| Sets the rail type of the given tile.
static TrackBits | GetTrackBits (TileIndex tile)
| Gets the track bits of the given tile.
static void | SetTrackBits (TileIndex t, TrackBits b)
| Sets the track bits of the given tile.
static bool | HasTrack (TileIndex tile, Track track)
| Returns whether the given track is present on the given tile.
static DiagDirection | GetRailDepotDirection (TileIndex t)
| Returns the direction the depot is facing to.
static Track | GetRailDepotTrack (TileIndex t)
| Returns the track of a depot, ignoring direction.
static Axis | GetWaypointAxis (TileIndex t)
| Returns the axis of the waypoint.
static Track | GetRailWaypointTrack (TileIndex t)
| Returns the track of the waypoint.
static TrackBits | GetRailWaypointBits (TileIndex t)
| Returns the track bits of the waypoint.
static WaypointID | GetWaypointIndex (TileIndex t)
| Returns waypoint index (for the waypoint pool).
static TrackBits | GetTrackReservation (TileIndex t)
| Returns the reserved track bits of the tile.
static void | SetTrackReservation (TileIndex t, TrackBits b)
| Sets the reserved track bits of the tile.
static bool | TryReserveTrack (TileIndex tile, Track t)
| Try to reserve a specific track on a tile.
static void | UnreserveTrack (TileIndex tile, Track t)
| Lift the reservation of a specific track on a tile.
static bool | GetDepotWaypointReservation (TileIndex t)
| Get the reservation state of the waypoint or depot.
static void | SetDepotWaypointReservation (TileIndex t, bool b)
| Set the reservation state of the waypoint or depot.
static TrackBits | GetRailWaypointReservation (TileIndex t)
| Get the reserved track bits for a waypoint.
static TrackBits | GetRailDepotReservation (TileIndex t)
| Get the reserved track bits for a depot.
static bool | IsPbsSignal (SignalType s)
static SignalType | GetSignalType (TileIndex t, Track track)
static void | SetSignalType (TileIndex t, Track track, SignalType s)
static bool | IsPresignalEntry (TileIndex t, Track track)
static bool | IsPresignalExit (TileIndex t, Track track)
static bool | IsOnewaySignal (TileIndex t, Track track)
| One-way signals can't be passed the 'wrong' way.
static void | CycleSignalSide (TileIndex t, Track track)
static SignalVariant | GetSignalVariant (TileIndex t, Track track)
static void | SetSignalVariant (TileIndex t, Track track, SignalVariant v)
static void | SetSignalStates (TileIndex tile, uint state)
| Set the states of the signals (Along/AgainstTrackDir).
static uint | GetSignalStates (TileIndex tile)
| Set the states of the signals (Along/AgainstTrackDir).
static SignalState | GetSingleSignalState (TileIndex t, byte signalbit)
| Get the state of a single signal.
static void | SetPresentSignals (TileIndex tile, uint signals)
| Set whether the given signals are present (Along/AgainstTrackDir).
static uint | GetPresentSignals (TileIndex tile)
| Get whether the given signals are present (Along/AgainstTrackDir).
static bool | IsSignalPresent (TileIndex t, byte signalbit)
| Checks whether the given signals is present.
static bool | HasSignalOnTrack (TileIndex tile, Track track)
| Checks for the presence of signals (either way) on the given track on the given rail tile.
static bool | HasSignalOnTrackdir (TileIndex tile, Trackdir trackdir)
| Checks for the presence of signals along the given trackdir on the given rail tile.
static SignalState | GetSignalStateByTrackdir (TileIndex tile, Trackdir trackdir)
| Gets the state of the signal along the given trackdir.
static void | SetSignalStateByTrackdir (TileIndex tile, Trackdir trackdir, SignalState state)
| Sets the state of the signal along the given trackdir.
static bool | HasPbsSignalOnTrackdir (TileIndex tile, Trackdir td)
| Is a pbs signal present along the trackdir?
static bool | HasOnewaySignalBlockingTrackdir (TileIndex 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 (TileIndex tile)
| Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
static void | SetRailGroundType (TileIndex t, RailGroundType rgt)
static RailGroundType | GetRailGroundType (TileIndex t)
static bool | IsSnowRailGround (TileIndex t)
static void | MakeRailNormal (TileIndex t, Owner o, TrackBits b, RailType r)
static void | MakeRailDepot (TileIndex t, Owner o, DiagDirection d, RailType r)
static void | MakeRailWaypoint (TileIndex t, Owner o, Axis a, RailType r, uint index)

## Detailed Description

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

Definition in file rail_map.h.

## Enumeration Type Documentation

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 581 of file rail_map.h.

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_WAYPOINT | Waypoint (X or Y direction).
  RAIL_TILE_DEPOT | Depot (one entrance).

Definition at line 18 of file rail_map.h.

enum SignalState

These are states in which a signal can be.

Currently these are only two, so simple boolean logic will do. But do try to compare to this enum instead of normal boolean evaluation, since that will make future additions easier.

Enumerator:

  SIGNAL_STATE_RED | The signal is red.
  SIGNAL_STATE_GREEN | The signal is green.

Definition at line 426 of file rail_map.h.

## Function Documentation

static bool GetDepotWaypointReservation | ( | TileIndex | t | ) | `[inline, static]`

Get the reservation state of the waypoint or depot.

Note:
  Works for both waypoints and rail depots

Precondition:
  IsRailWaypoint(t) || IsRailDepot(t)

Parameters:

  | t | the waypoint/depot tile

Returns:
  reservation state

Definition at line 321 of file rail_map.h.

References _m, HasBit(), IsRailDepot(), and IsRailWaypoint().

Referenced by GetRailDepotReservation(), GetRailWaypointReservation(), RemoveTrainWaypoint(), TryPathReserve(), and TryReserveRailTrack().

static uint GetPresentSignals | ( | TileIndex | tile | ) | `[inline, static]`

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 477 of file rail_map.h.

References _m, and GB().

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

static DiagDirection GetRailDepotDirection | ( | TileIndex | t | ) | `[inline, static]`

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 188 of file rail_map.h.

References _m, and GB().

Referenced by CanAccessTileInDir(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::CanEnterNewTile(), CmdBuildRailVehicle(), CmdBuildRailWagon(), DrawCatenary(), ExploreSegment(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::ForcedReverse(), GetDepotDirection(), AIRail::GetRailDepotFrontTile(), GetRailDepotTrack(), GetVehicleTrackdir(), TicksToLeaveDepot(), TrainCanLeaveTile(), TryPathReserve(), UpdateSignalsInBuffer(), and VehicleEnter_Track().

static TrackBits GetRailDepotReservation | ( | TileIndex | t | ) | `[inline, static]`

Get the reserved track bits for a depot.

Precondition:
  IsRailDepot(t)

Parameters:

  | t | the tile

Returns:
  reserved track bits

Definition at line 357 of file rail_map.h.

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

Referenced by FollowTrainReservation().

static Track GetRailDepotTrack | ( | TileIndex | t | ) | `[inline, static]`

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 199 of file rail_map.h.

References DiagDirToDiagTrack(), and GetRailDepotDirection().

Referenced by AdvanceWagonsAfterSwap(), CmdConvertRail(), and GetRailDepotReservation().

static RailTileType GetRailTileType | ( | TileIndex | t | ) | `[inline, 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 32 of file rail_map.h.

References _m, GB(), IsTileType(), and MP_RAILWAY.

Referenced by CmdBuildRoad(), CmdBuildTrainWaypoint(), CmdConvertRail(), ExploreSegment(), GetOrderTypeByTile(), GetRailTrackBitsUniversal(), HasSignalOnTrack(), HasSignalOnTrackdir(), HasSignals(), IsPlainRail(), IsPossibleCrossing(), IsRailDepot(), IsRailWaypoint(), and PlaceExtraDepotRail().

static RailType GetRailType | ( | TileIndex | t | ) | `[inline, static]`

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 132 of file rail_map.h.

References _m, and GB().

Referenced by CmdBuildBridge(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoad(), CmdBuildSingleRail(), CmdBuildTrainWaypoint(), CmdConvertRail(), DrawCatenaryRailway(), DrawTile_Road(), DrawTile_TunnelBridge(), DrawTrackBits(), GetRailTrackBitsUniversal(), GetTileRailType(), RemoveRoad(), RemoveTrainWaypoint(), SetDefaultRailGui(), and TrainPowerChanged().

static TrackBits GetRailWaypointBits | ( | TileIndex | t | ) | `[inline, static]`

Returns the track bits of the waypoint.

Parameters:

  | t | the tile to get the waypoint track bits from

Precondition:
  IsRailWaypointTile(t)

Returns:
  the track bits of the waypoint

Definition at line 233 of file rail_map.h.

References GetRailWaypointTrack(), and TrackToTrackBits().

Referenced by GetRailTrackBitsUniversal(), AIRail::GetRailTracks(), GetRailWaypointReservation(), and RemoveTrainWaypoint().

static TrackBits GetRailWaypointReservation | ( | TileIndex | t | ) | `[inline, static]`

Get the reserved track bits for a waypoint.

Precondition:
  IsRailWaypoint(t)

Parameters:

  | t | the tile

Returns:
  reserved track bits

Definition at line 346 of file rail_map.h.

References GetDepotWaypointReservation(), GetRailWaypointBits(), and TRACK_BIT_NONE.

Referenced by GetReservedTrackbits().

static Track GetRailWaypointTrack | ( | TileIndex | t | ) | `[inline, static]`

Returns the track of the waypoint.

Parameters:

  | t | the tile to get the waypoint track from

Precondition:
  IsRailWaypointTile(t)

Returns:
  the track of the waypoint

Definition at line 222 of file rail_map.h.

References AxisToTrack(), and GetWaypointAxis().

Referenced by CmdConvertRail(), GetRailWaypointBits(), and RemoveTrainWaypoint().

static SignalState GetSignalStateByTrackdir | ( | TileIndex | tile,
|  | Trackdir | trackdir |
| ) |  |  | `[inline, static]`

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 526 of file rail_map.h.

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

Referenced by CheckNextTrainTile(), ExploreSegment(), FreeTrainTrackReservation(), and UpdateSignalsAroundSegment().

static uint GetSignalStates | ( | TileIndex | tile | ) | `[inline, static]`

Set the states of the signals (Along/AgainstTrackDir).

Parameters:

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

Definition at line 446 of file rail_map.h.

References _m, and GB().

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

static SignalState GetSingleSignalState | ( | TileIndex | t,
|  | byte | signalbit |
| ) |  |  | `[inline, static]`

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 457 of file rail_map.h.

References GetSignalStates(), and HasBit().

static TrackBits GetTrackBits | ( | TileIndex | tile | ) | `[inline, static]`

Gets the track bits of the given tile.

Parameters:

  | t | the tile to get the track bits from

Returns:
  the track bits of the tile

Definition at line 153 of file rail_map.h.

References _m, GB(), and IsPlainRailTile().

Referenced by CmdBuildRoad(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdBuildTrainWaypoint(), CmdConvertRail(), CmdRemoveSingleRail(), DoDryUp(), ExploreSegment(), FloodHalftile(), GetRailTrackBitsUniversal(), AIRail::GetRailTracks(), HasTrack(), IsPossibleCrossing(), PlaceExtraDepotRail(), and CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::QueryNewTileTrackStatus().

static TrackBits GetTrackReservation | ( | TileIndex | t | ) | `[inline, static]`

Returns the reserved track bits of the tile.

Precondition:
  IsPlainRailTile(t)

Parameters:

  | t | the tile to query

Returns:
  the track bits

Definition at line 256 of file rail_map.h.

References _m, GB(), HasBit(), IsPlainRailTile(), TRACK_BIT_NONE, TrackToOppositeTrack(), and TrackToTrackBits().

Referenced by CmdBuildRoad(), CmdBuildSingleSignal(), CmdBuildTrainWaypoint(), CmdRemoveSingleRail(), DrawTrackBits(), GetReservedTrackbits(), TryReserveTrack(), and UnreserveTrack().

static Axis GetWaypointAxis | ( | TileIndex | t | ) | `[inline, static]`

Returns the axis of the waypoint.

Parameters:

  | t | the tile to get the waypoint axis from

Precondition:
  IsRailWaypointTile(t)

Returns:
  the axis of the waypoint

Definition at line 211 of file rail_map.h.

References _m, and GB().

Referenced by ExploreSegment(), and GetRailWaypointTrack().

static WaypointID GetWaypointIndex | ( | TileIndex | t | ) | `[inline, static]`

Returns waypoint index (for the waypoint pool).

Parameters:

  | t | the tile to get the waypoint index from

Precondition:
  IsRailWaypointTile(t)

Returns:
  the waypoint index

Definition at line 244 of file rail_map.h.

References _m, and Tile::m2.

Referenced by GetWaypointByTile(), AIWaypoint::GetWaypointID(), and AIOrder::InsertOrder().

static bool HasOnewaySignalBlockingTrackdir | ( | TileIndex | tile,
|  | Trackdir | td |
| ) |  |  | `[inline, static]`

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 565 of file rail_map.h.

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

Referenced by ExtendTrainReservation(), and FollowReservation().

static bool HasPbsSignalOnTrackdir | ( | TileIndex | tile,
|  | Trackdir | td |
| ) |  |  | `[inline, static]`

Is a pbs signal present along the trackdir?

Parameters:

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

Definition at line 551 of file rail_map.h.

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

Referenced by CheckNextTrainTile(), FreeTrainTrackReservation(), and IsSafeWaitingPosition().

static bool HasSignalOnTrackdir | ( | TileIndex | tile,
|  | Trackdir | trackdir |
| ) |  |  | `[inline, static]`

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 512 of file rail_map.h.

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

Referenced by CheckNextTrainTile(), ExploreSegment(), FollowReservation(), FreeTrainTrackReservation(), AIRail::GetSignalType(), HasOnewaySignalBlockingTrackdir(), HasPbsSignalOnTrackdir(), IsSafeWaitingPosition(), IsWaitingPositionFree(), TryPathReserve(), and UpdateSignalsAroundSegment().

static bool HasSignals | ( | TileIndex | t | ) | `[inline, static]`

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 68 of file rail_map.h.

References GetRailTileType(), and RAIL_TILE_SIGNALS.

Referenced by CmdBuildSingleSignal(), ExploreSegment(), and AIRail::GetSignalType().

static bool HasTrack | ( | TileIndex | tile,
|  | Track | track |
| ) |  |  | `[inline, static]`

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 177 of file rail_map.h.

References GetTrackBits(), and HasBit().

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

static bool IsOnewaySignal | ( | TileIndex | t,
|  | Track | track |
| ) |  |  | `[inline, static]`

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

Definition at line 394 of file rail_map.h.

References SIGTYPE_PBS.

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

static bool IsPlainRail | ( | TileIndex | t | ) | `[inline, 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 45 of file rail_map.h.

References GetRailTileType(), RAIL_TILE_NORMAL, and RAIL_TILE_SIGNALS.

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

static bool IsPlainRailTile | ( | TileIndex | t | ) | `[inline, 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 56 of file rail_map.h.

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

Referenced by AIRail::BuildSignal(), CmdBuildSingleSignal(), CmdRemoveSingleSignal(), CmdSignalTrackHelper(), DisasterTick_Big_Ufo(), FixOwnerOfRailTrack(), FloodHalftile(), GetTrackBits(), GetTrackReservation(), MaskWireBits(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::QueryNewTileTrackStatus(), AIRail::RemoveRailTrack(), SetHasSignals(), SetTrackBits(), and SetTrackReservation().

static bool IsRailDepot | ( | TileIndex | t | ) | `[inline, 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 112 of file rail_map.h.

References GetRailTileType(), and RAIL_TILE_DEPOT.

Referenced by DrawCatenary(), ExploreSegment(), GetDepotWaypointReservation(), GetReservedTrackbits(), IsRailDepotTile(), AIRail::IsRailTile(), NPFMarkTile(), SetDepotWaypointReservation(), TryReserveRailTrack(), UnreserveRailTrack(), and UpdateSignalsInBuffer().

static bool IsRailDepotTile | ( | TileIndex | t | ) | `[inline, 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 122 of file rail_map.h.

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

Referenced by CanAccessTileInDir(), CmdBuildRailVehicle(), CmdInsertOrder(), DeleteLastWagon(), FindClosestTrainDepot(), FixTTDDepots(), FollowReservation(), FollowTrainReservation(), IsDepotTile(), IsDepotTypeTile(), AIRail::IsRailDepotTile(), IsSafeWaitingPosition(), IsWaitingPositionFree(), TrainCanLeaveTile(), and VehicleEnter_Track().

static bool IsRailWaypoint | ( | TileIndex | t | ) | `[inline, static]`

Is this rail tile a rail waypoint?

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 waypoint

Definition at line 91 of file rail_map.h.

References GetRailTileType(), and RAIL_TILE_WAYPOINT.

Referenced by GetDepotWaypointReservation(), GetReservedTrackbits(), IsRailWaypointTile(), SetDepotWaypointReservation(), TryReserveRailTrack(), and UnreserveRailTrack().

static bool IsRailWaypointTile | ( | TileIndex | t | ) | `[inline, static]`

Is this tile rail tile and a rail waypoint?

Parameters:

  | t | the tile to get the information from

Returns:
  true if and only if the tile is a rail waypoint

Definition at line 101 of file rail_map.h.

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

Referenced by GetWaypointByTile(), and RemoveTrainWaypoint().

static bool IsSignalPresent | ( | TileIndex | t,
|  | byte | signalbit |
| ) |  |  | `[inline, static]`

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 488 of file rail_map.h.

References GetPresentSignals(), and HasBit().

static void SetDepotWaypointReservation | ( | TileIndex | t,
|  | bool | b |
| ) |  |  | `[inline, static]`

Set the reservation state of the waypoint or depot.

Note:
  Works for both waypoints and rail depots

Precondition:
  IsRailWaypoint(t) || IsRailDepot(t)

Parameters:

  | t | the waypoint/depot tile
  | b | the reservation state

Definition at line 334 of file rail_map.h.

References _m, IsRailDepot(), IsRailWaypoint(), and SB().

Referenced by CmdBuildTrainWaypoint(), TryPathReserve(), TryReserveRailTrack(), and UnreserveRailTrack().

static void SetHasSignals | ( | TileIndex | tile,
|  | bool | signals |
| ) |  |  | `[inline, static]`

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 79 of file rail_map.h.

References _m, IsPlainRailTile(), and SB().

Referenced by CmdBuildSingleSignal(), and CmdRemoveSingleSignal().

static void SetPresentSignals | ( | TileIndex | tile,
|  | uint | signals |
| ) |  |  | `[inline, static]`

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 467 of file rail_map.h.

References _m, and SB().

Referenced by CmdBuildSingleSignal(), and CmdRemoveSingleSignal().

static void SetRailType | ( | TileIndex | t,
|  | RailType | r |
| ) |  |  | `[inline, static]`

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 142 of file rail_map.h.

References _m, and SB().

Referenced by CmdConvertRail().

static void SetSignalStates | ( | TileIndex | tile,
|  | uint | state |
| ) |  |  | `[inline, static]`

Set the states of the signals (Along/AgainstTrackDir).

Parameters:

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

Definition at line 436 of file rail_map.h.

References _m, and SB().

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

static void SetTrackBits | ( | TileIndex | t,
|  | TrackBits | b |
| ) |  |  | `[inline, static]`

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 164 of file rail_map.h.

References _m, IsPlainRailTile(), and SB().

Referenced by CmdBuildSingleRail(), and CmdRemoveSingleRail().

static void SetTrackReservation | ( | TileIndex | t,
|  | TrackBits | b |
| ) |  |  | `[inline, static]`

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 271 of file rail_map.h.

References _m, INVALID_TRACK, INVALID_TRACK_BIT, IsPlainRailTile(), RemoveFirstTrack(), SB(), TRACK_BIT_NONE, and TracksOverlap().

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

static bool TryReserveTrack | ( | TileIndex | tile,
|  | Track | t |
| ) |  |  | `[inline, static]`

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 288 of file rail_map.h.

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

Referenced by TryReserveRailTrack().

static void UnreserveTrack | ( | TileIndex | tile,
|  | Track | t |
| ) |  |  | `[inline, static]`

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 306 of file rail_map.h.

References GetTrackReservation(), HasTrack(), SetTrackReservation(), and TrackToTrackBits().

Referenced by UnreserveRailTrack().