OpenTTD Source: RailTypeInfo Class Reference

OpenTTD Source 15.3

Public Member Functions | Data Fields
RailTypeInfo Class Reference

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

`#include <rail.h>`

## Public Member Functions
bool | UsesOverlay () const
uint | GetRailtypeSpriteOffset () const
| Offset between the current railtype and normal rail.
RailType | Index () const
| Get the RailType for this RailTypeInfo.

## Data Fields
struct { |
SpriteID track_y |
| single piece of rail in Y direction, with ground More...
SpriteID track_ns |
| two pieces of rail in North and South corner (East-West direction) More...
SpriteID ground |
| ground sprite for a 3-way switch More...
SpriteID single_x |
| single piece of rail in X direction, without ground More...
SpriteID single_y |
| single piece of rail in Y direction, without ground More...
SpriteID single_n |
| single piece of rail in the northern corner More...
SpriteID single_s |
| single piece of rail in the southern corner More...
SpriteID single_e |
| single piece of rail in the eastern corner More...
SpriteID single_w |
| single piece of rail in the western corner More...
SpriteID single_sloped |
| single piece of rail for slopes More...
SpriteID crossing |
| level crossing, rail in X direction More...
SpriteID tunnel |
| tunnel sprites base More...
SpriteID bridge_deck |
| bridge deck sprites base More...
} | base_sprites |
| Struct containing the main sprites.
struct { |
SpriteID build_ns_rail |
| button for building single rail in N-S direction More...
SpriteID build_x_rail |
| button for building single rail in X direction More...
SpriteID build_ew_rail |
| button for building single rail in E-W direction More...
SpriteID build_y_rail |
| button for building single rail in Y direction More...
SpriteID auto_rail |
| button for the autorail construction More...
SpriteID build_depot |
| button for building depots More...
SpriteID build_tunnel |
| button for building a tunnel More...
SpriteID convert_rail |
| button for converting rail More...
SpriteID signals [SIGTYPE_END][2][2] |
| signal GUI sprites (type, variant, state) More...
} | gui_sprites |
| struct containing the sprites for the rail GUI.
struct { |
CursorID rail_ns |
| Cursor for building rail in N-S direction. More...
CursorID rail_swne |
| Cursor for building rail in X direction. More...
CursorID rail_ew |
| Cursor for building rail in E-W direction. More...
CursorID rail_nwse |
| Cursor for building rail in Y direction. More...
CursorID autorail |
| Cursor for autorail tool. More...
CursorID depot |
| Cursor for building a depot. More...
CursorID tunnel |
| Cursor for building a tunnel. More...
CursorID convert |
| Cursor for converting track. More...
} | cursor |
| Cursors associated with the rail type.
struct { |
StringID name |
| Name of this rail type. More...
StringID toolbar_caption |
| Caption in the construction toolbar GUI for this rail type. More...
StringID menu_text |
| Name of this rail type in the main toolbar dropdown. More...
StringID build_caption |
| Caption of the build vehicle GUI for this rail type. More...
StringID replace_text |
| Text used in the autoreplace GUI. More...
StringID new_loco |
| Name of an engine for this type of rail in the engine preview GUI. More...
} | strings |
| Strings associated with the rail type.
SpriteID | snow_offset
| sprite number difference between a piece of track on a snowy ground and the corresponding one on normal ground
RailTypes | powered_railtypes
| bitmask to the OTHER railtypes on which an engine of THIS railtype generates power
RailTypes | compatible_railtypes
| bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel
uint8_t | bridge_offset
| Bridge offset.
uint8_t | fallback_railtype
| Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations.
uint8_t | curve_speed
| Multiplier for curve maximum speed advantage.
RailTypeFlags | flags
| Bit mask of rail type flags.
uint16_t | cost_multiplier
| Cost multiplier for building this rail type.
uint16_t | maintenance_multiplier
| Cost multiplier for maintenance of this rail type.
VehicleAccelerationModel | acceleration_type
| Acceleration type of this rail type.
uint16_t | max_speed
| Maximum speed for vehicles travelling on this rail type.
RailTypeLabel | label
| Unique 32 bit rail type identifier.
FlatSet< RailTypeLabel > | alternate_labels
| Rail type labels this type provides in addition to the main label.
PixelColour | map_colour
| Colour on mini-map.
TimerGameCalendar::Date | introduction_date
| Introduction date.
RailTypes | introduction_required_railtypes
| Bitmask of railtypes that are required for this railtype to be introduced at a given introduction_date.
RailTypes | introduces_railtypes
| Bitmask of which other railtypes are introduced when this railtype is introduced.
uint8_t | sorting_order
| The sorting order of this railtype for the toolbar dropdown.
const GRFFile * | grffile [RTSG_END]
| NewGRF providing the Action3 for the railtype.
const SpriteGroup * | group [RTSG_END]
| Sprite groups for resolving sprites.
std::vector< BadgeID > | badges

