OpenTTD Source: src/newgrf_roadstop.h File Reference

OpenTTD Source 15.0-RC2

Data Structures | Typedefs | Enumerations | Functions | Variables
newgrf_roadstop.h File Reference

NewGRF definitions and structures for road stops. More...

`#include "bridge_type.h"`
`#include "newgrf_animation_type.h"`
`#include "newgrf_spritegroup.h"`
`#include "newgrf_badge_type.h"`
`#include "newgrf_callbacks.h"`
`#include "newgrf_class.h"`
`#include "newgrf_commons.h"`
`#include "newgrf_town.h"`
`#include "road.h"`

Go to the source code of this file.

## Data Structures
struct | RoadStopScopeResolver
| Scope resolver for road stops. More...
struct | RoadStopResolverObject
| Road stop resolver. More...
struct | RoadStopSpec
| Road stop specification. More...

## Typedefs
using | RoadStopDrawModes = EnumBitSet< RoadStopDrawMode, uint8_t >
using | RoadStopSpecFlags = EnumBitSet< RoadStopSpecFlag, uint8_t >
using | RoadStopClass = NewGRFClass< RoadStopSpec, RoadStopClassID, ROADSTOP_CLASS_MAX >

## Enumerations
enum | RoadStopClassID : uint16_t { ROADSTOP_CLASS_BEGIN = 0 , ROADSTOP_CLASS_DFLT = 0 , ROADSTOP_CLASS_WAYP , ROADSTOP_CLASS_MAX = UINT16_MAX }
enum | RoadStopAvailabilityType : uint8_t { ROADSTOPTYPE_PASSENGER , ROADSTOPTYPE_FREIGHT , ROADSTOPTYPE_ALL , ROADSTOPTYPE_END }
| Various different options for availability, restricting the roadstop to be only for busses or for trucks. More...
enum class | RoadStopDrawMode : uint8_t { Road = 0 , Overlay = 1 , WaypGround = 2 }
| Different draw modes to disallow rendering of some parts of the stop or road. More...
enum class | RoadStopSpecFlag : uint8_t { Cb141RandomBits = 0 , NoCatenary = 2 , DriveThroughOnly = 3 , NoAutoRoadConnection = 4 , RoadOnly = 5 , TramOnly = 6 , DrawModeRegister = 8 }
enum | RoadStopView : uint8_t { RSV_BAY_NE = 0 , RSV_BAY_SE = 1 , RSV_BAY_SW = 2 , RSV_BAY_NW = 3 , RSV_DRIVE_THROUGH_X = 4 , RSV_DRIVE_THROUGH_Y = 5 }

## Functions
std::optional< SpriteLayoutProcessor > | GetRoadStopLayout (TileInfo *ti, const RoadStopSpec *spec, BaseStation *st, StationType type, int view, std::span< int32_t > regs100={})
void | DrawRoadStopTile (int x, int y, RoadType roadtype, const RoadStopSpec *spec, StationType type, int view)
| Draw representation of a road stop tile for GUI purposes.
uint16_t | GetRoadStopCallback (CallbackID callback, uint32_t param1, uint32_t param2, const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, RoadType roadtype, StationType type, uint8_t view, std::span< int32_t > regs100={})
void | AnimateRoadStopTile (TileIndex tile)
uint8_t | GetRoadStopTileAnimationSpeed (TileIndex tile)
void | TriggerRoadStopAnimation (BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoType cargo_type=INVALID_CARGO)
void | TriggerRoadStopRandomisation (BaseStation *st, TileIndex tile, StationRandomTrigger trigger, CargoType cargo_type=INVALID_CARGO)
| Trigger road stop randomisation.
bool | GetIfNewStopsByType (RoadStopType rs, RoadType roadtype)
| Checks if there's any new stations by a specific RoadStopType.
bool | GetIfClassHasNewStopsByType (const RoadStopClass *roadstopclass, RoadStopType rs, RoadType roadtype)
| Checks if the given RoadStopClass has any specs assigned to it, compatible with the given RoadStopType.
bool | GetIfStopIsForType (const RoadStopSpec *roadstopspec, RoadStopType rs, RoadType roadtype)
| Checks if the given RoadStopSpec is compatible with the given RoadStopType.
const RoadStopSpec * | GetRoadStopSpec (TileIndex t)
std::optional< uint8_t > | AllocateSpecToRoadStop (const RoadStopSpec *spec, BaseStation *st)
| Allocate a RoadStopSpec to a Station.
void | AssignSpecToRoadStop (const RoadStopSpec *spec, BaseStation *st, uint8_t specindex)
| Assign a previously allocated RoadStopSpec specindex to a Station.
void | DeallocateSpecFromRoadStop (BaseStation *st, uint8_t specindex)
| Deallocate a RoadStopSpec from a Station.
void | RoadStopUpdateCachedTriggers (BaseStation *st)
| Update the cached animation trigger bitmask for a station.
bool | IsWaypointClass (const RoadStopClass &cls)
| Test if a RoadStopClass is the waypoint class.

