GRF: Add road stops variable for road info of nearby plain road tile

See: #464
This commit is contained in:
Jonathan G Rennison
2022-12-24 18:52:57 +00:00
parent 6b8f799a1c
commit 8af4ac8a4c
6 changed files with 61 additions and 2 deletions

View File

@@ -165,6 +165,12 @@
<tr><td>nearby_tile_one_way_info</td><td>x, y offset (-8..7)</td><td>RST_OWI_XXX</td><td>One-way state of nearby drive-through road stop tile</td></tr> <tr><td>nearby_tile_one_way_info</td><td>x, y offset (-8..7)</td><td>RST_OWI_XXX</td><td>One-way state of nearby drive-through road stop tile</td></tr>
<tr><td>nearby_tile_road_stop_info</td><td>x, y offset (-8..7)</td><td></td><td>Above nearby road stop tile variables in one variable (all of variable 0x68)</td></tr> <tr><td>nearby_tile_road_stop_info</td><td>x, y offset (-8..7)</td><td></td><td>Above nearby road stop tile variables in one variable (all of variable 0x68)</td></tr>
<tr><td>nearby_tile_grfid</td><td>x, y offset (-8..7)</td><td>-1, 0 or a GRFID</td><td>Return value is -1 if the tile is not a road stop, 0 if the tile is a non-custom road stop, or else the GRFID of the NewGRF defining the road stop</td></tr> <tr><td>nearby_tile_grfid</td><td>x, y offset (-8..7)</td><td>-1, 0 or a GRFID</td><td>Return value is -1 if the tile is not a road stop, 0 if the tile is a non-custom road stop, or else the GRFID of the NewGRF defining the road stop</td></tr>
<tr><td>nearby_tile_is_plain_road</td><td>x, y offset (-8..7)</td><td>0 | 1</td><td>Is nearby tile a plain road tile</td></tr>
<tr><td>nearby_tile_road_bits</td><td>x, y offset (-8..7)</td><td>bitmask(ROADBIT_XXX, ...)</td><td>XXX = [NW | SW | SE | NE]<br />Present road bits on nearby tile</td></tr>
<tr><td>nearby_tile_tram_bits</td><td>x, y offset (-8..7)</td><td>bitmask(ROADBIT_XXX, ...)</td><td>XXX = [NW | SW | SE | NE]<br />Present tram bits on nearby tile</td></tr>
<tr><td>nearby_tile_road_piece</td><td>x, y offset (-8..7)</td><td>0..18 | 0xFF</td><td>Present road piece and slope in <a href="https://newgrf-specs.tt-wiki.net/wiki/Action3/Roadtypes#Road_underlay_.2802.29">sprite order</a>, or 0xFF if none</td></tr>
<tr><td>nearby_tile_tram_piece</td><td>x, y offset (-8..7)</td><td>0..18 | 0xFF</td><td>Present tram piece and slope in <a href="https://newgrf-specs.tt-wiki.net/wiki/Action3/Roadtypes#Road_underlay_.2802.29">sprite order</a>, or 0xFF if none</td></tr>
<tr><td>nearby_tile_road_stop_info</td><td>x, y offset (-8..7)</td><td></td><td>Above nearby road tile variables in one variable (all of variable 0x6B)</td></tr>
</table> </table>
<h3 id="roadstop_callbacks">Road Stop Callbacks</h3> <h3 id="roadstop_callbacks">Road Stop Callbacks</h3>

View File

