OpenTTD Source 20261112-master-gbcbec5e63f
rail.h File Reference

Rail specific functions. More...

#include "rail_type.h"
#include "track_type.h"
#include "gfx_type.h"
#include "core/enum_type.hpp"
#include "core/flatset_type.hpp"
#include "economy_func.h"
#include "slope_type.h"
#include "strings_type.h"
#include "timer/timer_game_calendar.h"
#include "signal_type.h"
#include "settings_type.h"
#include "newgrf_badge_type.h"

Go to the source code of this file.

Data Structures

class  RailTypeInfo
 This struct contains all the info that is needed to draw and construct tracks. More...

Typedefs

using RailTypeFlags = EnumBitSet<RailTypeFlag, uint8_t>
 Bitset of RailTypeFlag elements.

Enumerations

enum class  RailTypeFlag : uint8_t {
  Catenary = 0 , NoLevelCrossing = 1 , Hidden = 2 , NoSpriteCombine = 3 ,
  Allow90Deg = 4 , Disallow90Deg = 5
}
 Railtype flag bit numbers. More...
enum class  RailSpriteType : uint8_t {
  UI , Overlay , Ground , Tunnel ,
  Wires , Pylons , Bridge , Crossing ,
  Depot , Fences , TunnelPortal , Signals ,
  GroundComplete , End
}
 Sprite types for a railtype. More...
enum class  RailTrackOffset : uint8_t {
  X , Y , N , S ,
  E , W , SlopeNE , SlopeSE ,
  SlopeSW , SlopeNW , CrossingXY , JunctionSW ,
  JunctionNE , JunctionSE , JunctionNW , JunctionNSEW
}
 Offsets for sprites within an overlay/underlay set. More...
enum class  RailTrackBridgeOffset : uint8_t { X , Y , Slope }
 Offsets for sprites within a bridge surface overlay set. More...
enum class  RailFenceOffset : uint8_t {
  FlatXNW , FlatYNE , FlatLeft , FlatUpper ,
  SlopeSWNW , SlopeSENE , SlopeNENW , SlopeNWNE ,
  FlatXSE , FlatYSW , FlatRight , FlatLower ,
  SlopeSWSE , SlopeSESW , SlopeNESE , SlopeNWSW ,
  End
}
 Offsets from base sprite for fence sprites. More...

Functions

constexpr SpriteID operator+ (SpriteID sprite, RailTrackOffset offset)
 Operator overload to allow RailTrackOffset to be added to a SpriteID without the need to use to_underlying.
constexpr SpriteID operator+ (SpriteID sprite, RailTrackBridgeOffset offset)
 Operator overload to allow RailTrackBridgeOffset to be added to a SpriteID without the need to use to_underlying.
const RailTypeInfo * GetRailTypeInfo (RailType railtype)
 Returns a pointer to the Railtype information for a given railtype.
RailTypes GetAllCompatibleRailTypes (RailTypes railtypes)
 Returns all compatible railtypes for a set of railtypes.
RailTypes GetAllPoweredRailTypes (RailTypes railtypes)
 Returns all powered railtypes for a set of railtypes.
RailTypes GetAllIntroducesRailTypes (RailTypes railtypes)
 Returns all introduced railtypes for a set of railtypes.
bool IsCompatibleRail (RailType enginetype, RailType tiletype)
 Checks if an engine of the given RailType can drive on a tile with a given RailType.
bool IsCompatibleRail (RailTypes enginetype, RailType tiletype)
 Checks if an engine of the given RailTypes can drive on a tile with a given RailType.
bool HasPowerOnRail (RailType enginetype, RailType tiletype)
 Checks if an engine of the given RailType got power on a tile with a given RailType.
bool HasPowerOnRail (RailTypes enginetype, RailType tiletype)
 Checks if an engine of the given RailTypes got power on a tile with a given RailType.
bool RailNoLevelCrossings (RailType rt)
 Test if a RailType disallows build of level crossings.
bool Rail90DegTurnDisallowed (RailType rt1, RailType rt2, bool def=_settings_game.pf.forbid_90_deg)
 Test if 90 degree turns are disallowed between two railtypes.
Money RailBuildCost (RailType railtype)
 Returns the cost of building the specified railtype.
Money RailClearCost (RailType railtype)
 Returns the 'cost' of clearing the specified railtype.
Money RailConvertCost (RailType from, RailType to)
 Calculates the cost of rail conversion.
