OpenTTD Source  20241124-master-g9399a92a4f
newgrf_roadstop.h File Reference

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

#include "newgrf_animation_type.h"
#include "newgrf_spritegroup.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 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  RoadStopRandomTrigger {
  RSRT_NEW_CARGO , RSRT_CARGO_TAKEN , RSRT_VEH_ARRIVES , RSRT_VEH_DEPARTS ,
  RSRT_VEH_LOADS
}
 
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  RoadStopDrawMode : uint8_t { ROADSTOP_DRAW_MODE_NONE = 0 , ROADSTOP_DRAW_MODE_ROAD = 1 << 0 , ROADSTOP_DRAW_MODE_OVERLAY = 1 << 1 , ROADSTOP_DRAW_MODE_WAYP_GROUND = 1 << 2 }
 Different draw modes to disallow rendering of some parts of the stop or road. More...
 
enum  RoadStopSpecFlags {
  RSF_CB141_RANDOM_BITS = 0 , RSF_NO_CATENARY = 2 , RSF_DRIVE_THROUGH_ONLY = 3 , RSF_NO_AUTO_ROAD_CONNECTION = 4 ,
  RSF_BUILD_MENU_ROAD_ONLY = 5 , RSF_BUILD_MENU_TRAM_ONLY = 6 , RSF_DRAW_MODE_REGISTER = 8
}
 
enum  RoadStopView {
  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

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. More...
 
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)
 
void AnimateRoadStopTile (TileIndex tile)
 
uint8_t GetRoadStopTileAnimationSpeed (TileIndex tile)
 
void TriggerRoadStopAnimation (BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type=INVALID_CARGO)
 
void TriggerRoadStopRandomisation (Station *st, TileIndex tile, RoadStopRandomTrigger trigger, CargoID cargo_type=INVALID_CARGO)
 Trigger road stop randomisation. More...
 
bool GetIfNewStopsByType (RoadStopType rs, RoadType roadtype)
 Checks if there's any new stations by a specific RoadStopType. More...
 
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. More...
 
bool GetIfStopIsForType (const RoadStopSpec *roadstopspec, RoadStopType rs, RoadType roadtype)
 Checks if the given RoadStopSpec is compatible with the given RoadStopType. More...
 
const RoadStopSpecGetRoadStopSpec (TileIndex t)
 
int AllocateSpecToRoadStop (const RoadStopSpec *statspec, BaseStation *st, bool exec)
 
void DeallocateSpecFromRoadStop (BaseStation *st, uint8_t specindex)
 
void RoadStopUpdateCachedTriggers (BaseStation *st)
 Update the cached animation trigger bitmask for a station. More...
 
bool IsWaypointClass (const RoadStopClass &cls)
 Test if a RoadStopClass is the waypoint class. More...
 

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.

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 49 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 28 of file newgrf_roadstop.h.

◆ RoadStopDrawMode

enum RoadStopDrawMode : uint8_t

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

Enumerator
ROADSTOP_DRAW_MODE_ROAD 

Bay stops: Draw the road itself.

ROADSTOP_DRAW_MODE_OVERLAY 

Drive-through stops: Draw the road overlay, e.g. pavement.

ROADSTOP_DRAW_MODE_WAYP_GROUND 

Waypoints: Draw the sprite layout ground tile (on top of the road)

Definition at line 61 of file newgrf_roadstop.h.

◆ RoadStopRandomTrigger

Enumerator
RSRT_NEW_CARGO 

Trigger roadstop on arrival of new cargo.

RSRT_CARGO_TAKEN 

Trigger roadstop when cargo is completely taken.

RSRT_VEH_ARRIVES 

Trigger roadstop when road vehicle arrives.

RSRT_VEH_DEPARTS 

Trigger roadstop when road vehicle leaves.

RSRT_VEH_LOADS 

Trigger roadstop when road vehicle loads.

Definition at line 37 of file newgrf_roadstop.h.

◆ RoadStopSpecFlags

Enumerator
RSF_CB141_RANDOM_BITS 

Callback 141 needs random bits.

RSF_NO_CATENARY 

Do not show catenary.

RSF_DRIVE_THROUGH_ONLY 

Stop is drive-through only.

RSF_NO_AUTO_ROAD_CONNECTION 

No auto road connection.

RSF_BUILD_MENU_ROAD_ONLY 

Only show in the road build menu (not tram).

RSF_BUILD_MENU_TRAM_ONLY 

Only show in the tram build menu (not road).

RSF_DRAW_MODE_REGISTER 

Read draw mode from register 0x100.

Definition at line 69 of file newgrf_roadstop.h.

◆ RoadStopView

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 79 of file newgrf_roadstop.h.

Function Documentation

◆ 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
xposition x of image.
yposition y of image.
imagean int offset for the sprite.
roadtypethe RoadType of the underlying road.
specthe RoadStop's spec.
Returns
true of the tile was drawn (allows for fallback to default graphics)

Definition at line 281 of file newgrf_roadstop.cpp.

◆ 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
roadstopclassthe RoadStopClass to check.
rsthe RoadStopType to check.
roadtypethe RoadType to check.
Returns
true if the RoadStopSpec has any specs compatible with the given RoadStopType and RoadType.

Definition at line 500 of file newgrf_roadstop.cpp.

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

Referenced by GetIfNewStopsByType().

◆ GetIfNewStopsByType()

bool GetIfNewStopsByType ( RoadStopType  rs,
RoadType  roadtype 
)

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

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

Definition at line 481 of file newgrf_roadstop.cpp.

References NewGRFClass< Tspec, Tindex, Tmax >::Classes(), GetIfClassHasNewStopsByType(), 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
roadstopspecthe RoadStopSpec to check.
rsthe RoadStopType to check.
roadtypethe RoadType to check.
Returns
true if the RoadStopSpec is compatible with the given RoadStopType and RoadType.

Definition at line 515 of file newgrf_roadstop.cpp.

References HasBit(), and RSF_BUILD_MENU_ROAD_ONLY.

Referenced by GetIfClassHasNewStopsByType().

◆ IsWaypointClass()

◆ RoadStopUpdateCachedTriggers()

void RoadStopUpdateCachedTriggers ( BaseStation st)

Update the cached animation trigger bitmask for a station.

Parameters
stStation to update.

Definition at line 623 of file newgrf_roadstop.cpp.

References BaseStation::cached_roadstop_anim_triggers, and BaseStation::cached_roadstop_cargo_triggers.

◆ TriggerRoadStopRandomisation()

void TriggerRoadStopRandomisation ( Station st,
TileIndex  tile,
RoadStopRandomTrigger  trigger,
CargoID  cargo_type 
)

Trigger road stop randomisation.

Parameters
stthe station being triggered
tilethe exact tile of the station that should be triggered
triggertrigger type
cargo_typecargo type causing the trigger

Definition at line 408 of file newgrf_roadstop.cpp.

References BaseStation::cached_roadstop_cargo_triggers, SpecializedStation< Station, false >::GetByTile(), GetEmptyMask(), HasBit(), IsValidCargoID(), RSRT_CARGO_TAKEN, SetBit(), and BaseStation::waiting_triggers.