## Variables
static const int | NUM_ROADSTOPS_PER_GRF = UINT16_MAX - 1
| The maximum amount of roadstops a single GRF is allowed to add.
static const uint32_t | ROADSTOP_CLASS_LABEL_DEFAULT = 'DFLT'
static const uint32_t | ROADSTOP_CLASS_LABEL_WAYPOINT = 'WAYP'

## Detailed Description

NewGRF definitions and structures for road stops.

Definition in file newgrf_roadstop.h.

## Typedef Documentation

## ◆ RoadStopClass

using RoadStopClass = NewGRFClass<RoadStopSpec, RoadStopClassID, ROADSTOP_CLASS_MAX>

Definition at line 163 of file newgrf_roadstop.h.

## ◆ RoadStopDrawModes

using RoadStopDrawModes = EnumBitSet<RoadStopDrawMode, uint8_t>

Definition at line 62 of file newgrf_roadstop.h.

## ◆ RoadStopSpecFlags

using RoadStopSpecFlags = EnumBitSet<RoadStopSpecFlag, uint8_t>

Definition at line 73 of file newgrf_roadstop.h.

## Enumeration Type Documentation

## ◆ RoadStopAvailabilityType

enum RoadStopAvailabilityType : uint8_t

Various different options for availability, restricting the roadstop to be only for busses or for trucks.

Enumerator
ROADSTOPTYPE_PASSENGER | This RoadStop is for passenger (bus) stops.
ROADSTOPTYPE_FREIGHT | This RoadStop is for freight (truck) stops.
ROADSTOPTYPE_ALL | This RoadStop is for both types of station road stops.

Definition at line 45 of file newgrf_roadstop.h.

## ◆ RoadStopClassID

enum RoadStopClassID : uint16_t

Enumerator
ROADSTOP_CLASS_BEGIN | The lowest valid value.
ROADSTOP_CLASS_DFLT | Default road stop class.
ROADSTOP_CLASS_WAYP | Waypoint class.
ROADSTOP_CLASS_MAX | Maximum number of classes.

Definition at line 33 of file newgrf_roadstop.h.

## ◆ RoadStopDrawMode

enum class RoadStopDrawMode : uint8_t
| strong

Different draw modes to disallow rendering of some parts of the stop or road.

Enumerator
Road | Bay stops: Draw the road itself.
Overlay | Drive-through stops: Draw the road overlay, e.g. pavement.
WaypGround | Waypoints: Draw the sprite layout ground tile (on top of the road)

Definition at line 57 of file newgrf_roadstop.h.

## ◆ RoadStopSpecFlag

enum class RoadStopSpecFlag : uint8_t
| strong

Enumerator
Cb141RandomBits | Callback 141 needs random bits.
NoCatenary | Do not show catenary.
DriveThroughOnly | Stop is drive-through only.
NoAutoRoadConnection | No auto road connection.
RoadOnly | Only show in the road build menu (not tram).
TramOnly | Only show in the tram build menu (not road).
DrawModeRegister | Read draw mode from register 0x100.

Definition at line 64 of file newgrf_roadstop.h.

## ◆ RoadStopView

enum RoadStopView : uint8_t

Enumerator
RSV_BAY_NE | Bay road stop, facing Northeast.
RSV_BAY_SE | Bay road stop, facing Southeast.
RSV_BAY_SW | Bay road stop, facing Southwest.
RSV_BAY_NW | Bay road stop, facing Northwest.
RSV_DRIVE_THROUGH_X | Drive through road stop, X axis.
RSV_DRIVE_THROUGH_Y | Drive through road stop, Y axis.

Definition at line 75 of file newgrf_roadstop.h.

## Function Documentation

## ◆ AllocateSpecToRoadStop()

std::optional< uint8_t > AllocateSpecToRoadStop | ( | const RoadStopSpec * | spec,
|  | BaseStation * | st
| ) |  |

Allocate a RoadStopSpec to a Station.

This is called once per build operation.

Parameters

  spec | RoadStopSpec to allocate.
  st | Station to allocate it to.

Returns
  Index within the Station's road stop spec list, or std::nullopt if the allocation failed.

Definition at line 568 of file newgrf_roadstop.cpp.

References BaseStation::roadstop_speclist.

## ◆ AnimateRoadStopTile()

void AnimateRoadStopTile | ( | TileIndex | tile | ) |

Definition at line 373 of file newgrf_roadstop.cpp.