@@ -228,6 +228,7 @@
<tr><td><a href="#roadstop_road_stop_info_nearby_tiles">68</a></td><td><a href="#roadstop_road_stop_info_nearby_tiles">roadstop_road_stop_info_nearby_tiles</a></td><td>Road stop info of nearby tiles</td></tr> <tr><td><a href="#roadstop_road_stop_info_nearby_tiles">68</a></td><td><a href="#roadstop_road_stop_info_nearby_tiles">roadstop_road_stop_info_nearby_tiles</a></td><td>Road stop info of nearby tiles</td></tr>
<tr><td><a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/BaseStation">69</a></td><td></td><td>Information about cargo accepted in the past (BaseStation)</td></tr> <tr><td><a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/BaseStation">69</a></td><td></td><td>Information about cargo accepted in the past (BaseStation)</td></tr>
<tr><td><a href="#roadstop_road_stop_grfid_nearby_tiles">6A</a></td><td><a href="#roadstop_road_stop_grfid_nearby_tiles">roadstop_road_stop_grfid_nearby_tiles</a></td><td>GRFID of nearby road stop tiles</td></tr> <tr><td><a href="#roadstop_road_stop_grfid_nearby_tiles">6A</a></td><td><a href="#roadstop_road_stop_grfid_nearby_tiles">roadstop_road_stop_grfid_nearby_tiles</a></td><td>GRFID of nearby road stop tiles</td></tr>
<tr><td><a href="#roadstop_road_info_nearby_tiles">6B</a></td><td><a href="#roadstop_road_info_nearby_tiles">roadstop_road_info_nearby_tiles</a></td><td>Road info of nearby plain road tiles</td></tr>
</table> </table>
<h4 id="roadstop_view">Road stop view/rotation (40, or mappable variable: roadstop_view)</h4> <h4 id="roadstop_view">Road stop view/rotation (40, or mappable variable: roadstop_view)</h4>
@@ -342,6 +343,39 @@
<h4 id="roadstop_road_stop_grfid_nearby_tiles">GRFID of nearby road stop tile (6A, or mappable variable: roadstop_road_stop_grfid_nearby_tiles)</h4> <h4 id="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 <a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Stations#GRFID_of_nearby_station_tile_.286A.29">station (feature 4) variable 6A</a>.</p> <p>This has the same value as <a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Stations#GRFID_of_nearby_station_tile_.286A.29">station (feature 4) variable 6A</a>.</p>
<h4 id="roadstop_road_info_nearby_tiles">Road info of nearby plain road tiles (6B, or mappable variable: roadstop_road_info_nearby_tiles)</h4>
The returned value is 0xFFFFFFFF if the selected tile isn't a plain road tile.<br /><br />
<table>
<tr><th>Bits</th><th>Value</th><th>Meaning</th></tr>
<tr><td>0</td><td>01</td><td>North-west road piece is present</td></tr>
<tr><td>1</td><td>02</td><td>South-west road piece is present</td></tr>
<tr><td>2</td><td>04</td><td>South-east road piece is present</td></tr>
<tr><td>3</td><td>08</td><td>North-east road piece is present</td></tr>
<tr><td>4</td><td>10</td><td>North-west tram piece is present</td></tr>
<tr><td>5</td><td>20</td><td>South-west tram piece is present</td></tr>
<tr><td>6</td><td>40</td><td>South-east tram piece is present</td></tr>
<tr><td>7</td><td>80</td><td>North-east tram piece is present</td></tr>
<tr><td>8 - 15</td><td></td><td>
Road piece and slope:<br />
(Same order as <a href="https://newgrf-specs.tt-wiki.net/wiki/Action3/Roadtypes#Road_underlay_.2802.29">road sprites</a>).<br />
0 - 18: As above<br />
0xFF: No road present
</td></tr>
<tr><td>16 - 23</td><td></td><td>
Tram piece and slope:<br />
(Same order as <a href="https://newgrf-specs.tt-wiki.net/wiki/Action3/Roadtypes#Road_underlay_.2802.29">road sprites</a>).<br />
0 - 18: As above<br />
0xFF: No tram present
</td></tr>
</table>
<br />
The remaining bits are reserved for future use and should be masked.
<br />
This requires <font face="monospace">road_stops</font>, version 5.
</p>
<br /> <br />
<h3 id="randomaction2roadstops">Random Action 2 - Road Stops</h3> <h3 id="randomaction2roadstops">Random Action 2 - Road Stops</h3>

View File