## Detailed Description

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

Definition at line 115 of file rail.h.

## Member Function Documentation

## ◆ GetRailtypeSpriteOffset()

uint RailTypeInfo::GetRailtypeSpriteOffset | ( |  | ) | const
| inline

Offset between the current railtype and normal rail.

This means that:

1) All the sprites in a railset MUST be in the same order. This order is determined by normal rail. Check sprites 1005 and following for this order

2) The position where the railtype is loaded must always be the same, otherwise the offset will fail.

Definition at line 286 of file rail.h.

References fallback_railtype.

Referenced by DrawStationTile().

## ◆ Index()

RailType RailTypeInfo::Index | ( |  | ) | const

Get the RailType for this RailTypeInfo.

Returns
  RailType in static RailTypeInfo definitions.

Definition at line 26 of file rail.cpp.

References RAILTYPE_END.

Referenced by AllocateRailType(), RailTypeScopeResolver::GetVariable(), and InitRailTypes().

## ◆ UsesOverlay()

bool RailTypeInfo::UsesOverlay | ( |  | ) | const
| inline

Definition at line 274 of file rail.h.

## Field Documentation

## ◆ acceleration_type

VehicleAccelerationModel RailTypeInfo::acceleration_type

Acceleration type of this rail type.

Definition at line 215 of file rail.h.

Referenced by Train::GetAccelerationType(), and RailTypeChangeInfo().

## ◆ alternate_labels

FlatSet<RailTypeLabel> RailTypeInfo::alternate_labels

Rail type labels this type provides in addition to the main label.

Definition at line 230 of file rail.h.

Referenced by AllocateRailType(), and GetRailTypeByLabel().

## ◆ auto_rail

SpriteID RailTypeInfo::auto_rail

button for the autorail construction

Definition at line 146 of file rail.h.

Referenced by BuildRailToolbarWindow::OnInit().

## ◆ autorail

CursorID RailTypeInfo::autorail

Cursor for autorail tool.

Definition at line 158 of file rail.h.

Referenced by BuildRailToolbarWindow::OnClick().

## ◆ badges

std::vector<BadgeID> RailTypeInfo::badges

Definition at line 272 of file rail.h.

## ◆ [struct]

struct { ... } RailTypeInfo::base_sprites

Struct containing the main sprites.

Note
  not all sprites are listed, but only the ones used directly in the code

Referenced by DrawBridgeMiddle(), DrawTile_Road(), DrawTile_TunnelBridge(), and DrawTrackBits().

## ◆ bridge_deck

SpriteID RailTypeInfo::bridge_deck

bridge deck sprites base

Definition at line 134 of file rail.h.

Referenced by DrawBridgeMiddle(), and DrawTile_TunnelBridge().

## ◆ bridge_offset

uint8_t RailTypeInfo::bridge_offset

Bridge offset.

Definition at line 185 of file rail.h.

Referenced by GetBridgeSpriteTableBaseOffset().

## ◆ build_caption

StringID RailTypeInfo::build_caption

Caption of the build vehicle GUI for this rail type.

Definition at line 168 of file rail.h.

Referenced by BuildVehicleWindow::GetWidgetString(), and RailTypeChangeInfo().

## ◆ build_depot

SpriteID RailTypeInfo::build_depot

button for building depots

Definition at line 147 of file rail.h.

Referenced by BuildRailToolbarWindow::OnInit().