## ◆ AssignSpecToRoadStop()

void AssignSpecToRoadStop | ( | const RoadStopSpec * | spec,
|  | BaseStation * | st,
|  | uint8_t | specindex
| ) |  |

Assign a previously allocated RoadStopSpec specindex to a Station.

Parameters

  spec | RoadStopSpec to assign..
  st | Station to allocate it to.
  specindex | Spec index of allocation.

Definition at line 601 of file newgrf_roadstop.cpp.

References RoadStopSpec::grf_prop, GRFFilePropsBase::grfid, GRFFilePropsBase::local_id, and BaseStation::roadstop_speclist.

## ◆ DeallocateSpecFromRoadStop()

void DeallocateSpecFromRoadStop | ( | BaseStation * | st,
|  | uint8_t | specindex
| ) |  |

Deallocate a RoadStopSpec from a Station.

Called when removing a single roadstop tile.

Parameters

  st | Station to work with.
  specindex | Index of the custom roadstop within the Station's roadstop spec list.

Definition at line 618 of file newgrf_roadstop.cpp.

References BaseStation::cached_roadstop_anim_triggers, BaseStation::cached_roadstop_cargo_triggers, BaseStation::custom_roadstop_tile_data, GetCustomRoadStopSpecIndex(), and BaseStation::roadstop_speclist.

## ◆ DrawRoadStopTile()

void DrawRoadStopTile | ( | int | x,
|  | int | y,
|  | RoadType | roadtype,
|  | const RoadStopSpec * | spec,
|  | StationType | type,
|  | int | view
| ) |  |

Draw representation of a road stop tile for GUI purposes.

Parameters

  x | position x of image.
  y | position y of image.
  image | an int offset for the sprite.
  roadtype | the RoadType of the underlying road.
  spec | the RoadStop's spec.

Returns
  true of the tile was drawn (allows for fallback to default graphics)

Definition at line 282 of file newgrf_roadstop.cpp.

References _local_company, DrawCommonTileSeqInGUI(), DrawModeRegister, DrawSprite(), GB(), GetCompanyPalette(), GetCustomRoadSprite(), SpriteLayoutProcessor::GetLayout(), GetRoadTypeInfo(), GroundSpritePaletteTransform(), INVALID_ROADTYPE, INVALID_TILE, Overlay, TileLayoutSpriteGroup::ProcessRegisters(), Road, ROTSG_GROUND, ROTSG_OVERLAY, ROTSG_ROADSTOP, SPRITE_WIDTH, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and WaypGround.

## ◆ GetIfClassHasNewStopsByType()

bool GetIfClassHasNewStopsByType | ( | const RoadStopClass * | roadstopclass,
|  | RoadStopType | rs,
|  | RoadType | roadtype
| ) |  |

Checks if the given RoadStopClass has any specs assigned to it, compatible with the given RoadStopType.

Parameters

  roadstopclass | the RoadStopClass to check.
  rs | the RoadStopType to check.
  roadtype | the RoadType to check.

Returns
  true if the RoadStopSpec has any specs compatible with the given RoadStopType and RoadType.

Definition at line 513 of file newgrf_roadstop.cpp.

References NewGRFClass< Tspec, Tindex, Tmax >::Specs().

## ◆ GetIfNewStopsByType()

bool GetIfNewStopsByType | ( | RoadStopType | rs,
|  | RoadType | roadtype
| ) |  |

Checks if there's any new stations by a specific RoadStopType.

Parameters

  rs | the RoadStopType to check.
  roadtype | the RoadType to check.

Returns
  true if there was any new RoadStopSpec's found for the given RoadStopType and RoadType, else false.

Definition at line 494 of file newgrf_roadstop.cpp.

References NewGRFClass< Tspec, Tindex, Tmax >::Classes(), IsWaypointClass(), and ROADSTOP_CLASS_DFLT.

## ◆ GetIfStopIsForType()

bool GetIfStopIsForType | ( | const RoadStopSpec * | roadstopspec,
|  | RoadStopType | rs,
|  | RoadType | roadtype
| ) |  |

Checks if the given RoadStopSpec is compatible with the given RoadStopType.

Parameters

  roadstopspec | the RoadStopSpec to check.
  rs | the RoadStopType to check.
  roadtype | the RoadType to check.

Returns
  true if the RoadStopSpec is compatible with the given RoadStopType and RoadType.

Definition at line 528 of file newgrf_roadstop.cpp.

References Bus, RoadOnly, ROADSTOPTYPE_ALL, ROADSTOPTYPE_FREIGHT, ROADSTOPTYPE_PASSENGER, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TramOnly, and Truck.

## ◆ GetRoadStopCallback()

