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_infox, y offset (-8..7)RST_OWI_XXXOne-way state of nearby drive-through road stop tile nearby_tile_road_stop_infox, y offset (-8..7)Above nearby road stop tile variables in one variable (all of variable 0x68) nearby_tile_grfidx, y offset (-8..7)-1, 0 or a GRFIDReturn 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_roadx, y offset (-8..7)0 | 1Is nearby tile a plain road tile + nearby_tile_road_bitsx, y offset (-8..7)bitmask(ROADBIT_XXX, ...)XXX = [NW | SW | SE | NE]
Present road bits on nearby tile + nearby_tile_tram_bitsx, y offset (-8..7)bitmask(ROADBIT_XXX, ...)XXX = [NW | SW | SE | NE]
Present tram bits on nearby tile + nearby_tile_road_piecex, y offset (-8..7)0..18 | 0xFFPresent road piece and slope in sprite order, or 0xFF if none + nearby_tile_tram_piecex, y offset (-8..7)0..18 | 0xFFPresent tram piece and slope in sprite order, or 0xFF if none + nearby_tile_road_stop_infox, 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 @@ 68roadstop_road_stop_info_nearby_tilesRoad stop info of nearby tiles 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)

@@ -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.

+ + + + + + + + + + + + + +
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

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(), };