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

NewGRF handling of road types. More...

#include "stdafx.h"
#include "core/container_func.hpp"
#include "debug.h"
#include "newgrf_roadtype.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 GetCustomRoadSprite (const RoadTypeInfo *rti, TileIndex tile, RoadTypeSpriteGroup rtsg, TileContext context, uint *num_results)
 Get the sprite to draw for the given tile. More...
 
RoadType GetRoadTypeTranslation (RoadTramType rtt, uint8_t tracktype, const GRFFile *grffile)
 Translate an index to the GRF-local road/tramtype-translation table into a RoadType. More...
 
uint8_t GetReverseRoadTypeTranslation (RoadType roadtype, const GRFFile *grffile)
 Perform a reverse roadtype lookup to get the GRF internal ID. More...
 

Detailed Description

NewGRF handling of road types.

Definition in file newgrf_roadtype.cpp.

Function Documentation

◆ GetCustomRoadSprite()

SpriteID GetCustomRoadSprite ( const RoadTypeInfo rti,
TileIndex  tile,
RoadTypeSpriteGroup  rtsg,
TileContext  context,
uint *  num_results 
)

Get the sprite to draw for the given tile.

Parameters
rtiThe road type data (spec).
tileThe tile to get the sprite for.
rtsgThe type of sprite to draw.
contentWhere 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 101 of file newgrf_roadtype.cpp.

Referenced by DrawRoadOverlays(), and GetBridgeRoadCatenary().

◆ GetReverseRoadTypeTranslation()

uint8_t GetReverseRoadTypeTranslation ( RoadType  roadtype,
const GRFFile grffile 
)

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

Parameters
roadtypeThe global (OpenTTD) roadtype.
grffileThe GRF to do the lookup for.
Returns
the GRF internal ID.

Definition at line 153 of file newgrf_roadtype.cpp.

◆ GetRoadTypeTranslation()

RoadType GetRoadTypeTranslation ( RoadTramType  rtt,
uint8_t  tracktype,
const GRFFile grffile 
)

Translate an index to the GRF-local road/tramtype-translation table into a RoadType.

Parameters
rttWhether to index the road- or tramtype-table.
tracktypeIndex into GRF-local translation table.
grffileOriginating GRF file.
Returns
RoadType or INVALID_ROADTYPE if the roadtype is unknown.

Definition at line 123 of file newgrf_roadtype.cpp.

References INVALID_ROADTYPE.