OpenTTD Source 20260218-master-g2123fca5ea
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 class  RailTileType : uint8_t { Normal = 0 , Signals = 1 , Depot = 3 }
 Different types of Rail-related tiles. More...
enum class  RailGroundType : uint8_t {
  Barren = 0 , Grass = 1 , FenceNW = 2 , FenceSE = 3 ,
  FenceSENW = 4 , FenceNE = 5 , FenceSW = 6 , FenceNESW = 7 ,
  FenceVert1 = 8 , FenceVert2 = 9 , FenceHoriz1 = 10 , FenceHoriz2 = 11 ,
  SnowOrDesert = 12 , HalfTileWater = 13 , HalfTileSnow = 14
}
 The ground 'under' the rail. More...

Functions

static RailTileType GetRailTileType (Tile t)
 Returns the RailTileType (normal with or without signals, waypoint or depot).
static bool IsPlainRail (Tile t)
 Returns whether this is plain rails, with or without signals.
static 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 bool IsRailDepot (Tile t)
 Is this rail tile a rail depot?
static 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)
 Checks whether the given signal is a path based signal.
SignalType GetSignalType (Tile t, Track track)
 Get the signal type for a track on a tile.
void SetSignalType (Tile t, Track track, SignalType s)
 Set the signal type for a track on a tile.
bool IsPresignalEntry (Tile t, Track track)
 Is the signal at the given track on a tile a presignal entry signal?
bool IsPresignalExit (Tile t, Track track)
 Is the signal at the given track on a tile a presignal exit signal?
bool IsOnewaySignal (Tile t, Track track)
 Is the signal at the given track on a tile a one way signal?
void CycleSignalSide (Tile t, Track track)
 Cycle to the next signal side at the given track on a tile.
SignalVariant GetSignalVariant (Tile t, Track track)
 Get the signal variant for a track on a tile.
void SetSignalVariant (Tile t, Track track, SignalVariant v)
 Set the signal variant for a track on a tile.
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?
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)
 Set the ground type for rail tiles.
RailGroundType GetRailGroundType (Tile t)
 Get the ground type for rail tiles.
bool IsSnowOrDesertRailGround (Tile t)
 Is the given rail tile snowy or deserty.
void MakeRailNormal (Tile t, Owner o, TrackBits b, RailType r)
 Make the given tile a normal rail.
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 class RailGroundType : uint8_t
strong

The ground 'under' the rail.

Enumerator
Barren 

Nothing (dirt).

Grass 

Grassy.

FenceNW 

Grass with a fence at the NW edge.

FenceSE 

Grass with a fence at the SE edge.

FenceSENW 

Grass with a fence at the NW and SE edges.

FenceNE 

Grass with a fence at the NE edge.

FenceSW 

Grass with a fence at the SW edge.

FenceNESW 

Grass with a fence at the NE and SW edges.

FenceVert1 

Grass with a fence at the eastern side.

FenceVert2 

Grass with a fence at the western side.

FenceHoriz1 

Grass with a fence at the southern side.

FenceHoriz2 

Grass with a fence at the northern side.

SnowOrDesert 

Icy or sandy.

HalfTileWater 

Grass with a fence and shore or water on the free halftile.

HalfTileSnow 

Snow only on higher part of slope (steep or one corner raised).

Definition at line 558 of file rail_map.h.

◆ RailTileType

enum class RailTileType : uint8_t
strong

Different types of Rail-related tiles.

Enumerator
Normal 

Normal rail tile without signals.

Signals 

Normal rail tile with signals.

Depot 

Depot (one entrance).

Definition at line 23 of file rail_map.h.

Function Documentation

◆ CycleSignalSide()

void CycleSignalSide ( Tile t,
Track track )
inline

Cycle to the next signal side at the given track on a tile.

For path based signals there are two options, for other signals there is a third option with both sides.

Parameters
tThe tile to update.
trackThe track to update for.

Definition at line 369 of file rail_map.h.

References GB(), GetSignalType(), IsPbsSignal(), Tile::m3(), SB(), TRACK_LOWER, and TRACK_RIGHT.

Referenced by CmdBuildSingleSignal().

◆ GetDepotReservationTrackBits()

