OpenTTD Source: src/newgrf_railtype.h File Reference

OpenTTD Source 15.0-RC2

Data Structures | Functions
newgrf_railtype.h File Reference

NewGRF handling of rail types. More...

`#include "rail.h"`
`#include "newgrf_commons.h"`
`#include "newgrf_spritegroup.h"`

Go to the source code of this file.

## Data Structures
struct | RailTypeScopeResolver
| Resolver for the railtype scope. More...
struct | RailTypeResolverObject
| Resolver object for rail types. More...

## Functions
SpriteID | GetCustomRailSprite (const RailTypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context=TCX_NORMAL, uint *num_results=nullptr)
| Get the sprite to draw for the given tile.
SpriteID | GetCustomSignalSprite (const RailTypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui=false)
| Get the sprite to draw for a given signal.
RailType | GetRailTypeTranslation (uint8_t railtype, const GRFFile *grffile)
| Translate an index to the GRF-local railtype-translation table into a RailType.
uint8_t | GetReverseRailTypeTranslation (RailType railtype, const GRFFile *grffile)
| Perform a reverse railtype lookup to get the GRF internal ID.
void | ConvertRailTypes ()
| Test if any saved rail type labels are different to the currently loaded rail types.
void | SetCurrentRailTypeLabelList ()
| Populate railtype label list with current values.
void | ClearRailTypeLabelList ()

## Detailed Description

NewGRF handling of rail types.

Definition in file newgrf_railtype.h.

## Function Documentation

## ◆ ClearRailTypeLabelList()

void ClearRailTypeLabelList | ( |  | ) |

Definition at line 253 of file newgrf_railtype.cpp.

## ◆ ConvertRailTypes()

void ConvertRailTypes | ( |  | ) |

Test if any saved rail type labels are different to the currently loaded rail types.

Rail types stored in the map will be converted if necessary.

Definition at line 194 of file newgrf_railtype.cpp.

References GetRailType(), GetRailTypeByLabel(), GetTileType(), GetTunnelBridgeTransportType(), HasStationRail(), INVALID_RAILTYPE, IsLevelCrossing(), Map::Iterate(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, RAILTYPE_RAIL, SetRailType(), and TRANSPORT_RAIL.

Referenced by AfterLoadLabelMaps().

## ◆ GetCustomRailSprite()

SpriteID GetCustomRailSprite | ( | const RailTypeInfo * | rti,
|  | TileIndex | tile,
|  | RailTypeSpriteGroup | rtsg,
|  | TileContext | context,
|  | uint * | num_results
| ) |  |

Get the sprite to draw for the given tile.

Parameters

  | rti | The rail type data (spec).
  | tile | The tile to get the sprite for.
  | rtsg | The type of sprite to draw.
  | context | Where are we drawing the tile?
  [out] | num_results | If not nullptr, return the number of sprites in the spriteset.

Returns
  The sprite to draw.

Definition at line 106 of file newgrf_railtype.cpp.

References RailTypeInfo::group.

Referenced by DrawBridgeMiddle(), DrawStationTile(), DrawTile_Road(), DrawTile_TunnelBridge(), DrawTrackDetails(), GetPylonBase(), and GetWireBase().

## ◆ GetCustomSignalSprite()

SpriteID GetCustomSignalSprite | ( | const RailTypeInfo * | rti,
|  | TileIndex | tile,
|  | SignalType | type,
|  | SignalVariant | var,
|  | SignalState | state,
|  | bool | gui
| ) |  |

Get the sprite to draw for a given signal.

Parameters

  rti | The rail type data (spec).
  tile | The tile to get the sprite for.
  type | Signal type.
  var | Signal variant.
  state | Signal state.
  gui | Is the sprite being used on the map or in the GUI?

Returns
  The sprite to draw.

Definition at line 131 of file newgrf_railtype.cpp.

References RailTypeInfo::group, RTSG_SIGNALS, and TCX_NORMAL.

## ◆ GetRailTypeTranslation()

RailType GetRailTypeTranslation | ( | uint8_t | railtype,
|  | const GRFFile * | grffile
| ) |  |

Translate an index to the GRF-local railtype-translation table into a RailType.

Parameters

  railtype | Index into GRF-local translation table.
  grffile | Originating GRF file.

Returns
  RailType or INVALID_RAILTYPE if the railtype is unknown.

Definition at line 151 of file newgrf_railtype.cpp.

References GetRailTypeByLabel(), GetRailTypeInfo(), INVALID_RAILTYPE, RAILTYPE_END, and GRFFile::railtype_list.

## ◆ GetReverseRailTypeTranslation()

uint8_t GetReverseRailTypeTranslation | ( | RailType | railtype,
|  | const GRFFile * | grffile
| ) |  |

Perform a reverse railtype lookup to get the GRF internal ID.

Parameters

  railtype | The global (OpenTTD) railtype.
  grffile | The GRF to do the lookup for.

Returns
  the GRF internal ID.

Definition at line 173 of file newgrf_railtype.cpp.

References find_index(), GetRailTypeInfo(), RailTypeInfo::label, and GRFFile::railtype_list.

Referenced by GetTrackTypes(), RailTypeScopeResolver::GetVariable(), and StationScopeResolver::GetVariable().

## ◆ SetCurrentRailTypeLabelList()

void SetCurrentRailTypeLabelList | ( |  | ) |

Populate railtype label list with current values.

Definition at line 244 of file newgrf_railtype.cpp.

References GetRailTypeInfo(), RAILTYPE_BEGIN, and RAILTYPE_END.

Referenced by AfterLoadLabelMaps(), and GenerateWorld().