NewGRF Road Stops Addition to NewGRF Specifications in JGR's Patchpack

This document describes the non-standard addition of the NewGRF road stops feature to the Official OpenTTD NewGRF Specifications, as implemented in this patchpack.
This feature does not match OpenTTD PR #7955 in a number of key areas, this feature may not necessarily match implementations of NewGRF road stops in other patches, branches, etc.
This feature as implemented here MAY also be present in other patchpacks.

See the NewGRF additions document for background information on additions to the NewGRF specifications.

A subset of the functionality listed below is also supported in a fork of NML, see the associated NML road stops and NML additions documents for more details.

NewGRFs which use this feature SHOULD use the feature testing mechanism to check whether the road stop feature and/or feature ID mapping is supported.

NewGRFs which use this feature MUST use the feature ID mapping mechanism to map the non-standard NewGRF road stop feature to a local feature ID.

This feature is indicated by the feature name: road_stops, version 1.
The feature name to use for feature ID mapping is road_stops.
Features/properties/variables which require a higher version will indicate the required version. Unless indicated otherwise these will fall back to doing nothing on versions which do not support them.

Sections:

Action 0 - Road Stops

See the Action 0 Specification for background information.

Properties:
NumberMappable nameSize in bytesDescription
08roadstop_class_id4Class ID
09roadstop_stop_type1Stop type availability
0Aroadstop_stop_name2Name
0Broadstop_class_name2Class name
0Croadstop_draw_mode1Draw mode
0Droadstop_random_trigger_cargoes4Random trigger cargoes
0Eroadstop_animation_info2Animation info
0Froadstop_animation_speed1Animation speed
10roadstop_animation_triggers2Animation triggers
11roadstop_callback_mask1Callback flags
12roadstop_general_flags4General flags
13roadstop_min_bridge_height6Minimum bridge heights
14roadstop_disallowed_bridge_pillars6Disallowed bridge pillars
15roadstop_cost_multipliers2Cost multipliers
16roadstop_height1Height (for build window)

Road stop class ID (08, or mappable property: roadstop_class_id)

This property sets the road stop class ID for this road stop ID.
This property must be used first before any other property for this road stop ID.
Two class names are pre-defined:

NameClass IDMeaning
DFLT44 46 4C 54Default bus and lorry stops
WAYP57 41 59 50This class is used for road waypoints
All classes except WAYP are used for bus and/or lorry stops.
This functions the same way as station (feature 4) property 08.
The property length is 4 bytes.

Road stop type availability (09, or mappable property: roadstop_stop_type)

This property sets the road stop type availability, this is ignored for road stops in the WAYP class.
The property length is 1 byte. The format is:

ValueMeaning
0Passenger/bus stop
1Freight/lorry stop
2Both passenger/bus and freight/lorry stops
The default value is 2 (both bus and lorry stops).

Road stop name (0A, or mappable property: roadstop_stop_name)

This property sets the road stop name string ID.
The property length is 2 bytes. This should be a D8xx or DCxx string ID.

Road stop class name (0B, or mappable property: roadstop_class_name)

This property sets the road stop class name string ID.
The property length is 2 bytes. This should be a D8xx or DCxx string ID.

Road stop draw mode (0C, or mappable property: roadstop_draw_mode)

This property sets the road stop draw mode.
The property length is 1 byte. The format is:

BitValueMeaning
01Bay stops: Draw road type ground sprite
12Drive through stops: Draw road/tram type overlays
24Road waypoints: Draw sprite layout ground sprite on top of the underlying road (by default the sprite layout ground sprite is not used)
The default value is 3 (bits 0 and 1 both set).

Road stop random trigger cargoes (0D, or mappable property: roadstop_random_trigger_cargoes)