TrackBits GetDepotReservationTrackBits ( Tile t)
inline

Get the reserved track bits for a depot.

Precondition
IsRailDepot(t)
Parameters
tthe tile
Returns
reserved track bits

Definition at line 281 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
tilethe tile to get the present signals for
Returns
the signals that are present

Definition at line 452 of file rail_map.h.

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

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

◆ GetRailDepotDirection()

DiagDirection GetRailDepotDirection ( Tile t)
inline

◆ GetRailDepotTrack()

Track GetRailDepotTrack ( Tile t)
inline

Returns the track of a depot, ignoring direction.

Precondition
IsRailDepotTile(t)
Parameters
tthe 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

Get the ground type for rail tiles.

Parameters
tThe tile to query.
Returns
The ground type.

Definition at line 591 of file rail_map.h.

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

Referenced by CmdRemoveSingleRail(), DoDryUp(), DrawTrackBits(), DrawTrackDetails(), FloodHalftile(), GetEffectiveWaterClass(), GetFloodingBehaviour(), GetTerrainType(), IsSnowOrDesertRailGround(), IsWateredTile(), SetWaterClassDependingOnSurroundings(), and TestAutoslopeOnRailTile().

◆ GetRailReservationTrackBits()

TrackBits GetRailReservationTrackBits ( Tile t)
inline

Returns the reserved track bits of the tile.

Precondition
IsPlainRailTile(t)
Parameters
tthe 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()

RailTileType GetRailTileType ( Tile t)
inlinestatic

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

Parameters
tthe tile to get the information from
Precondition
IsTileType(t, TileType::Railway)
Returns
the RailTileType

Definition at line 36 of file rail_map.h.

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

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

◆ GetRailType()

◆ 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).

Parameters
tileThe tile to query.
trackdirThe trackdir to query for.
Returns
The signal state for the given trackdir.

Definition at line 506 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
tilethe tile to set the states for
Returns
the state of the signals

Definition at line 421 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

Get the signal type for a track on a tile.

In horizontal and vertical orientation there may be two tracks on a tile with a signal.

Parameters
tThe tile to query.
trackThe track to query for.
Returns
The signal type.

Definition at line 304 of file rail_map.h.

References GB(), GetRailTileType(), Tile::m2(), Signals, TRACK_LOWER, and TRACK_RIGHT.

Referenced by CheckNextTrainTile(), CmdBuildSingleSignal(), CmdRemoveSingleSignal(), CmdSignalTrackHelper(), CycleSignalSide(), ExploreSegment(), FollowReservation(), FreeTrainTrackReservation(), GenericPlaceSignals(), HasPbsSignalOnTrackdir(), IsOnewaySignal(), IsPresignalEntry(), IsPresignalExit(), IsSafeWaitingPosition(), IsWaitingPositionFree(), CYapfCostRailT< Types >::PfCalcCost(), ReverseTrainDirection(), TrainController(), and UpdateSignalsAroundSegment().

◆ GetSignalVariant()

SignalVariant GetSignalVariant ( Tile t,
Track track )
inline

Get the signal variant for a track on a tile.

In horizontal and vertical orientation there may be two tracks on a tile with a signal.

Parameters
tThe tile to query.
trackThe track to query for.
Returns
The signal variant.

Definition at line 386 of file rail_map.h.

References GB(), Tile::m2(), TRACK_LOWER, and TRACK_RIGHT.

Referenced by CmdBuildSingleSignal(), and CmdSignalTrackHelper().

◆ GetSingleSignalState()

SignalState GetSingleSignalState ( Tile t,
uint8_t signalbit )
inline

Get the state of a single signal.

Parameters
tthe tile to get the signal state for
signalbitthe signal
Returns
the state of the signal

Definition at line 432 of file rail_map.h.

References GetSignalStates(), and HasBit().

◆ GetTileRailType()

◆ GetTrackBits()

◆ HasDepotReservation()

bool HasDepotReservation ( Tile t)
inline

Get the reservation state of the depot.

Precondition
IsRailDepot(t)
Parameters
tthe depot tile
Returns
reservation state

Definition at line 257 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
tilethe tile to check
tdthe trackdir to check
Returns
true iff a one way signals blocks the trackdir.

Definition at line 548 of file rail_map.h.