## ◆ build_ew_rail

SpriteID RailTypeInfo::build_ew_rail

button for building single rail in E-W direction

Definition at line 144 of file rail.h.

Referenced by BuildRailToolbarWindow::OnInit().

## ◆ build_ns_rail

SpriteID RailTypeInfo::build_ns_rail

button for building single rail in N-S direction

Definition at line 142 of file rail.h.

Referenced by BuildRailToolbarWindow::OnInit().

## ◆ build_tunnel

SpriteID RailTypeInfo::build_tunnel

button for building a tunnel

Definition at line 148 of file rail.h.

Referenced by BuildRailToolbarWindow::OnInit().

## ◆ build_x_rail

SpriteID RailTypeInfo::build_x_rail

button for building single rail in X direction

Definition at line 143 of file rail.h.

Referenced by GetRailTypeDropDownList(), and BuildRailToolbarWindow::OnInit().

## ◆ build_y_rail

SpriteID RailTypeInfo::build_y_rail

button for building single rail in Y direction

Definition at line 145 of file rail.h.

Referenced by BuildRailToolbarWindow::OnInit().

## ◆ compatible_railtypes

RailTypes RailTypeInfo::compatible_railtypes

bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel

Definition at line 180 of file rail.h.

Referenced by AllocateRailType(), GetAllCompatibleRailTypes(), GetTrainForReservation(), IsCompatibleRail(), and RailTypeChangeInfo().

## ◆ convert

CursorID RailTypeInfo::convert

Cursor for converting track.

Definition at line 161 of file rail.h.

Referenced by BuildRailToolbarWindow::OnClick().

## ◆ convert_rail

SpriteID RailTypeInfo::convert_rail

button for converting rail

Definition at line 149 of file rail.h.

Referenced by BuildRailToolbarWindow::OnInit().

## ◆ cost_multiplier

uint16_t RailTypeInfo::cost_multiplier

Cost multiplier for building this rail type.

Definition at line 205 of file rail.h.

Referenced by ParamSet(), and RailTypeChangeInfo().

## ◆ crossing

SpriteID RailTypeInfo::crossing

level crossing, rail in X direction

Definition at line 132 of file rail.h.

Referenced by DrawTile_Road().

## ◆ curve_speed

uint8_t RailTypeInfo::curve_speed

Multiplier for curve maximum speed advantage.

Definition at line 195 of file rail.h.

Referenced by Train::GetCurveSpeedLimit(), and RailTypeChangeInfo().

## ◆ depot

CursorID RailTypeInfo::depot

Cursor for building a depot.

Definition at line 159 of file rail.h.

Referenced by BuildRailToolbarWindow::OnClick().

## ◆ fallback_railtype

uint8_t RailTypeInfo::fallback_railtype

Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations.

Definition at line 190 of file rail.h.

Referenced by DrawStationTile(), GetRailtypeSpriteOffset(), and RailTypeChangeInfo().

## ◆ flags

RailTypeFlags RailTypeInfo::flags

Bit mask of rail type flags.

Definition at line 200 of file rail.h.

Referenced by HasRailCatenary(), InitRailTypes(), Rail90DegTurnDisallowed(), RailNoLevelCrossings(), and RailTypeChangeInfo().

## ◆ grffile

const GRFFile* RailTypeInfo::grffile[RTSG_END]

NewGRF providing the Action3 for the railtype.

nullptr if not available.

Definition at line 265 of file rail.h.

## ◆ ground

SpriteID RailTypeInfo::ground

ground sprite for a 3-way switch

Definition at line 124 of file rail.h.

Referenced by DrawTrackBits().

## ◆ group

const SpriteGroup* RailTypeInfo::group[RTSG_END]

Sprite groups for resolving sprites.

Definition at line 270 of file rail.h.

Referenced by GetCustomRailSprite(), GetCustomSignalSprite(), and RailTypeResolverObject::RailTypeResolverObject().

## ◆ [struct]

struct { ... } RailTypeInfo::gui_sprites

struct containing the sprites for the rail GUI.

Note
  only sprites referred to directly in the code are listed