Money RailMaintenanceCost (RailType railtype, uint32_t num, uint32_t total_num)
 Calculates the maintenance cost of a number of track bits.
Money SignalMaintenanceCost (uint32_t num)
 Calculates the maintenance cost of a number of signals.
void DrawTrainDepotSprite (int x, int y, DiagDirection dir, RailType railtype)
 Draw train depot sprite in the UI.
int TicksToLeaveDepot (const Train *v)
 Compute number of ticks when next wagon will leave a depot.
Foundation GetRailFoundation (Slope tileh, TrackBits bits)
 Checks if a track combination is valid on a specific slope and returns the needed foundation.
bool HasRailTypeAvail (const CompanyID company, const RailType railtype)
 Finds out if a company has a certain buildable railtype available.
bool HasAnyRailTypesAvail (const CompanyID company)
 Test if any buildable railtype is available for a company.
bool ValParamRailType (const RailType rail)
 Validate functions for rail building.
RailTypes AddDateIntroducedRailTypes (RailTypes current, TimerGameCalendar::Date date)
 Add the rail types that are to be introduced at the given date.
RailTypes GetCompanyRailTypes (CompanyID company, bool introduces=true)
 Get the rail types the given company can build.
RailTypes GetRailTypes (bool introduces)
 Get list of rail types, regardless of company availability.
RailType GetRailTypeByLabel (RailTypeLabel label, bool allow_alternate_labels=true)
 Get the rail type for a given label.
void ResetRailTypes ()
 Reset all rail type information to its default values.
void InitRailTypes ()
 Resolve sprites of custom rail types.
RailType AllocateRailType (RailTypeLabel label)
 Allocate a new rail type label.

Variables

std::vector< RailType > _sorted_railtypes
 Sorted list of rail types.
RailTypes _railtypes_hidden_mask

Detailed Description

Rail specific functions.

Definition in file rail.h.

Typedef Documentation

◆ RailTypeFlags

Bitset of RailTypeFlag elements.

Definition at line 37 of file rail.h.

Enumeration Type Documentation

◆ RailFenceOffset

enum class RailFenceOffset : uint8_t
strong

Offsets from base sprite for fence sprites.

These are in the order of the sprites in the original data files.

Enumerator
FlatXNW 

Slope FLAT, Track X, Fence NW.

FlatYNE 

Slope FLAT, Track Y, Fence NE.

FlatLeft 

Slope FLAT, Track LEFT, Fence E.

FlatUpper 

Slope FLAT, Track UPPER, Fence S.

SlopeSWNW 

Slope SW, Track X, Fence NW.

SlopeSENE 

Slope SE, Track Y, Fence NE.

SlopeNENW 

Slope NE, Track X, Fence NW.

SlopeNWNE 

Slope NW, Track Y, Fence NE.

FlatXSE 

Slope FLAT, Track X, Fence SE.

FlatYSW 

Slope FLAT, Track Y, Fence SW.

FlatRight 

Slope FLAT, Track RIGHT, Fence W.

FlatLower 

Slope FLAT, Track LOWER, Fence N.

SlopeSWSE 

Slope SW, Track X, Fence SE.

SlopeSESW 

Slope SE, Track Y, Fence SW.

SlopeNESE 

Slope NE, Track X, Fence SE.

SlopeNWSW 

Slope NW, Track Y, Fence SW.

End 

End.

Definition at line 111 of file rail.h.

◆ RailSpriteType

enum class RailSpriteType : uint8_t
strong

Sprite types for a railtype.

Enumerator
UI 

Cursor and toolbar icon images.

Overlay 

Images for overlaying track.

Ground 

Main group of ground images.

Tunnel 

Main group of ground images for snow or desert.

Wires 

Catenary wires.

Pylons 

Catenary pylons.

Bridge 

Bridge surface images.

Crossing 

Level crossing overlay images.

Depot 

Depot images.

Fences 

Fence images.

TunnelPortal 

Tunnel portal overlay.

Signals 

Signal images.

GroundComplete 

Complete ground images.

End 

End marker.

Definition at line 42 of file rail.h.

◆ RailTrackBridgeOffset

enum class RailTrackBridgeOffset : uint8_t
strong

Offsets for sprites within a bridge surface overlay set.

Enumerator
X 

Piece of rail in X direction.

Y 

Piece of rail in Y direction.

Slope 

Sloped rail pieces, in order NE, SE, SW, NW.

Definition at line 93 of file rail.h.