References HasSignalOnTrackdir(), IsOnewaySignal(), IsTileType(), 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
tilethe tile to check
tdthe trackdir to check
Returns
true iff there is a path based signal on the trackdir.

Definition at line 535 of file rail_map.h.

References GetSignalType(), HasSignalOnTrackdir(), IsPbsSignal(), IsTileType(), 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.

Parameters
tileThe tile to query.
trackThe track to query for.
Returns
true iff there is a signal in any direction.

Definition at line 475 of file rail_map.h.

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

Referenced by ChangeOwnershipOfCompanyItems(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), CmdSignalTrackHelper(), DetermineNextTrainForceProceeding(), 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).

Parameters
tileThe tile to query.
trackdirThe trackdir to query for.
Returns
true iff there is a signal in the given direction.

Definition at line 491 of file rail_map.h.

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

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
tthe tile to get the information from
Precondition
IsTileType(t, TileType::Railway)
Returns
true if and only if the tile has signals

Definition at line 72 of file rail_map.h.

References GetRailTileType(), and Signals.

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

◆ HasTrack()

bool HasTrack ( Tile tile,
Track track )
inline

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

Parameters
tilethe tile to check the track presence of
trackthe 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

Is the signal at the given track on a tile a one way signal?

One-way signals can't be passed the 'wrong' way. In horizontal and vertical orientation there may be two tracks on a tile with a signal.

Parameters
tThe tile to query.
trackThe track to query for.
Returns
true iff it is an one way signal.

Definition at line 358 of file rail_map.h.

References GetSignalType(), and SIGTYPE_PBS.

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

◆ IsPbsSignal()

◆ IsPlainRail()

bool IsPlainRail ( Tile t)
inlinestatic

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

Iow, if this tiles RailTileType is RailTileType::Normal or RailTileType::Signals.

Parameters
tthe tile to get the information from
Precondition
IsTileType(t, TileType::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(), Normal, and Signals.

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

◆ IsPlainRailTile()

bool IsPlainRailTile ( Tile t)
inlinestatic

◆ IsPresignalEntry()

bool IsPresignalEntry ( Tile t,
Track track )
inline

Is the signal at the given track on a tile a presignal entry signal?

In horizontal and vertical orientation there may be two tracks on a tile with a signal.

Parameters
tThe tile to query.
trackThe track to query for.
Returns
true iff it is a presignal entry signal.

Definition at line 333 of file rail_map.h.

References GetSignalType(), SIGTYPE_COMBO, and SIGTYPE_ENTRY.

Referenced by UpdateSignalsAroundSegment().

◆ IsPresignalExit()

bool IsPresignalExit ( Tile t,
Track track )
inline

Is the signal at the given track on a tile a presignal exit signal?

In horizontal and vertical orientation there may be two tracks on a tile with a signal.

Parameters
tThe tile to query.
trackThe track to query for.
Returns
true iff it is a presignal exit signal.

Definition at line 345 of file rail_map.h.

References GetSignalType(), SIGTYPE_COMBO, and SIGTYPE_EXIT.

Referenced by ExploreSegment(), and UpdateSignalsAroundSegment().

◆ IsRailDepot()

bool IsRailDepot ( Tile t)
inlinestatic

Is this rail tile a rail depot?

Parameters
tthe tile to get the information from
Precondition
IsTileType(t, TileType::Railway)
Returns
true if and only if the tile is a rail depot

Definition at line 95 of file rail_map.h.

References Depot, and GetRailTileType().

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

◆ IsRailDepotTile()

◆ IsSignalPresent()

bool IsSignalPresent ( Tile t,
uint8_t signalbit )
inline

Checks whether the given signals is present.

Parameters
tthe tile to check on
signalbitthe signal
Returns
true if and only if the signal is present

Definition at line 463 of file rail_map.h.

References GetPresentSignals(), and HasBit().

◆ IsSnowOrDesertRailGround()

bool IsSnowOrDesertRailGround ( Tile t)
inline

Is the given rail tile snowy or deserty.

Parameters
tThe tile to query.
Returns
true iff the tile is snowy or deserty.

Definition at line 601 of file rail_map.h.

References GetRailGroundType(), and SnowOrDesert.

◆ MakeRailDepot()

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

Make a rail depot.

Parameters
tileTile to make a depot on.
ownerNew owner of the depot.
depot_idNew depot ID.
dirDirection of the depot exit.
rail_typeRail type of the depot.

Definition at line 647 of file rail_map.h.

References Depot, Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), Tile::m8(), Railway, SB(), SetDockingTile(), SetTileOwner(), SetTileType(), and to_underlying().