Referenced by BuildSignalWindow::DrawWidget(), GetRailTypeDropDownList(), BuildRailToolbarWindow::OnInit(), and BuildSignalWindow::OnInit().

## ◆ introduces_railtypes

RailTypes RailTypeInfo::introduces_railtypes

Bitmask of which other railtypes are introduced when this railtype is introduced.

Definition at line 255 of file rail.h.

Referenced by AddDateIntroducedRailTypes(), AllocateRailType(), GetAllIntroducesRailTypes(), and RailTypeChangeInfo().

## ◆ introduction_date

TimerGameCalendar::Date RailTypeInfo::introduction_date

Introduction date.

When #INVALID_DATE or a vehicle using this railtype gets introduced earlier, the vehicle's introduction date will be used instead for this railtype. The introduction at this date is furthermore limited by the introduction_required_railtypes.

Definition at line 244 of file rail.h.

Referenced by AddDateIntroducedRailTypes(), GetRailTypeDropDownList(), and RailTypeChangeInfo().

## ◆ introduction_required_railtypes

RailTypes RailTypeInfo::introduction_required_railtypes

Bitmask of railtypes that are required for this railtype to be introduced at a given introduction_date.

Definition at line 250 of file rail.h.

Referenced by AddDateIntroducedRailTypes(), and RailTypeChangeInfo().

## ◆ label

RailTypeLabel RailTypeInfo::label

Unique 32 bit rail type identifier.

Definition at line 225 of file rail.h.

Referenced by AddDateIntroducedRailTypes(), AllocateRailType(), RailTypeResolverObject::GetDebugID(), GetNewEngine(), GetRailTypeByLabel(), GetReverseRailTypeTranslation(), InitRailTypes(), ResetNewGRFData(), and RAILChunkHandler::Save().

## ◆ maintenance_multiplier

uint16_t RailTypeInfo::maintenance_multiplier

Cost multiplier for maintenance of this rail type.

Definition at line 210 of file rail.h.

Referenced by RailTypeChangeInfo().

## ◆ map_colour

PixelColour RailTypeInfo::map_colour

Colour on mini-map.

Definition at line 235 of file rail.h.

Referenced by RailTypeChangeInfo().

## ◆ max_speed

uint16_t RailTypeInfo::max_speed

Maximum speed for vehicles travelling on this rail type.

Definition at line 220 of file rail.h.