uint16_t GetRoadStopCallback | ( | CallbackID | callback,
|  | uint32_t | param1,
|  | uint32_t | param2,
|  | const RoadStopSpec * | roadstopspec,
|  | BaseStation * | st,
|  | TileIndex | tile,
|  | RoadType | roadtype,
|  | StationType | type,
|  | uint8_t | view,
|  | std::span< int32_t > | regs100 = `{}`
| ) |  |

Definition at line 267 of file newgrf_roadstop.cpp.

## ◆ GetRoadStopLayout()

std::optional< SpriteLayoutProcessor > GetRoadStopLayout | ( | TileInfo * | ti,
|  | const RoadStopSpec * | spec,
|  | BaseStation * | st,
|  | StationType | type,
|  | int | view,
|  | std::span< int32_t > | regs100 = `{}`
| ) |  |

Definition at line 342 of file newgrf_roadstop.cpp.

## ◆ GetRoadStopSpec()

const RoadStopSpec * GetRoadStopSpec | ( | TileIndex | t | ) |

Definition at line 553 of file newgrf_roadstop.cpp.

## ◆ IsWaypointClass()

bool IsWaypointClass | ( | const RoadStopClass & | cls | ) |
| inline

Test if a RoadStopClass is the waypoint class.

Parameters

  cls | RoadStopClass to test.

Returns
  true if the class is the waypoint class.

Definition at line 190 of file newgrf_roadstop.h.

References GB(), and NewGRFClass< Tspec, Tindex, Tmax >::global_id.

Referenced by CmdBuildRailStation(), CmdBuildRailWaypoint(), CmdBuildRoadStop(), CmdBuildRoadWaypoint(), StationPickerCallbacks::GetClassName(), WaypointPickerCallbacks::GetClassName(), RoadWaypointPickerCallbacks::GetClassName(), GetIfNewStopsByType(), StationPickerCallbacks::HasClassChoice(), WaypointPickerCallbacks::HasClassChoice(), RoadWaypointPickerCallbacks::HasClassChoice(), StationPickerCallbacks::IsActive(), WaypointPickerCallbacks::IsActive(), RoadStopPickerCallbacks< roadstoptype >::IsActive(), and RoadWaypointPickerCallbacks::IsActive().

## ◆ RoadStopUpdateCachedTriggers()

void RoadStopUpdateCachedTriggers | ( | BaseStation * | st | ) |

Update the cached animation trigger bitmask for a station.

Parameters

  st | Station to update.

Definition at line 659 of file newgrf_roadstop.cpp.

References BaseStation::cached_roadstop_anim_triggers, BaseStation::cached_roadstop_cargo_triggers, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().

## ◆ TriggerRoadStopAnimation()

void TriggerRoadStopAnimation | ( | BaseStation * | st,
|  | TileIndex | tile,
|  | StationAnimationTrigger | trigger,
|  | CargoType | cargo_type = `INVALID_CARGO`
| ) |  |

Definition at line 381 of file newgrf_roadstop.cpp.

## ◆ TriggerRoadStopRandomisation()

void TriggerRoadStopRandomisation | ( | BaseStation * | st,
|  | TileIndex | tile,
|  | StationRandomTrigger | trigger,
|  | CargoType | cargo_type
| ) |  |

Trigger road stop randomisation.

Parameters

  st | the station being triggered
  tile | the exact tile of the station that should be triggered
  trigger | trigger type
  cargo_type | cargo type causing the trigger

Definition at line 418 of file newgrf_roadstop.cpp.

References BaseStation::cached_roadstop_cargo_triggers, RoadStopSpec::cargo_triggers, CargoTaken, BaseStation::custom_roadstop_tile_data, SpecializedStation< Station, false >::From(), GetEmptyMask(), GetStationGfx(), GetStationType(), HasBit(), INVALID_ROADTYPE, IsValidCargoType(), MarkTileDirtyByTile(), NewCargo, Random, BaseStation::random_bits, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), and BaseStation::waiting_random_triggers.

## Variable Documentation

## ◆ NUM_ROADSTOPS_PER_GRF

const int NUM_ROADSTOPS_PER_GRF = UINT16_MAX - 1
| static

The maximum amount of roadstops a single GRF is allowed to add.

Definition at line 28 of file newgrf_roadstop.h.

## ◆ ROADSTOP_CLASS_LABEL_DEFAULT

const uint32_t ROADSTOP_CLASS_LABEL_DEFAULT = 'DFLT'
| static

Definition at line 30 of file newgrf_roadstop.h.

## ◆ ROADSTOP_CLASS_LABEL_WAYPOINT

const uint32_t ROADSTOP_CLASS_LABEL_WAYPOINT = 'WAYP'
| static

Definition at line 31 of file newgrf_roadstop.h.