◆ RailTrackOffset

enum class RailTrackOffset : uint8_t
strong

Offsets for sprites within an overlay/underlay set.

These are the same for overlay and underlay sprites.

Enumerator
X 

Piece of rail in X direction.

Y 

Piece of rail in Y direction.

N 

Piece of rail in northern corner.

S 

Piece of rail in southern corner.

E 

Piece of rail in eastern corner.

W 

Piece of rail in western corner.

SlopeNE 

Piece of rail on slope with north-east raised.

SlopeSE 

Piece of rail on slope with south-east raised.

SlopeSW 

Piece of rail on slope with south-west raised.

SlopeNW 

Piece of rail on slope with north-west raised.

CrossingXY 

Crossing of X and Y rail, with ballast.

JunctionSW 

Ballast for junction 'pointing' SW.

JunctionNE 

Ballast for junction 'pointing' NE.

JunctionSE 

Ballast for junction 'pointing' SE.

JunctionNW 

Ballast for junction 'pointing' NW.

JunctionNSEW 

Ballast for full junction.

Definition at line 63 of file rail.h.

◆ RailTypeFlag

enum class RailTypeFlag : uint8_t
strong

Railtype flag bit numbers.

Enumerator
Catenary 

Bit number for drawing a catenary.

NoLevelCrossing 

Bit number for disallowing level crossings.

Hidden 

Bit number for hiding from selection.

NoSpriteCombine 

Bit number for using non-combined junctions.

Allow90Deg 

Bit number for always allowed 90 degree turns, regardless of setting.

Disallow90Deg 

Bit number for never allowed 90 degree turns, regardless of setting.

Definition at line 27 of file rail.h.

Function Documentation

◆ AddDateIntroducedRailTypes()

RailTypes AddDateIntroducedRailTypes ( RailTypes current,
TimerGameCalendar::Date date )

Add the rail types that are to be introduced at the given date.

Parameters
currentThe currently available railtypes.
dateThe date for the introduction comparisons.
Returns
The rail types that should be available when date introduced rail types are taken into account as well.

Definition at line 104 of file rail.cpp.

