OpenTTD Source: src/newgrf_roadtype.h File Reference

OpenTTD Source 15.3

Data Structures | Functions
newgrf_roadtype.h File Reference

NewGRF handling of road types. More...

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

Go to the source code of this file.

## Data Structures
struct | RoadTypeScopeResolver
| Resolver for the railtype scope. More...
struct | RoadTypeResolverObject
| Resolver object for road types. More...

## Functions
SpriteID | GetCustomRoadSprite (const RoadTypeInfo *rti, TileIndex tile, RoadTypeSpriteGroup rtsg, TileContext context=TCX_NORMAL, uint *num_results=nullptr)
| Get the sprite to draw for the given tile.
RoadType | GetRoadTypeTranslation (RoadTramType rtt, uint8_t tracktype, const GRFFile *grffile)
| Translate an index to the GRF-local road/tramtype-translation table into a RoadType.
uint8_t | GetReverseRoadTypeTranslation (RoadType roadtype, const GRFFile *grffile)
| Perform a reverse roadtype lookup to get the GRF internal ID.
uint32_t | GetTrackTypes (TileIndex tile, const GRFFile *grffile)
| Variable 0x45 of road-/tram-/rail-types to query track types on a tile.
void | ConvertRoadTypes ()
| Test if any saved road type labels are different to the currently loaded road types.
void | SetCurrentRoadTypeLabelList ()
| Populate road type label list with current values.
void | ClearRoadTypeLabelList ()

## Detailed Description

NewGRF handling of road types.

Definition in file newgrf_roadtype.h.

## Function Documentation

## ◆ ClearRoadTypeLabelList()

void ClearRoadTypeLabelList | ( |  | ) |

Definition at line 278 of file newgrf_roadtype.cpp.

## ◆ ConvertRoadTypes()

void ConvertRoadTypes | ( |  | ) |

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

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

Definition at line 225 of file newgrf_roadtype.cpp.

References GetRoadTypeByLabel(), GetTileType(), GetTunnelBridgeTransportType(), INVALID_ROADTYPE, IsAnyRoadStop(), Map::Iterate(), MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, ROADTYPE_ROAD, ROADTYPE_TRAM, SetRoadTypeRoad(), SetRoadTypeTram(), and TRANSPORT_ROAD.

Referenced by AfterLoadLabelMaps().

## ◆ 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

  | rti | The road type data (spec).
  | tile | The tile to get the sprite for.
  | rtsg | The type of sprite to draw.
  | content | 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 149 of file newgrf_roadtype.cpp.

References RoadTypeInfo::group.

Referenced by DrawBridgeRoadBits(), DrawRoadBits(), DrawRoadDepotSprite(), DrawRoadOverlays(), DrawRoadStopTile(), DrawRoadTypeCatenary(), DrawTile_Road(), DrawTile_TunnelBridge(), and GetBridgeRoadCatenary().

## ◆ GetReverseRoadTypeTranslation()

uint8_t GetReverseRoadTypeTranslation | ( | RoadType | roadtype,
|  | const GRFFile * | grffile
| ) |  |

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

Parameters

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

Returns
  the GRF internal ID.

Definition at line 201 of file newgrf_roadtype.cpp.

References find_index(), GetRoadTypeInfo(), RoadTypeInfo::label, GRFFile::roadtype_list, and GRFFile::tramtype_list.

Referenced by GetTrackTypes(), RoadStopScopeResolver::GetVariable(), and RoadTypeScopeResolver::GetVariable().

## ◆ 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

  rtt | Whether to index the road- or tramtype-table.
  tracktype | Index into GRF-local translation table.
  grffile | Originating GRF file.

Returns
  RoadType or INVALID_ROADTYPE if the roadtype is unknown.

Definition at line 171 of file newgrf_roadtype.cpp.

References GetRoadTypeByLabel(), INVALID_ROADTYPE, GRFFile::roadtype_list, RTT_TRAM, and GRFFile::tramtype_list.

## ◆ GetTrackTypes()

uint32_t GetTrackTypes | ( | TileIndex | tile,
|  | const GRFFile * | grffile
| ) |  |

Variable 0x45 of road-/tram-/rail-types to query track types on a tile.

Format: __RRttrr

- rr: Translated roadtype.
- tt: Translated tramtype.
- RR: Translated railtype.

Special values for rr, tt, RR:

- 0xFF: Track not present on tile.
- 0xFE: Track present, but no matching entry in translation table.

Definition at line 34 of file newgrf_roadtype.cpp.

References GetReverseRailTypeTranslation(), GetReverseRoadTypeTranslation(), GetTileRailType(), INVALID_RAILTYPE, INVALID_ROADTYPE, and MayHaveRoad().

Referenced by RailTypeScopeResolver::GetVariable(), and RoadTypeScopeResolver::GetVariable().

## ◆ SetCurrentRoadTypeLabelList()

void SetCurrentRoadTypeLabelList | ( |  | ) |

Populate road type label list with current values.

Definition at line 270 of file newgrf_roadtype.cpp.

References GetRoadTypeInfo(), ROADTYPE_BEGIN, and ROADTYPE_END.

Referenced by AfterLoadLabelMaps(), and GenerateWorld().