diff --git a/src/newgrf_roadstop.cpp b/src/newgrf_roadstop.cpp index e5eb1340c7..0ded310e8c 100644 --- a/src/newgrf_roadstop.cpp +++ b/src/newgrf_roadstop.cpp @@ -219,6 +219,23 @@ uint32_t RoadStopScopeResolver::GetVariable(uint16_t variable, uint32_t paramete return ssl.grfid; } + /* 16 bit road stop ID of nearby tiles */ + case 0x6B: { + TileIndex nearby_tile = GetNearbyTile(parameter, this->tile); + + if (!IsAnyRoadStopTile(nearby_tile)) return 0xFFFFFFFF; + if (!IsCustomRoadStopSpecIndex(nearby_tile)) return 0xFFFE; + + uint32_t grfid = this->st->roadstop_speclist[GetCustomRoadStopSpecIndex(this->tile)].grfid; + + const RoadStopSpecList ssl = BaseStation::GetByTile(nearby_tile)->roadstop_speclist[GetCustomRoadStopSpecIndex(nearby_tile)]; + if (ssl.grfid == grfid) { + return ssl.localidx; + } + + return 0xFFFE; + } + /* Road info of nearby tiles */ case A2VRI_ROADSTOP_ROAD_INFO_NEARBY_TILES: { if (this->tile == INVALID_TILE) return 0xFFFFFFFF; diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index 403d121c56..45dcc0f065 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -403,6 +403,22 @@ uint32_t StationScopeResolver::GetNearbyStationInfo(uint32_t parameter, StationS return ssl.grfid; } + case 0x6B: { // 16 bit Station ID of nearby tiles + TileIndex nearby_tile = GetNearbyTile(parameter, this->tile); + + if (!HasStationTileRail(nearby_tile)) return 0xFFFFFFFF; + if (!IsCustomStationSpecIndex(nearby_tile)) return 0xFFFE; + + uint32_t grfid = this->st->speclist[GetCustomStationSpecIndex(this->tile)].grfid; + + const StationSpecList ssl = BaseStation::GetByTile(nearby_tile)->speclist[GetCustomStationSpecIndex(nearby_tile)]; + if (ssl.grfid == grfid) { + return ssl.localidx; + } + + return 0xFFFE; + } + /* General station variables */ case 0x82: return 50; case 0x84: return this->st->string_id; diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index bc7414d169..23a268526d 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -732,6 +732,7 @@ static const NIVariable _niv_stations[] = { NIV(0x68, "station info of nearby tiles"), NIV(0x69, "information about cargo accepted in the past"), NIV(0x6A, "GRFID of nearby station tiles"), + NIV(0x6B, "station ID of nearby tiles"), NIVF(A2VRI_STATION_INFO_NEARBY_TILES_V2, "station info of nearby tiles v2", NIVF_SHOW_PARAMS), NIV_END() }; @@ -2389,6 +2390,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 stop ID of nearby tiles"), NIVF(A2VRI_ROADSTOP_INFO_NEARBY_TILES_EXT, "road stop info of nearby tiles ext", NIVF_SHOW_PARAMS), NIVF(A2VRI_ROADSTOP_INFO_NEARBY_TILES_V2, "road stop info of nearby tiles v2", NIVF_SHOW_PARAMS), NIVF(A2VRI_ROADSTOP_ROAD_INFO_NEARBY_TILES, "Road info of nearby plain road tiles", NIVF_SHOW_PARAMS),