This property sets the cargo types for random triggers.
This functions the same way as station (feature 4) property 12.
This sets which cargo types should trigger re-randomizing. The cargo types are given as a bitmask of the bits from column 3 (type B) in CargoTypes. If nothing is set (the default), the no random triggers will happen, to conserve CPU time.
With GRF version 7 and above, the interpretation of bits changes. Instead of climate-dependent cargo slot numbers (type B), you have to set the bits of climate-independent cargo ID (type A).
The property length is 4 bytes.

Road stop animation info (0E, or mappable property: roadstop_animation_info)

This property sets the cargo types for random triggers.
This functions the same way as station (feature 4) property 16.
The low byte specifies the number of animation frames minus one, so 00 means 1 frame, 01 means 2 frames etc. The maximum number of frames is 256, although you can have some problems if your animation exceeds FD (253) frames. The high byte must be 0 for non-looping animations and 01 for looping animations. Every other value is reserved for future use. In addition, if the whole word contains FFFF, animation is turned off for this station (this is the default value). Since you can't have properties for individual station tiles, this property applies for every tile of the station. If you don't want to animate some tiles, you should check the current position during callback 140 and return FD if the current tile doesn't need to be animated. If you also need animations of different length per tile, you'll have to use callback 141 for that.
The property length is 2 bytes.

Road stop animation speed (0F, or mappable property: roadstop_animation_speed)

This property sets the cargo types for random triggers.
This functions the same way as station (feature 4) property 17.
This is the amount of time between switching frames. The default value is 2, which means the switch occurs every 108 milliseconds. Increasing this value by one doubles the wait, i.e. 3 will cause 216 ms delay, while 4 will pause 432 ms, and so on. The minimum is 0, which means the fastest possible animation, changing frames every game tick (27ms). The maximum is 16, which means 1769 seconds (approx. half an hour) delay. Settings above this value may cause strange behaviour.
The property length is 1 byte.

Road stop animation triggers (10, or mappable property: roadstop_animation_triggers)

This property sets the cargo types for random triggers.
This functions the same way as station (feature 4) property 18.
This is a bit mask of events that should trigger callback 140, allowing to change the animation state.

BitValueMeaningHappens onVar 18
01Road stop is builtnewly built tile
12New cargo arrives at stationall tilesBits 8..15 contain the triggering cargo type
24Cargo removed from stationall tilesBits 8..15 contain the triggering cargo type
38Road vehicle enters stop (starts loading/unloading)tile where the vehicle is
410Road vehicle leaves stop (done loading/unloading)tile where the vehicle is
520Road vehicle loads/unloads cargotile where the vehicle is
640Every 250 ticksall tiles
For bits 1 and 2: bits 8..15 of var 18 contain the triggering cargo type. If your GRF has a cargo translation table, the cargo type will be an index in that table, or FFh if the cargo isn't in the table. If you don't have a cargo translation table, the cargo type will simply be the climate-dependent cargo type number.

Road stop callback flags (11, or mappable property: roadstop_callback_mask)

This property enables callbacks for this road stop type.
The property length is 1 byte. The format is:

BitValueVariable 0C valueCallback
0113Whether to make road stop available in construction window (non-zero callback return) or not (callback returns zero)
12141Decide next animation frame
24142Decide animation speed
Variable 0C value is what variable 0C will be set to, for checking it in the VarAction2 for callbacks.
The default value is 0 (no callbacks enabled).

Road stop general flags (12, or mappable property: roadstop_general_flags)

This property sets general flags for this road stop type.
The property length is 4 bytes. The format is:

BitValueMeaning
01Callback 141 needs random bits in variable 10
12Do not show one way road overlay sprites, this should only be set if different graphics are provided for the different one-way states using bits 0..1 of variable 50.
24Do not show catenary graphics.
This requires road_stops, version 2.
38Only allow drive-through stops (not bay stops).
This requires road_stops, version 2.
410Do not automatically build connecting road pieces.
This requires road_stops, version 3.
520Only show in the road build menu (not tram).
This requires road_stops, version 4.
640Only show in the tram build menu (not road).
This requires road_stops, version 4.
780Use custom graphics for disabled road stop views.
This requires road_stops, version 8.
8100Read the road stop draw mode from variable 0x100, this overrides the roadstop_draw_mode property.
This requires road_stops, version 9.
The default value is 0 (no flags enabled).