Referenced by Train::GetMaxTrackSpeed(), GetRailTypeDropDownList(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSpeedLimit(), BuildRailToolbarWindow::GetWidgetString(), and RailTypeChangeInfo().

## ◆ menu_text

StringID RailTypeInfo::menu_text

Name of this rail type in the main toolbar dropdown.

Definition at line 167 of file rail.h.

Referenced by GetRailTypeDropDownList(), and RailTypeChangeInfo().

## ◆ name

StringID RailTypeInfo::name

Name of this rail type.

Definition at line 165 of file rail.h.

Referenced by RailTypeChangeInfo(), and CompanyInfrastructureWindow::UpdateWidgetSize().

## ◆ new_loco

StringID RailTypeInfo::new_loco

Name of an engine for this type of rail in the engine preview GUI.

Definition at line 170 of file rail.h.

Referenced by GetEngineCategoryName(), and RailTypeChangeInfo().

## ◆ powered_railtypes

RailTypes RailTypeInfo::powered_railtypes

bitmask to the OTHER railtypes on which an engine of THIS railtype generates power

Definition at line 177 of file rail.h.

Referenced by AllocateRailType(), GetAllPoweredRailTypes(), HasPowerOnRail(), and RailTypeChangeInfo().

## ◆ rail_ew

CursorID RailTypeInfo::rail_ew

Cursor for building rail in E-W direction.

Definition at line 156 of file rail.h.

Referenced by BuildRailToolbarWindow::OnClick().

## ◆ rail_ns

CursorID RailTypeInfo::rail_ns

Cursor for building rail in N-S direction.

Definition at line 154 of file rail.h.

Referenced by BuildRailToolbarWindow::OnClick().

## ◆ rail_nwse

CursorID RailTypeInfo::rail_nwse

Cursor for building rail in Y direction.

Definition at line 157 of file rail.h.

Referenced by BuildRailToolbarWindow::OnClick().

## ◆ rail_swne

CursorID RailTypeInfo::rail_swne

Cursor for building rail in X direction.

Definition at line 155 of file rail.h.

Referenced by BuildRailToolbarWindow::OnClick().

## ◆ replace_text

StringID RailTypeInfo::replace_text

Text used in the autoreplace GUI.

Definition at line 169 of file rail.h.

Referenced by GetRailTypeDropDownList(), ReplaceVehicleWindow::GetWidgetString(), RailTypeChangeInfo(), and ReplaceVehicleWindow::UpdateWidgetSize().

## ◆ signals

SpriteID RailTypeInfo::signals[SIGTYPE_END][2][2]

signal GUI sprites (type, variant, state)

Definition at line 150 of file rail.h.

Referenced by BuildSignalWindow::DrawWidget(), and BuildSignalWindow::OnInit().

## ◆ single_e

SpriteID RailTypeInfo::single_e

single piece of rail in the eastern corner

Definition at line 129 of file rail.h.

Referenced by DrawTrackBits().

## ◆ single_n

SpriteID RailTypeInfo::single_n

single piece of rail in the northern corner

Definition at line 127 of file rail.h.

Referenced by DrawTrackBits().

## ◆ single_s

SpriteID RailTypeInfo::single_s

single piece of rail in the southern corner

Definition at line 128 of file rail.h.

Referenced by DrawTrackBits().

## ◆ single_sloped

SpriteID RailTypeInfo::single_sloped

single piece of rail for slopes

Definition at line 131 of file rail.h.

Referenced by DrawTile_TunnelBridge(), and DrawTrackBits().

## ◆ single_w

SpriteID RailTypeInfo::single_w

single piece of rail in the western corner

Definition at line 130 of file rail.h.

Referenced by DrawTrackBits().

## ◆ single_x

SpriteID RailTypeInfo::single_x

single piece of rail in X direction, without ground

Definition at line 125 of file rail.h.

Referenced by DrawBridgeMiddle(), DrawTile_Road(), DrawTile_TunnelBridge(), and DrawTrackBits().

## ◆ single_y

SpriteID RailTypeInfo::single_y

single piece of rail in Y direction, without ground

Definition at line 126 of file rail.h.

Referenced by DrawBridgeMiddle(), DrawTile_Road(), DrawTile_TunnelBridge(), and DrawTrackBits().

## ◆ snow_offset

SpriteID RailTypeInfo::snow_offset

sprite number difference between a piece of track on a snowy ground and the corresponding one on normal ground

Definition at line 174 of file rail.h.

Referenced by DrawTrackBits().

## ◆ sorting_order

uint8_t RailTypeInfo::sorting_order

The sorting order of this railtype for the toolbar dropdown.

Definition at line 260 of file rail.h.

Referenced by AllocateRailType(), CompareRailTypes(), and RailTypeChangeInfo().

## ◆ toolbar_caption

StringID RailTypeInfo::toolbar_caption

Caption in the construction toolbar GUI for this rail type.

Definition at line 166 of file rail.h.

Referenced by BuildRailToolbarWindow::GetWidgetString(), and RailTypeChangeInfo().

## ◆ track_ns

SpriteID RailTypeInfo::track_ns

two pieces of rail in North and South corner (East-West direction)

Definition at line 123 of file rail.h.

Referenced by DrawTrackBits().

## ◆ track_y

SpriteID RailTypeInfo::track_y

single piece of rail in Y direction, with ground

Definition at line 122 of file rail.h.

Referenced by DrawTrackBits().

## ◆ tunnel [1/2]

SpriteID RailTypeInfo::tunnel

tunnel sprites base

Definition at line 133 of file rail.h.

Referenced by DrawTile_TunnelBridge(), and BuildRailToolbarWindow::OnClick().

## ◆ tunnel [2/2]

CursorID RailTypeInfo::tunnel

Cursor for building a tunnel.

Definition at line 160 of file rail.h.

The documentation for this class was generated from the following files:

- src/rail.h
- src/rail.cpp