diff --git a/docs/newgrf-roadstops-nml.html b/docs/newgrf-roadstops-nml.html
index a111739eee..c8bb8ef655 100644
--- a/docs/newgrf-roadstops-nml.html
+++ b/docs/newgrf-roadstops-nml.html
@@ -165,6 +165,12 @@
nearby_tile_one_way_info | x, y offset (-8..7) | RST_OWI_XXX | One-way state of nearby drive-through road stop tile |
nearby_tile_road_stop_info | x, y offset (-8..7) | | Above nearby road stop tile variables in one variable (all of variable 0x68) |
nearby_tile_grfid | x, y offset (-8..7) | -1, 0 or a GRFID | 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 |
+ nearby_tile_is_plain_road | x, y offset (-8..7) | 0 | 1 | Is nearby tile a plain road tile |
+ nearby_tile_road_bits | x, y offset (-8..7) | bitmask(ROADBIT_XXX, ...) | XXX = [NW | SW | SE | NE] Present road bits on nearby tile |
+ nearby_tile_tram_bits | x, y offset (-8..7) | bitmask(ROADBIT_XXX, ...) | XXX = [NW | SW | SE | NE] Present tram bits on nearby tile |
+ nearby_tile_road_piece | x, y offset (-8..7) | 0..18 | 0xFF | Present road piece and slope in sprite order, or 0xFF if none |
+ nearby_tile_tram_piece | x, y offset (-8..7) | 0..18 | 0xFF | Present tram piece and slope in sprite order, or 0xFF if none |
+ nearby_tile_road_stop_info | x, y offset (-8..7) | | Above nearby road tile variables in one variable (all of variable 0x6B) |
Road Stop Callbacks
diff --git a/docs/newgrf-roadstops.html b/docs/newgrf-roadstops.html
index 6e75d16772..5dbb29792b 100644
--- a/docs/newgrf-roadstops.html
+++ b/docs/newgrf-roadstops.html
@@ -228,6 +228,7 @@
68 | roadstop_road_stop_info_nearby_tiles | Road stop info of nearby tiles |
69 | | Information about cargo accepted in the past (BaseStation) |
6A | roadstop_road_stop_grfid_nearby_tiles | GRFID of nearby road stop tiles |
+ 6B | roadstop_road_info_nearby_tiles | Road info of nearby plain road tiles |
Road stop view/rotation (40, or mappable variable: roadstop_view)
@@ -342,6 +343,39 @@
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.
+
+
+ Bits | Value | Meaning |
+ 0 | 01 | North-west road piece is present |
+ 1 | 02 | South-west road piece is present |
+ 2 | 04 | South-east road piece is present |
+ 3 | 08 | North-east road piece is present |
+ 4 | 10 | North-west tram piece is present |
+ 5 | 20 | South-west tram piece is present |
+ 6 | 40 | South-east tram piece is present |
+ 7 | 80 | North-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
diff --git a/src/newgrf_extension.cpp b/src/newgrf_extension.cpp
index 161c3ba8e1..a58dba561e 100644
--- a/src/newgrf_extension.cpp
+++ b/src/newgrf_extension.cpp
@@ -55,7 +55,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = {
GRFFeatureInfo("action0_object_edge_foundation_mode", 2),
GRFFeatureInfo("action0_object_flood_resistant", 1),
GRFFeatureInfo("action0_object_viewport_map_tile_type", 1),
- GRFFeatureInfo("road_stops", 4),
+ GRFFeatureInfo("road_stops", 5),
GRFFeatureInfo("new_landscape", 2),
GRFFeatureInfo(),
};
@@ -147,6 +147,7 @@ extern const GRFVariableMapDefinition _grf_action2_remappable_variables[] = {
GRFVariableMapDefinition(GSF_ROADSTOPS, 0x67, "roadstop_land_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, 0x6B, "roadstop_road_info_nearby_tiles"),
GRFVariableMapDefinition(GSF_RAILTYPES, A2VRI_RAILTYPE_SIGNAL_RESTRICTION_INFO, "railtype_signal_restriction_info"),
GRFVariableMapDefinition(GSF_RAILTYPES, A2VRI_RAILTYPE_SIGNAL_CONTEXT, "railtype_signal_context"),
GRFVariableMapDefinition(GSF_SIGNALS, A2VRI_SIGNALS_SIGNAL_RESTRICTION_INFO, "signals_signal_restriction_info"),
diff --git a/src/newgrf_roadstop.cpp b/src/newgrf_roadstop.cpp
index 702dda2cd6..664f1ff187 100644
--- a/src/newgrf_roadstop.cpp
+++ b/src/newgrf_roadstop.cpp
@@ -187,6 +187,23 @@ uint32 RoadStopScopeResolver::GetVariable(uint16 variable, uint32 parameter, Get
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 0xFA: return Clamp((this->st == nullptr ? _date : this->st->build_date) - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // build date
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 62d5503620..8fb07606af 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -1866,7 +1866,7 @@ const byte _road_sloped_sprites[14] = {
* @param bits Roadbits
* @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) {
switch (slope) {
diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h
index cd7e156316..017213b5d1 100644
--- a/src/table/newgrf_debug_data.h
+++ b/src/table/newgrf_debug_data.h
@@ -1701,6 +1701,7 @@ static const NIVariable _nif_roadstops[] = {
NIV(0x68, "road stop info of nearby tiles"),
NIV(0x69, "information about cargo accepted in the past"),
NIV(0x6A, "GRFID of nearby road stop tiles"),
+ NIV(0x6B, "Road info of nearby plain road tiles"),
NIV_END(),
};