Road stop minimum bridge heights (13, or mappable property: roadstop_min_bridge_height)

This property allows or disallows building bridges over road stops.
The bridge height property defines minimum clearances required for a bridge for each of the 6 views/rotations (or 0 to not allow any bridge). Values are given in height level units (1 level == 8px).
Each height value is 1 byte, the total property length is 6 bytes.

Road stop disallowed bridge pillars (14, or mappable property: roadstop_disallowed_bridge_pillars)

This property describes which bridge pillars are not allowed on the road stop tile.
It consists of a set of pillar flags, for each of the 6 road stop views/rotations.
Each set of flags is 1 byte, the total property length is 6 bytes.
Each set of flags has the format described in the bridge_pillar_flags property section.

Road stop cost multipliers (15, or mappable property: roadstop_cost_multipliers)

This property sets the build and removal cost multipliers.
The first byte is the build cost multiplier.
The second byte is the removal cost multiplier.
The total property length is 2 bytes.
A value of 16 produces a build or removal cost the same as non-NewGRF road stops..

Road stop height (in the build window) (16, or mappable property: roadstop_height)

This property sets the height used to size the road stop build window previews.
The nominal height for the road stop preview is set to at least: 32 + "value of this property" * 8.
This similar to Object variable 16.
The total property length is 1 byte.
This requires road_stops, version 6.

The 6 road stop views/rotations are described below.
Views/rotationTypeDescription
0BayFacing north-east
1BayFacing south-east
2BayFacing south-west
3BayFacing north-west
4Drive-throughX-axis: north-east to south-west
5Drive-throughY-axis: north-west to south-east


Action 2 - Road Stops

See the Action 2 Specification for background information.

Road stops use the special sprite layout format, the same as Action 2 features: 7 (house), 9 (industry tile), F (object), 11 (airport tile).


Variational Action 2 - Road Stops

See the Variational Action 2 Specification for background information.

The parent scope for this feature is the road stop's station's town.

Variables:
NumberMappable nameDescription
40roadstop_viewView/rotation
41roadstop_typeStop type
42roadstop_terrain_typeTerrain type
43roadstop_road_typeRoad type
44roadstop_tram_typeTram type
45roadstop_town_zoneTown zone and Manhattan distance of town
46roadstop_town_distance_squaredSquare of Euclidean distance of town
47roadstop_company_infoPlayer/company info
48Bitmask of accepted cargoes (BaseStation)
49roadstop_animation_frameCurrent animation frame
50roadstop_misc_infoMiscellaneous info
60Amount of cargo waiting (BaseStation)
61Time since last cargo pickup (BaseStation)
62Rating of cargo (BaseStation)
63Time spent on route (BaseStation)
64Information about last vehicle picking cargo up (BaseStation)
65Amount of cargo acceptance (BaseStation)
66roadstop_animation_frame_nearby_tilesAnimation frame of nearby tile
67roadstop_land_info_nearby_tilesLand info of nearby tiles
68roadstop_road_stop_info_nearby_tilesRoad stop info of nearby tiles
roadstop_road_stop_info_nearby_tiles_v2Road stop info of nearby tiles (v2)
69Information about cargo accepted in the past (BaseStation)
6Aroadstop_road_stop_grfid_nearby_tilesGRFID of nearby road stop tiles
6Broadstop_road_info_nearby_tilesRoad info of nearby plain road tiles

Road stop view/rotation (40, or mappable variable: roadstop_view)

Bits 0 - 7 have the range 0 - 5, see the 6 road stop views/rotations
The remaining bits are reserved for future use and should be masked.

Road stop type (41, or mappable variable: roadstop_type)

Bits 0 - 7 have the values in the table below.

ValueMeaning
0Passenger/bus stop
1Freight/lorry stop
2Road waypoint

