<h2>Additions to the NewGRF Road Stops Specification in JGR's Patchpack</h2>
<p>This document describes the non-standard additions to the NewGRF road stops feature in the <ahref="https://newgrf-specs.tt-wiki.net/wiki/Main_Page">Official OpenTTD NewGRF Specifications</a> (OpenTTD 14.0 and later), as implemented in this patchpack.</br>
The additions here are compatible with the specification and OpenTTD 14.0, such that GRFs can run on OpenTTD 14.0 and also optionally use patchpack extensions where available.</p>
<p>These additions and the official specification do not match the obsolete OpenTTD PR #7955 which used a different NewGRF interface.</p>
<p>The functionality listed below is also supported in a fork of NML, see the associated <ahref="newgrf-roadstops-nml.html">NML road stops</a> and <ahref="newgrf-additions-nml.html">NML additions</a> documents for more details.</p>
<p>NewGRFs which use this feature MAY use the <ahref="newgrf-additions.html#feature-test">feature testing</a> mechanism to check whether/which extensions to the road stop feature are supported.</p>
<p>NewGRFs which use this feature MAY use the <ahref="newgrf-additions.html#feature-id-mapping">feature ID mapping</a> mechanism to map the road stop feature to local feature ID 0x14 to additionally support earlier
versions of this patchpack before the feature was added to the specification, otherwise feature ID 0x14 may be used without any mapping (as per the specification).</p>
<p>These extensions are indicated by the feature name: <fontface="monospace">road_stops</font>, version 1.<br/>
The feature name to use for feature ID mapping is <fontface="monospace">road_stops</font>.<br/>
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.</p>
<tr><td><ahref="#roadstop_stop_type">09</a></td><td><ahref="#roadstop_stop_type">roadstop_stop_type</a></td><td>1</td><td>Stop type availability</td><td></td></tr>
<tr><td><ahref="#roadstop_min_bridge_height">13</a></td><td><ahref="#roadstop_min_bridge_height">roadstop_min_bridge_height</a></td><td>6</td><td>Minimum bridge heights</td><td>Not in spec</td></tr>
<tr><td><ahref="#roadstop_disallowed_bridge_pillars">14</a></td><td><ahref="#roadstop_disallowed_bridge_pillars">roadstop_disallowed_bridge_pillars</a></td><td>6</td><td>Disallowed bridge pillars</td><td>Not in spec</td></tr>
All classes except WAYP are used for bus and/or lorry stops.<br/>
This functions the same way as <ahref="https://newgrf-specs.tt-wiki.net/wiki/Action0/Stations#Station_class_.2808.29">station (feature 4) property 08</a>.<br/>
The property length is 4 bytes.
</p>
<h4id="roadstop_stop_type">Road stop type availability (09, or mappable property: roadstop_stop_type)</h4>
<p>This property sets the road stop type availability, this is ignored for road stops in the WAYP class.<br/>
The property length is 1 byte. The format is:
<table>
<tr><th>Value</th><th>Meaning</th></tr>
<tr><td>0</td><td>Passenger/bus stop</td></tr>
<tr><td>1</td><td>Freight/lorry stop</td></tr>
<tr><td>2</td><td>Both passenger/bus and freight/lorry stops</td></tr>
</table>
The default value is 2 (both bus and lorry stops).
</p>
<h4id="roadstop_stop_name">Road stop name (0A, or mappable property: roadstop_stop_name)</h4>
<p>This property sets the road stop name string ID.<br/>
The property length is 2 bytes. This should be a D8xx or DCxx string ID.</p>
<h4id="roadstop_class_name">Road stop class name (0B, or mappable property: roadstop_class_name)</h4>
<p>This property sets the road stop class name string ID.<br/>
The property length is 2 bytes. This should be a D8xx or DCxx string ID.</p>
<h4id="roadstop_draw_mode">Road stop draw mode (0C, or mappable property: roadstop_draw_mode)</h4>
<p>This property sets the road stop draw mode.<br/>
<h4id="roadstop_random_trigger_cargoes">Road stop random trigger cargoes (0D, or mappable property: roadstop_random_trigger_cargoes)</h4>
<p>This property sets the cargo types for random triggers.<br/>
This functions the same way as <ahref="https://newgrf-specs.tt-wiki.net/wiki/Action0/Stations#Cargo_types_for_random_triggers_.2812.29">station (feature 4) property 12</a>.<br/>
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.<br/>
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).<br/>
The property length is 4 bytes.</p>
<h4id="roadstop_animation_info">Road stop animation info (0E, or mappable property: roadstop_animation_info)</h4>
<p>This property sets the cargo types for random triggers.<br/>
This functions the same way as <ahref="https://newgrf-specs.tt-wiki.net/wiki/Action0/Stations#Animation_information_.2816.29">station (feature 4) property 16</a>.<br/>
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.<br/>
The property length is 2 bytes.</p>
<h4id="roadstop_animation_speed">Road stop animation speed (0F, or mappable property: roadstop_animation_speed)</h4>
<p>This property sets the cargo types for random triggers.<br/>
This functions the same way as <ahref="https://newgrf-specs.tt-wiki.net/wiki/Action0/Stations#Animation_speed_.2817.29">station (feature 4) property 17</a>.<br/>
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.<br/>
The property length is 1 byte.</p>
<h4id="roadstop_animation_triggers">Road stop animation triggers (10, or mappable property: roadstop_animation_triggers)</h4>
<p>This property sets the cargo types for random triggers.<br/>
This functions the same way as <ahref="https://newgrf-specs.tt-wiki.net/wiki/Action0/Stations#Animation_triggers_.2818.29">station (feature 4) property 18</a>.<br/>
This is a bit mask of events that should trigger callback 140, allowing to change the animation state.<br/>
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.</p>
<h4id="roadstop_callback_mask">Road stop callback flags (11, or mappable property: roadstop_callback_mask)</h4>
<p>This property enables callbacks for this road stop type.<br/>
<tr><td>0</td><td>1</td><td>13</td><td>Whether to make road stop available in construction window (non-zero callback return) or not (callback returns zero)</td></tr>
<tr><td>1</td><td>2</td><td>141</td><td>Decide next animation frame</td></tr>
<tr><td>1</td><td>2</td><td>Do 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.<br/>This is not in the specification.</td></tr>
<tr><td>5</td><td>20</td><td>Only show in the road build menu (not tram).</br>This requires <fontface="monospace">road_stops</font>, version 4.</td></tr>
<tr><td>6</td><td>40</td><td>Only show in the tram build menu (not road).</br>This requires <fontface="monospace">road_stops</font>, version 4.</td></tr>
<tr><td>7</td><td>80</td><td>Use custom graphics for disabled road stop views.</br>This requires <fontface="monospace">road_stops</font>, version 8.<br/>This is not in the specification.</td></tr>
<tr><td>8</td><td>100</td><td>Read the road stop draw mode from variable 0x100, this overrides the <ahref="#roadstop_draw_mode">roadstop_draw_mode</a> property.</br>This requires <fontface="monospace">road_stops</font>, version 9.<br/>This is not in the specification.</td></tr>
<h4id="roadstop_min_bridge_height">Road stop minimum bridge heights (13, or mappable property: roadstop_min_bridge_height)</h4>
<p>This property allows or disallows building bridges over road stops.<br/>
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).<br/>
<tr><td>4</td><td>Drive-through</td><td>X-axis: north-east to south-west</td></tr>
<tr><td>5</td><td>Drive-through</td><td>Y-axis: north-west to south-east</td></tr>
</table>
</p>
<br/>
<h3id="a2roadstops">Action 2 - Road Stops</h3>
<p>See the <ahref="https://newgrf-specs.tt-wiki.net/wiki/Action2">Action 2 Specification</a> for background information.</p>
<p>Road stops use the <ahref="https://newgrf-specs.tt-wiki.net/wiki/Action2/Sprite_Layout">special sprite layout format</a>, the same as Action 2 features: 7 (house), 9 (industry tile), F (object), 11 (airport tile).</p>
<tr><td><ahref="#roadstop_town_zone">45</a></td><td><ahref="#roadstop_town_zone">roadstop_town_zone</a></td><td>Town zone and Manhattan distance of town</td><td></td></tr>
<tr><td><ahref="#roadstop_town_distance_squared">46</a></td><td><ahref="#roadstop_town_distance_squared">roadstop_town_distance_squared</a></td><td>Square of Euclidean distance of town</td><td></td></tr>
<tr><td><ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/BaseStation">48</a></td><td></td><td>Bitmask of accepted cargoes (BaseStation)</td><td></td></tr>
<tr><td><ahref="#roadstop_misc_info">50</a></td><td><ahref="#roadstop_misc_info">roadstop_misc_info</a></td><td>Miscellaneous info</td><td>Not in spec</td></tr>
<tr><td><ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/BaseStation">60</a></td><td></td><td>Amount of cargo waiting (BaseStation)</td><td></td></tr>
<tr><td><ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/BaseStation">61</a></td><td></td><td>Time since last cargo pickup (BaseStation)</td><td></td></tr>
<tr><td><ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/BaseStation">62</a></td><td></td><td>Rating of cargo (BaseStation)</td><td></td></tr>
<tr><td><ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/BaseStation">63</a></td><td></td><td>Time spent on route (BaseStation)</td><td></td></tr>
<tr><td><ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/BaseStation">64</a></td><td></td><td>Information about last vehicle picking cargo up (BaseStation)</td><td></td></tr>
<tr><td><ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/BaseStation">65</a></td><td></td><td>Amount of cargo acceptance (BaseStation)</td><td></td></tr>
<tr><td><ahref="#roadstop_animation_frame_nearby_tiles">66</a></td><td><ahref="#roadstop_animation_frame_nearby_tiles">roadstop_animation_frame_nearby_tiles</a></td><td>Animation frame of nearby tile</td><td></td></tr>
<tr><td><ahref="#roadstop_land_info_nearby_tiles">67</a></td><td><ahref="#roadstop_land_info_nearby_tiles">roadstop_land_info_nearby_tiles</a></td><td>Land info of nearby tiles</td><td></td></tr>
<tr><td><ahref="#roadstop_road_stop_info_nearby_tiles">68</a></td><td><ahref="#roadstop_road_stop_info_nearby_tiles">roadstop_road_stop_info_nearby_tiles</a></td><td>Road stop info of nearby tiles</td><td>Road waypoint, bits 24 - 31</td></tr>
<tr><td></td><td><ahref="#roadstop_road_stop_info_nearby_tiles_v2">roadstop_road_stop_info_nearby_tiles_v2</a></td><td>Road stop info of nearby tiles (v2)</td><td>Not in spec</td></tr>
<tr><td><ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/BaseStation">69</a></td><td></td><td>Information about cargo accepted in the past (BaseStation)</td><td></td></tr>
<tr><td><ahref="#roadstop_road_stop_grfid_nearby_tiles">6A</a></td><td><ahref="#roadstop_road_stop_grfid_nearby_tiles">roadstop_road_stop_grfid_nearby_tiles</a></td><td>GRFID of nearby road stop tiles</td><td></td></tr>
<tr><td></td><td><ahref="#roadstop_road_info_nearby_tiles">roadstop_road_info_nearby_tiles</a></td><td>Road info of nearby plain road tiles</td><td>Not in spec</td></tr>
<p>This has the same value as bits 0 - 15 of <ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Objects#Tile_information_.2841.29">object (feature F) variable 41</a>.
<h4id="roadstop_road_type">Road stop road type (43, or mappable variable: roadstop_road_type)</h4>
<p>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.<br/>
If the tile has no road at all (tram only) 0xFFFFFFFF is returned.</p>
<h4id="roadstop_tram_type">Road stop tram type (44, or mappable variable: roadstop_road_type)</h4>
<p>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.<br/>
If the tile has no tram at all (road only) 0xFFFFFFFF is returned.</p>
<h4id="roadstop_town_zone">Town zone and Manhattan distance of town (45, or mappable variable: roadstop_town_zone)</h4>
<p>The town used is the one associated with the station/waypoint (this is in the station/waypoint name by default).
<table>
<tr><th>Bits</th><th>Meaning</th></tr>
<tr><td>0 - 15</td><td>Manhattan distance from town</td></tr>
<h4id="roadstop_town_distance_squared">Square of Euclidean distance of town (46, or mappable variable: roadstop_town_distance_squared)</h4>
<p>The town used is the one associated with the station/waypoint (this is in the station/waypoint name by default).</p>
<h4id="roadstop_company_info">Player/company info (47, or mappable variable: roadstop_company_info)</h4>
<p>This has the same value as <ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Vehicles#Player_info_.2843.29">vehicle (features 0 - 3) variable 43</a>.<br/>
The company used is the owner of the station/waypoint, not the owner of the underlying road and/or tram.</p>
<h4id="roadstop_animation_frame">Current animation frame (49, or mappable variable: roadstop_animation_frame)</h4>
<p>This has the same value as <ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Stations">station (feature 4) variable 4A</a>.</p>
<h4id="roadstop_animation_frame_nearby_tiles">Animation frame of nearby tile (66, or mappable variable: roadstop_animation_frame_nearby_tiles)</h4>
<p>This has the same value as <ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Stations#Animation_frame_of_nearby_tile_.2866.29">station (feature 4) variable 66</a>.</p>
<h4id="roadstop_land_info_nearby_tiles">Land info of nearby tile (67, or mappable variable: roadstop_land_info_nearby_tiles)</h4>
<p>This has the same value as <ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Industry_Tiles#Land_info_of_nearby_tiles_.2860.29">industry tile (feature 9) variable 60</a>.</p>
<p>This has a similar value to <ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Stations#Station_info_of_nearby_tiles_.2868.29">station (feature 4) variable 68</a>.<br/>
<p>This has a similar value to <ahref="#roadstop_road_stop_info_nearby_tiles">68</a>/<ahref="#roadstop_road_stop_info_nearby_tiles">roadstop_road_stop_info_nearby_tiles</a>, above.<br/>
<table>
<tr><th>Bits</th><th>Meaning</th></tr>
<tr><td>0 - 15</td><td>If the tile is defined in the current GRF, this is the setID used in the definition. Otherwise, the content is undefined. </td></tr>
<tr><td>16 - 17</td><td>
0 - The tile uses original TTD graphics<br/>
1 - The tile is defined in the current GRF<br/>
2 - The tile is defined in another GRF
</td></tr>
<tr><td>18</td><td>Set if the selected tile belongs to the current station, clear otherwise</td></tr>
<tr><td>19</td><td>Clear if the selected tile has the same view/rotation, set if a different view/rotation</td></tr>
<tr><td>20 - 23</td><td>View/rotation of the selected tile</td></tr>
<tr><td>24 - 27</td><td>
0 - Passenger/bus stop<br/>
1 - Freight/lorry stop<br/>
2 - Road waypoint
</td></tr>
<tr><td>28</td><td>Set if the stop type (passenger/bus, freight/lorry or road waypoint) is the same as the current tile</td></tr>
<tr><td>29 - 30</td><td>
One-way road information of the selected tile:<br/>
<h4id="roadstop_road_stop_grfid_nearby_tiles">GRFID of nearby road stop tile (6A, or mappable variable: roadstop_road_stop_grfid_nearby_tiles)</h4>
<p>This has the same value as <ahref="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Stations#GRFID_of_nearby_station_tile_.286A.29">station (feature 4) variable 6A</a>.</p>
<tr><td>3</td><td>08</td><td>Road vehicle leaves (done unloading & loading)</td></tr>
<tr><td>4</td><td>10</td><td>Road vehicle loads or unloads cargo</td></tr>
</table>
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.</p>
<p>
Also note that none of the above triggers will actually trigger unless <ahref="#roadstop_random_trigger_cargoes">property 0D/roadstop_random_trigger_cargoes</a> has at least one bit set.<br/>
Triggers 01 will be triggered for any of the cargo types set in <ahref="#roadstop_random_trigger_cargoes">property 0D/roadstop_random_trigger_cargoes</a>, but trigger 02 will only be triggered if all of those cargo types have no more cargo waiting.<br/>
Triggers 04 and 08 are triggered no matter what cargo types the train transports, as long as <ahref="#roadstop_random_trigger_cargoes">property 0D/roadstop_random_trigger_cargoes</a> is not zero.<br/>
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.
<p>In feature name <fontface="monospace">road_stops</font> version 7 and later, the Action 3 ID field is an extended byte; GRFs may define more than 255 road stop types.<br/>
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.</p>
<p>In feature name <fontface="monospace">road_stops</font> versions 1 to 5 (inclusive), mapped Action 0 properties which are unknown and should be ignored, instead generate an error on use.</p>