References AddDateIntroducedRailTypes(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::All(), BaseLabel::Empty(), GetRailTypeInfo(), RailTypeInfo::introduces_railtypes, RailTypeInfo::introduction_date, RailTypeInfo::introduction_required_railtypes, IsInsideMM(), RailTypeInfo::label, TimerGameConst< struct Calendar >::MAX_DATE, RAILTYPE_END, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().

Referenced by AddDateIntroducedRailTypes(), GetCompanyRailTypes(), GetRailTypes(), and NewVehicleAvailable().

◆ AllocateRailType()

RailType AllocateRailType ( RailTypeLabel label)

Allocate a new rail type label.

Parameters
labelThe label of the rail type.
Returns
The allocated type, or INVALID_RAILTYPE upon failures.

Definition at line 149 of file rail_cmd.cpp.

References _original_railtypes, RailTypeInfo::alternate_labels, RailTypeInfo::compatible_railtypes, RailTypeInfo::Index(), RailTypeInfo::introduces_railtypes, INVALID_RAILTYPE, RailTypeInfo::label, RailTypeInfo::powered_railtypes, RAILTYPE_RAIL, and RailTypeInfo::sorting_order.

◆ DrawTrainDepotSprite()

void DrawTrainDepotSprite ( int x,
int y,
DiagDirection dir,
RailType railtype )

◆ GetAllCompatibleRailTypes()

RailTypes GetAllCompatibleRailTypes ( RailTypes railtypes)
inline

Returns all compatible railtypes for a set of railtypes.

Parameters
railtypesSet of railtypes to get the compatible railtypes from.
Returns
Union of all compatible railtypes.

Definition at line 332 of file rail.h.

References GetRailTypeInfo(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().

Referenced by CheckAutoreplaceValidity(), FollowTrainReservation(), FreeTrainTrackReservation(), IsCompatibleRail(), IsEngineBuildable(), and IsSafeWaitingPosition().

◆ GetAllIntroducesRailTypes()

RailTypes GetAllIntroducesRailTypes ( RailTypes railtypes)
inline

Returns all introduced railtypes for a set of railtypes.

Parameters
railtypesSet of railtypes to get the introduced railtypes from.
Returns
Union of all introduced railtypes.

Definition at line 356 of file rail.h.

References GetRailTypeInfo(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().

Referenced by GetCompanyRailTypes(), GetRailTypes(), and NewVehicleAvailable().

◆ GetAllPoweredRailTypes()

RailTypes GetAllPoweredRailTypes ( RailTypes railtypes)
inline

Returns all powered railtypes for a set of railtypes.

Parameters
railtypesSet of railtypes to get the powered railtypes from.
Returns
Union of all powered railtypes.

Definition at line 344 of file rail.h.

References GetRailTypeInfo(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().

Referenced by Train::ConsistChanged(), and HasPowerOnRail().

◆ GetCompanyRailTypes()

◆ GetRailFoundation()

◆ GetRailTypeByLabel()

RailType GetRailTypeByLabel ( RailTypeLabel label,
bool allow_alternate_labels )

Get the rail type for a given label.

Parameters
labelthe railtype label.
allow_alternate_labelsSearch in the alternate label lists as well.
Returns
the railtype.

Definition at line 197 of file rail.cpp.

References RailTypeInfo::alternate_labels, BaseLabel::Empty(), INVALID_RAILTYPE, RailTypeInfo::label, and RAILTYPE_END.

Referenced by AfterLoadGRFs(), ConvertRailTypes(), GetRailTypeTranslation(), and RailTypeChangeInfo().

◆ GetRailTypeInfo()

const RailTypeInfo * GetRailTypeInfo ( RailType railtype)
inline

Returns a pointer to the Railtype information for a given railtype.

Parameters
railtypethe rail type which the information is requested for
Returns
The pointer to the RailTypeInfo

Definition at line 320 of file rail.h.

References RAILTYPE_END.

Referenced by AddDateIntroducedRailTypes(), CompareRailTypes(), ConDumpRailTypes(), DrawBridgeMiddle(), DrawStationTile(), DrawTile_Rail(), DrawTile_Road(), DrawTile_Station(), DrawTile_TunnelBridge(), DrawTrackBits(), DrawTrainDepotSprite(), BuildSignalWindow::DrawWidget(), FinaliseEngineArray(), Train::GetAccelerationType(), GetAllCompatibleRailTypes(), GetAllIntroducesRailTypes(), GetAllPoweredRailTypes(), NIHRailType::GetBadges(), GetBridgeSpriteTableBaseOffset(), BuildRailToolbarWindow::GetCursorForWidget(), Train::GetCurveSpeedLimit(), GetEngineCategoryName(), GetGlobalVariable(), Train::GetMaxTrackSpeed(), GetNewEngine(), GetPylonBase(), GetRailTypeDropDownList(), GetRailTypeTranslation(), GetReverseRailTypeTranslation(), GetSmallMapRoutesPixels(), CFollowTrackT< TransportType::Water, Ship, true >::GetSpeedLimit(), GetTileDesc_Rail(), GetTileDesc_Road(), GetTileDesc_TunnelBridge(), GetTrainForReservation(), BuildRailToolbarWindow::GetWidgetString(), BuildVehicleWindow::GetWidgetString(), ReplaceVehicleWindow::GetWidgetString(), GetWireBase(), HasPowerOnRail(), HasRailCatenary(), IsCompatibleRail(), BuildRailToolbarWindow::OnInit(), BuildSignalWindow::OnInit(), Rail90DegTurnDisallowed(), RailBuildCost(), RailMaintenanceCost(), RailNoLevelCrossings(), ResetNewGRFData(), RAILChunkHandler::Save(), SetCurrentRailTypeLabelList(), CompanyInfrastructureWindow::UpdateWidgetSize(), and ReplaceVehicleWindow::UpdateWidgetSize().

◆ GetRailTypes()

◆ HasAnyRailTypesAvail()

bool HasAnyRailTypesAvail ( const CompanyID company)

Test if any buildable railtype is available for a company.

Parameters
companythe company in question
Returns
true if company has any RailTypes available

Definition at line 80 of file rail.cpp.

References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset().

Referenced by CanBuildVehicleInfrastructure().

◆ HasPowerOnRail() [1/2]

bool HasPowerOnRail ( RailType enginetype,
RailType tiletype )
inline

Checks if an engine of the given RailType got power on a tile with a given RailType.

This would normally just be an equality check, but for electric rails (which also support non-electric engines).

Parameters
enginetypeThe RailType of the engine we are considering.
tiletypeThe RailType of the tile we are considering.
Returns
Whether the engine got power on this tile.

Definition at line 396 of file rail.h.

References GetRailTypeInfo(), RailTypeInfo::powered_railtypes, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by CheckFlatLandRailStation(), CmdBuildRailVehicle(), CmdBuildSingleRail(), CmdConvertRail(), Train::GetPower(), Train::GetPoweredPartPower(), RailConvertCost(), and Vehicle::ShowVisualEffect().

◆ HasPowerOnRail() [2/2]

bool HasPowerOnRail ( RailTypes enginetype,
RailType tiletype )
inline

Checks if an engine of the given RailTypes got power on a tile with a given RailType.

Parameters
enginetypeThe RailTypes of the engine we are considering.
tiletypeThe RailType of the tile we are considering.
Returns
Whether the engine got power on this tile.

Definition at line 408 of file rail.h.

References GetAllPoweredRailTypes(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

◆ HasRailTypeAvail()

bool HasRailTypeAvail ( const CompanyID company,
const RailType railtype )

Finds out if a company has a certain buildable railtype available.

Parameters
companythe company in question
railtyperequested RailType
Returns
true if company has requested RailType available

Definition at line 70 of file rail.cpp.

Referenced by BuildRailToolbarWindow::ChangeRailTypeOnHotkey(), and ValParamRailType().

◆ InitRailTypes()

void InitRailTypes ( )

◆ IsCompatibleRail() [1/2]

bool IsCompatibleRail ( RailType enginetype,
RailType tiletype )
inline

Checks if an engine of the given RailType can drive on a tile with a given RailType.

This would normally just be an equality check, but for electric rails (which also support non-electric engines).

Parameters
enginetypeThe RailType of the engine we are considering.
tiletypeThe RailType of the tile we are considering.
Returns
Whether the engine can drive on this tile.

Definition at line 371 of file rail.h.

References RailTypeInfo::compatible_railtypes, GetRailTypeInfo(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by CmdBuildRailWagon(), CmdBuildSingleRail(), CmdConvertRail(), and IsCompatibleTrainStationTile().

◆ IsCompatibleRail() [2/2]

bool IsCompatibleRail ( RailTypes enginetype,
RailType tiletype )
inline

Checks if an engine of the given RailTypes can drive on a tile with a given RailType.

Parameters
enginetypeThe RailTypes of the engine we are considering.
tiletypeThe RailType of the tile we are considering.
Returns
Whether the engine can drive on this tile.

Definition at line 383 of file rail.h.

References GetAllCompatibleRailTypes(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

◆ operator+() [1/2]

SpriteID operator+ ( SpriteID sprite,
RailTrackBridgeOffset offset )
constexpr

Operator overload to allow RailTrackBridgeOffset to be added to a SpriteID without the need to use to_underlying.

Parameters
spriteThe SpriteID we want to add the RailTrackBridgeOffset to
offsetThe RailTrackBridgeOffset we want to add to the SpriteID
Returns
The value of the SpriteID after it has been added to the RailBridgeOffset

Definition at line 105 of file rail.h.

References to_underlying().

◆ operator+() [2/2]

SpriteID operator+ ( SpriteID sprite,
RailTrackOffset offset )
constexpr

Operator overload to allow RailTrackOffset to be added to a SpriteID without the need to use to_underlying.

Parameters
spriteThe SpriteID we want to add to the RailTrackOffset
offsetThe RailTrackOffset we want to add to the SpriteID
Returns
The value of the SpriteID after it has been added to the RailTrackOffset

Definition at line 88 of file rail.h.

References to_underlying().

◆ Rail90DegTurnDisallowed()

bool Rail90DegTurnDisallowed ( RailType rt1,
RailType rt2,
bool def = _settings_game.pf.forbid_90_deg )
inline

Test if 90 degree turns are disallowed between two railtypes.

Parameters
rt1First railtype to test for.
rt2Second railtype to test for.
defDefault value to use if the rail type doesn't specify anything.
Returns
True if 90 degree turns are disallowed between the two rail types.

Definition at line 430 of file rail.h.

References _settings_game, Allow90Deg, Disallow90Deg, RailTypeInfo::flags, GetRailTypeInfo(), INVALID_RAILTYPE, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by CheckNextTrainTile(), ExtendTrainReservation(), CFollowTrackT< TransportType::Water, Ship, true >::Follow(), IsSafeWaitingPosition(), IsWaitingPositionFree(), TrainCheckIfLineEnds(), TrainController(), and TryPathReserve().

◆ RailBuildCost()

Money RailBuildCost ( RailType railtype)
inline

Returns the cost of building the specified railtype.

Parameters
railtypeThe railtype being built.
Returns
The cost multiplier.

Definition at line 448 of file rail.h.

References _price, BuildRail, GetRailTypeInfo(), and RAILTYPE_END.

Referenced by CalculateRailStationCost(), CmdBuildBridge(), CmdBuildSingleRail(), CmdBuildTrainDepot(), CmdBuildTunnel(), GetRailTypeDropDownList(), RailClearCost(), RailConvertCost(), and ShowBuildBridgeWindow().

◆ RailClearCost()

Money RailClearCost ( RailType railtype)
inline

Returns the 'cost' of clearing the specified railtype.

Parameters
railtypeThe railtype being removed.
Returns
The cost.

Definition at line 459 of file rail.h.

References _price, ClearRail, RailBuildCost(), and RAILTYPE_END.

Referenced by CmdRemoveSingleRail(), RailConvertCost(), and TunnelBridgeClearCost().

◆ RailConvertCost()

Money RailConvertCost ( RailType from,
RailType to )
inline

Calculates the cost of rail conversion.

Parameters
fromThe railtype we are converting from
toThe railtype we are converting to
Returns
Cost per Track

Definition at line 476 of file rail.h.

References HasPowerOnRail(), RailBuildCost(), and RailClearCost().

Referenced by CmdConvertRail().

◆ RailMaintenanceCost()

Money RailMaintenanceCost ( RailType railtype,
uint32_t num,
uint32_t total_num )
inline

Calculates the maintenance cost of a number of track bits.

Parameters
railtypeThe railtype to get the cost of.
numNumber of track bits of this railtype.
total_numTotal number of track bits of all railtypes.
Returns
Total cost.

Definition at line 503 of file rail.h.

References _price, GetRailTypeInfo(), InfrastructureRail, IntSqrt(), and RAILTYPE_END.

Referenced by CompaniesGenStatistics().

◆ RailNoLevelCrossings()

bool RailNoLevelCrossings ( RailType rt)
inline

Test if a RailType disallows build of level crossings.

Parameters
rtThe RailType to check.
Returns
Whether level crossings are not allowed.

Definition at line 418 of file rail.h.

References RailTypeInfo::flags, GetRailTypeInfo(), NoLevelCrossing, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by CmdBuildRoad(), CmdBuildSingleRail(), and CmdConvertRail().

◆ ResetRailTypes()

void ResetRailTypes ( )

Reset all rail type information to its default values.

Definition at line 64 of file rail_cmd.cpp.

References _original_railtypes.

Referenced by ResetNewGRFData().

◆ SignalMaintenanceCost()

Money SignalMaintenanceCost ( uint32_t num)
inline

Calculates the maintenance cost of a number of signals.

Parameters
numNumber of signals.
Returns
Total cost.

Definition at line 514 of file rail.h.

References _price, InfrastructureRail, and IntSqrt().

Referenced by CompaniesGenStatistics().

◆ TicksToLeaveDepot()

int TicksToLeaveDepot ( const Train * v)

Compute number of ticks when next wagon will leave a depot.

Negative means next wagon should have left depot n ticks before.

Parameters
vvehicle outside (leaving) the depot
Returns
number of ticks when the next wagon will leave

Definition at line 3008 of file rail_cmd.cpp.

References _fractcoords_enter, Train::CalcNextVehicleOffset(), GetRailDepotDirection(), NE, NW, SE, SW, Vehicle::tile, TILE_UNIT_MASK, Vehicle::x_pos, and Vehicle::y_pos.

Referenced by AdvanceWagonsAfterSwap(), CheckTrainsLengths(), and FixupTrainLengths().

◆ ValParamRailType()

bool ValParamRailType ( const RailType rail)

Validate functions for rail building.

Parameters
railthe railtype to check.
Returns
true if the current company may build the rail.

Definition at line 92 of file rail.cpp.

References _current_company, HasRailTypeAvail(), and RAILTYPE_END.

Referenced by CmdBuildBridge(), CmdBuildRailStation(), CmdBuildSingleRail(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdConvertRail(), CmdRailTrackHelper(), BuildRailToolbarWindow::OnInvalidateData(), and ShowBuildRailToolbar().

Variable Documentation

◆ _railtypes_hidden_mask

RailTypes _railtypes_hidden_mask
extern

Definition at line 47 of file rail_cmd.cpp.

◆ _sorted_railtypes