@@ -55,7 +55,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = {
GRFFeatureInfo("action0_object_edge_foundation_mode", 2), GRFFeatureInfo("action0_object_edge_foundation_mode", 2),
GRFFeatureInfo("action0_object_flood_resistant", 1), GRFFeatureInfo("action0_object_flood_resistant", 1),
GRFFeatureInfo("action0_object_viewport_map_tile_type", 1), GRFFeatureInfo("action0_object_viewport_map_tile_type", 1),
GRFFeatureInfo("road_stops", 4), GRFFeatureInfo("road_stops", 5),
GRFFeatureInfo("new_landscape", 2), GRFFeatureInfo("new_landscape", 2),
GRFFeatureInfo(), GRFFeatureInfo(),
}; };
@@ -147,6 +147,7 @@ extern const GRFVariableMapDefinition _grf_action2_remappable_variables[] = {
GRFVariableMapDefinition(GSF_ROADSTOPS, 0x67, "roadstop_land_info_nearby_tiles"), GRFVariableMapDefinition(GSF_ROADSTOPS, 0x67, "roadstop_land_info_nearby_tiles"),
GRFVariableMapDefinition(GSF_ROADSTOPS, 0x68, "roadstop_road_stop_info_nearby_tiles"), GRFVariableMapDefinition(GSF_ROADSTOPS, 0x68, "roadstop_road_stop_info_nearby_tiles"),
GRFVariableMapDefinition(GSF_ROADSTOPS, 0x6A, "roadstop_road_stop_grfid_nearby_tiles"), GRFVariableMapDefinition(GSF_ROADSTOPS, 0x6A, "roadstop_road_stop_grfid_nearby_tiles"),
GRFVariableMapDefinition(GSF_ROADSTOPS, 0x6B, "roadstop_road_info_nearby_tiles"),
GRFVariableMapDefinition(GSF_RAILTYPES, A2VRI_RAILTYPE_SIGNAL_RESTRICTION_INFO, "railtype_signal_restriction_info"), GRFVariableMapDefinition(GSF_RAILTYPES, A2VRI_RAILTYPE_SIGNAL_RESTRICTION_INFO, "railtype_signal_restriction_info"),
GRFVariableMapDefinition(GSF_RAILTYPES, A2VRI_RAILTYPE_SIGNAL_CONTEXT, "railtype_signal_context"), GRFVariableMapDefinition(GSF_RAILTYPES, A2VRI_RAILTYPE_SIGNAL_CONTEXT, "railtype_signal_context"),
GRFVariableMapDefinition(GSF_SIGNALS, A2VRI_SIGNALS_SIGNAL_RESTRICTION_INFO, "signals_signal_restriction_info"), GRFVariableMapDefinition(GSF_SIGNALS, A2VRI_SIGNALS_SIGNAL_RESTRICTION_INFO, "signals_signal_restriction_info"),

View File

@@ -187,6 +187,23 @@ uint32 RoadStopScopeResolver::GetVariable(uint16 variable, uint32 parameter, Get
return ssl.grfid; return ssl.grfid;
} }
/* Road info of nearby tiles */
case 0x6B: {
if (this->tile == INVALID_TILE) return 0xFFFFFFFF;
TileIndex nearby_tile = GetNearbyTile(parameter, this->tile);
if (!IsNormalRoadTile(nearby_tile)) return 0xFFFFFFFF;
RoadBits road = GetRoadBits(nearby_tile, RTT_ROAD);
RoadBits tram = GetRoadBits(nearby_tile, RTT_TRAM);
Slope tileh = GetTileSlope(nearby_tile);
extern uint GetRoadSpriteOffset(Slope slope, RoadBits bits);
uint road_offset = (road == 0) ? 0xFF : GetRoadSpriteOffset(tileh, road);
uint tram_offset = (tram == 0) ? 0xFF : GetRoadSpriteOffset(tileh, tram);
return (tram_offset << 16) | (road_offset << 8) | (tram << 4) | (road);
}
case 0xF0: return this->st == nullptr ? 0 : this->st->facilities; // facilities case 0xF0: return this->st == nullptr ? 0 : this->st->facilities; // facilities
case 0xFA: return Clamp((this->st == nullptr ? _date : this->st->build_date) - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // build date case 0xFA: return Clamp((this->st == nullptr ? _date : this->st->build_date) - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // build date

View File

@@ -1866,7 +1866,7 @@ const byte _road_sloped_sprites[14] = {
* @param bits Roadbits * @param bits Roadbits
* @return Offset for the sprite within the spritegroup. * @return Offset for the sprite within the spritegroup.
*/ */
static uint GetRoadSpriteOffset(Slope slope, RoadBits bits) uint GetRoadSpriteOffset(Slope slope, RoadBits bits)
{ {
if (slope != SLOPE_FLAT) { if (slope != SLOPE_FLAT) {
switch (slope) { switch (slope) {

View File

@@ -1701,6 +1701,7 @@ static const NIVariable _nif_roadstops[] = {
NIV(0x68, "road stop info of nearby tiles"), NIV(0x68, "road stop info of nearby tiles"),
NIV(0x69, "information about cargo accepted in the past"), NIV(0x69, "information about cargo accepted in the past"),
NIV(0x6A, "GRFID of nearby road stop tiles"), NIV(0x6A, "GRFID of nearby road stop tiles"),
NIV(0x6B, "Road info of nearby plain road tiles"),
NIV_END(), NIV_END(),
}; };