The remaining bits are reserved for future use and should be masked.

Road stop tile terrain type (42, or mappable variable: roadstop_terrain_type)

This has the same value as bits 0 - 7 of object (feature F) variable 41.

ValueMeaning
0Normal
1Desert
2Rainforest
4On or above snowline

Road stop road type (43, or mappable variable: roadstop_road_type)

This has the value of the (translated) roadtype the road stop is built on, or the current roadtype in the build GUI. If the roadtype has no entry in the roadtype translation table of the GRF, this value will be 0xFF. If no translation table is present, the raw value will be returned. Note: only exact matches of roadtypes are reported. If the translation table of the GRF does not contain the exact roadtype 0xFF is returned.
If the tile has no road at all (tram only) 0xFFFFFFFF is returned.

Road stop tram type (44, or mappable variable: roadstop_road_type)

This has the value of the (translated) tramtype the road stop is built on, or the current tramtype in the build GUI. If the tramtype has no entry in the tramtype translation table of the GRF, this value will be 0xFF. If no translation table is present, the raw value will be returned. Note: only exact matches of tramtypes are reported. If the translation table of the GRF does not contain the exact tramtype 0xFF is returned.
If the tile has no tram at all (road only) 0xFFFFFFFF is returned.

Town zone and Manhattan distance of town (45, or mappable variable: roadstop_town_zone)

The town used is the one associated with the station/waypoint (this is in the station/waypoint name by default).

BitsMeaning
0 - 15Manhattan distance from town
16 - 24Town zone

The remaining bits are reserved for future use and should be masked.

Square of Euclidean distance of town (46, or mappable variable: roadstop_town_distance_squared)

The town used is the one associated with the station/waypoint (this is in the station/waypoint name by default).

Player/company info (47, or mappable variable: roadstop_company_info)

This has the same value as vehicle (features 0 - 3) variable 43.
The company used is the owner of the station/waypoint, not the owner of the underlying road and/or tram.

Current animation frame (49, or mappable variable: roadstop_animation_frame)

This has the same value as station (feature 4) variable 4A.

Miscellaneous road stop info (50, or mappable variable: roadstop_misc_info)

BitsMeaning
0 - 1 One-way road information:
0 - Two-way traffic
1 - West-bound only
2 - East-bound only
3 - No entry
2 - 3 Inferred one-way road information, from examining the road layout:
0 - Two-way traffic
1 - West-bound only
2 - East-bound only
3 - No entry
This requires road_stops, version 8.
4 1 if the road stop is being drawn in the build window
This requires road_stops, version 9.

The remaining bits are reserved for future use and should be masked.

Animation frame of nearby tile (66, or mappable variable: roadstop_animation_frame_nearby_tiles)

This has the same value as station (feature 4) variable 66.

Land info of nearby tile (67, or mappable variable: roadstop_land_info_nearby_tiles)

This has the same value as industry tile (feature 9) variable 60.

Road stop of nearby tile (68, or mappable variable: roadstop_road_stop_info_nearby_tiles)

This has a similar value to station (feature 4) variable 68.

BitsMeaning
0 - 7 If the tile is defined in the current GRF, this is the lower 8 bits of the setID used in the definition. Otherwise, the content is undefined.
Note that if this GRF has any road stop setIDs greater than 255, bits 24 - 31 need to be used as well.
8 - 9 0 - The tile uses original TTD graphics
1 - The tile is defined in the current GRF
2 - The tile is defined in another GRF
10Set if the selected tile belongs to the current station, clear otherwise
11Clear if the selected tile has the same view/rotation, set if a different view/rotation
12 - 15View/rotation of the selected tile
16 - 19 0 - Passenger/bus stop
1 - Freight/lorry stop
2 - Road waypoint
20Set if the stop type (passenger/bus, freight/lorry or road waypoint) is the same as the current tile
21 - 22 One-way road information of the selected tile:
0 - Two-way traffic
1 - North-bound only
2 - South-bound only
3 - No entry
24 - 31 If the tile is defined in the current GRF, this is the upper 8 bits of the setID used in the definition. Otherwise, the content is undefined.
This can be ignored if this GRF does not have any road stop setIDs greater than 255 (does not define more than 256 road stop types).
This requires road_stops, version 7.

