summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeterN <peter@fuzzle.org>2019-03-27 23:10:02 +0000
committerGitHub <noreply@github.com>2019-03-27 23:10:02 +0000
commit7fb77ff35a124f2533d4c467e289fbd2ec936fbd (patch)
treeb0e67011079be9ade15b047b3bd3549ca6e090dd /src
parent66dd7c3879123bb99b712375b66b577f81d53a96 (diff)
downloadopenttd-7fb77ff35a124f2533d4c467e289fbd2ec936fbd.tar.xz
Fix: Incorrect display of industry production around tiles. (#7426)
Display of industry production around tiles (as shown when placing a station) did not take account of the station catchment changes, so still showed production from an industry even if it was not covered by a tile. This is fixed by making a set of nearby industries that are covered, instead of looping over all possible industries.
Diffstat (limited to 'src')
-rw-r--r--src/station_cmd.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 5dfba2d19..7a939cd8b 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -512,21 +512,21 @@ CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad)
assert(w > 0);
assert(h > 0);
+ std::set<IndustryID> industries;
TileArea ta(TileXY(x1, y1), TileXY(x2 - 1, y2 - 1));
/* Loop over all tiles to get the produced cargo of
* everything except industries */
- TILE_AREA_LOOP(tile, ta) AddProducedCargo(tile, produced);
+ TILE_AREA_LOOP(tile, ta) {
+ if (IsTileType(tile, MP_INDUSTRY)) industries.insert(GetIndustryIndex(tile));
+ AddProducedCargo(tile, produced);
+ }
- /* Loop over the industries. They produce cargo for
- * anything that is within 'rad' from their bounding
- * box. As such if you have e.g. a oil well the tile
- * area loop might not hit an industry tile while
- * the industry would produce cargo for the station.
+ /* Loop over the seen industries. They produce cargo for
+ * anything that is within 'rad' of any one of their tiles.
*/
- const Industry *i;
- FOR_ALL_INDUSTRIES(i) {
- if (!ta.Intersects(i->location)) continue;
+ for (IndustryID industry : industries) {
+ const Industry *i = Industry::Get(industry);
/* Skip industry with neutral station */
if (i->neutral_station != NULL && !_settings_game.station.serve_neutral_industries) continue;