Referenced by CmdBuildTrainDepot().

◆ MakeRailNormal()

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

Make the given tile a normal rail.

Parameters
tThe tile to convert.
oThe new owner.
bThe bits/tracks to set.
rThe new rail type.

Definition at line 614 of file rail_map.h.

References Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), Tile::m8(), Normal, Railway, SB(), SetDockingTile(), SetTileOwner(), SetTileType(), and to_underlying().

Referenced by AfterLoadGame(), CmdBuildSingleRail(), RemoveFromRailBaseStation(), and RemoveRoad().

◆ SetDepotReservation()

void SetDepotReservation ( Tile t,
bool b )
inline

Set the reservation state of the depot.

Precondition
IsRailDepot(t)
Parameters
tthe depot tile
bthe reservation state

Definition at line 269 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
tilethe tile to add/remove the signals to/from
signalswhether the rail tile should have signals or not
Precondition
IsPlainRailTile(tile)

Definition at line 83 of file rail_map.h.

References IsPlainRailTile(), Tile::m5(), Normal, SB(), Signals, and to_underlying().

Referenced by CmdBuildSingleSignal(), and CmdRemoveSingleSignal().

◆ SetPresentSignals()

void SetPresentSignals ( Tile tile,
uint signals )
inline

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

Parameters
tilethe tile to set the present signals for
signalsthe signals that have to be present

Definition at line 442 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
tileTile of the depot.
dirDirection of the depot exit.

Definition at line 633 of file rail_map.h.

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

Referenced by CmdBuildTrainDepot().

◆ SetRailGroundType()

void SetRailGroundType ( Tile t,
RailGroundType rgt )
inline

Set the ground type for rail tiles.

Parameters
tThe tile to update.
rgtThe new ground type.

Definition at line 581 of file rail_map.h.

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

Referenced by CmdBuildSingleRail(), DoDryUp(), FloodHalftile(), and TestAutoslopeOnRailTile().

◆ SetRailType()

void SetRailType ( Tile t,
RailType r )
inline

Sets the rail type of the given tile.

Parameters
tthe tile to set the rail type of
rthe 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.

Parameters
tileThe tile to update.
trackdirThe trackdir to update for.
stateThe new signal state.

Definition at line 520 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
tilethe tile to set the states for
statethe new state

Definition at line 411 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

Set the signal type for a track on a tile.

In horizontal and vertical orientation there may be two tracks on a tile with a signal.

Parameters
tThe tile to update.
trackThe track to update for.
sThe new signal type.

Definition at line 318 of file rail_map.h.

References GetRailTileType(), INVALID_TRACK, Tile::m2(), SB(), Signals, TRACK_LOWER, and TRACK_RIGHT.

Referenced by CmdBuildSingleSignal().

◆ SetSignalVariant()

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

Set the signal variant for a track on a tile.

In horizontal and vertical orientation there may be two tracks on a tile with a signal.

Parameters
tThe tile to update.
trackThe track to update for.
vThe new signal variant.

Definition at line 399 of file rail_map.h.

References INVALID_TRACK, Tile::m2(), SB(), TRACK_LOWER, and TRACK_RIGHT.

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

◆ SetTrackBits()

void SetTrackBits ( Tile t,
TrackBits b )
inline

Sets the track bits of the given tile.

Parameters
tthe tile to set the track bits of
bthe 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
tthe tile to change
bthe track bits

Definition at line 209 of file rail_map.h.

References AssignBit(), INVALID_TRACK, 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(tile) && HasTrack(tile, t)
Parameters
tilethe tile
tthe track to reserve
Returns
true if successful

Definition at line 225 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(tile) && HasTrack(tile, t)
Parameters
tilethe tile
tthe track to free

Definition at line 243 of file rail_map.h.

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

Referenced by UnreserveRailTrack().