OpenTTD Source  20241108-master-g80f628063a
newgrf_railtype.cpp File Reference

NewGRF handling of rail types. More...

#include "stdafx.h"
#include "core/container_func.hpp"
#include "debug.h"
#include "newgrf_railtype.h"
#include "timer/timer_game_calendar.h"
#include "depot_base.h"
#include "town.h"
#include "safeguards.h"

Go to the source code of this file.

Functions

SpriteID GetCustomRailSprite (const RailTypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context, uint *num_results)
 Get the sprite to draw for the given tile. More...
 
SpriteID GetCustomSignalSprite (const RailTypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui)
 Get the sprite to draw for a given signal. More...
 
RailType GetRailTypeTranslation (uint8_t railtype, const GRFFile *grffile)
 Translate an index to the GRF-local railtype-translation table into a RailType. More...
 
uint8_t GetReverseRailTypeTranslation (RailType railtype, const GRFFile *grffile)
 Perform a reverse railtype lookup to get the GRF internal ID. More...
 

Detailed Description

NewGRF handling of rail types.

Definition in file newgrf_railtype.cpp.

Function Documentation

◆ 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
rtiThe rail type data (spec).
tileThe tile to get the sprite for.
rtsgThe type of sprite to draw.
contextWhere are we drawing the tile?
[out]num_resultsIf not nullptr, return the number of sprites in the spriteset.
Returns
The sprite to draw.

Definition at line 96 of file newgrf_railtype.cpp.

Referenced by 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
rtiThe rail type data (spec).
tileThe tile to get the sprite for.
typeSignal type.
varSignal variant.
stateSignal state.
guiIs the sprite being used on the map or in the GUI?
Returns
The sprite to draw.

Definition at line 121 of file newgrf_railtype.cpp.

References RailTypeInfo::group, SpriteGroup::Resolve(), 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
railtypeIndex into GRF-local translation table.
grffileOriginating GRF file.
Returns
RailType or INVALID_RAILTYPE if the railtype is unknown.

Definition at line 141 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
railtypeThe global (OpenTTD) railtype.
grffileThe GRF to do the lookup for.
Returns
the GRF internal ID.

Definition at line 163 of file newgrf_railtype.cpp.

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