The remaining bits are reserved for future use and should be masked.

Road stop of nearby tile v2 (mappable variable: roadstop_road_stop_info_nearby_tiles_v2)

This has a similar value to 68/roadstop_road_stop_info_nearby_tiles, above.

BitsMeaning
0 - 15If the tile is defined in the current GRF, this is the setID used in the definition. Otherwise, the content is undefined.
16 - 17 0 - The tile uses original TTD graphics
1 - The tile is defined in the current GRF
2 - The tile is defined in another GRF
18Set if the selected tile belongs to the current station, clear otherwise
19Clear if the selected tile has the same view/rotation, set if a different view/rotation
20 - 23View/rotation of the selected tile
24 - 27 0 - Passenger/bus stop
1 - Freight/lorry stop
2 - Road waypoint
28Set if the stop type (passenger/bus, freight/lorry or road waypoint) is the same as the current tile
29 - 30 One-way road information of the selected tile:
0 - Two-way traffic
1 - North-bound only
2 - South-bound only
3 - No entry

The remaining bits are reserved for future use and should be masked.
This requires road_stops, version 7.

GRFID of nearby road stop tile (6A, or mappable variable: roadstop_road_stop_grfid_nearby_tiles)

This has the same value as station (feature 4) variable 6A.

Road info of nearby plain road tiles (6B, or mappable variable: roadstop_road_info_nearby_tiles)

The returned value is 0xFFFFFFFF if the selected tile isn't a plain road tile.

BitsValueMeaning
001North-west road piece is present
102South-west road piece is present
204South-east road piece is present
308North-east road piece is present
410North-west tram piece is present
520South-west tram piece is present
640South-east tram piece is present
780North-east tram piece is present
8 - 15 Road piece and slope:
(Same order as road sprites).
0 - 18: As above
0xFF: No road present
16 - 23 Tram piece and slope:
(Same order as road sprites).
0 - 18: As above
0xFF: No tram present

The remaining bits are reserved for future use and should be masked.
This requires road_stops, version 5.


Random Action 2 - Road Stops

See the Random Action 2 Specification for background information.

Road stops have 16+8 random bits. Bits 0 to 15 are a property of the station as a whole, and bits 16 to 23 are different for each tile.

BitValueTrigger
001New cargo waiting
102No more cargo
204Road vehicle arrives (starts unloading/loading)
308Road vehicle leaves (done unloading & loading)
410Road vehicle loads or unloads cargo
Note that a road vehicle arrives trigger does not imply that the stop was previously empty, and a road vehicle leaves trigger does not imply that the stop is now empty.

Also note that none of the above triggers will actually trigger unless property 0D/roadstop_random_trigger_cargoes has at least one bit set.
Triggers 01 will be triggered for any of the cargo types set in property 0D/roadstop_random_trigger_cargoes, but trigger 02 will only be triggered if all of those cargo types have no more cargo waiting.
Triggers 04 and 08 are triggered no matter what cargo types the train transports, as long as property 0D/roadstop_random_trigger_cargoes is not zero.
Triggers 04, 08, and 10 only affect the tile on which they occur, as well as the random bits of the station, but not other tiles.


Action 3 - Road Stops

See the Action 3 Specification for background information.

Road stops have the same Action 3 cargo-type values as feature 4 (station).

In feature name road_stops version 7 and later, the Action 3 ID field is an extended byte; GRFs may define more than 255 road stop types.
In versions 1 to 6 (inclusive), only 255 road stop types may be defined per GRF, and the extended byte format may not be used.


Erata

In feature name road_stops versions 1 to 5 (inclusive), mapped Action 0 properties which are unknown and should be ignored, instead generate an error on use.