From d52d44760362201b5c576667f05149fc86761fba Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 17 Apr 2024 17:07:00 +0100 Subject: [PATCH] Update station/industry nearby lists in BuildOilRig See: https://github.com/OpenTTD/OpenTTD/issues/12506 --- src/station_cmd.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index e871aa5953..beace0675e 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -5081,6 +5081,19 @@ void BuildOilRig(TileIndex tile) st->rect.BeforeAddTile(tile, StationRect::ADD_FORCE); st->UpdateVirtCoord(); + + /* An industry tile has now been replaced with a station tile, this may change the overlap between station catchments and industry tiles. + * Recalculate the station catchment for all stations currently in the industry's nearby list. + * Clear the industry's station nearby list first because Station::RecomputeCatchment cannot remove nearby industries in this case. */ + if (_settings_game.station.serve_neutral_industries) { + StationList nearby = std::move(st->industry->stations_near); + st->industry->stations_near.clear(); + for (Station *near : nearby) { + near->RecomputeCatchment(true); + UpdateStationAcceptance(near, true); + } + } + st->RecomputeCatchment(); UpdateStationAcceptance(st, false); ZoningMarkDirtyStationCoverageArea(st);