diff options
author | rubidium <rubidium@openttd.org> | 2010-01-04 21:10:20 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-01-04 21:10:20 +0000 |
commit | 28fc7b47bd35acc860e84e3885d13ffb0fad2c83 (patch) | |
tree | c461b7b47abb73891c5caf5d490cede32158ed0d /src/station_cmd.cpp | |
parent | 1ed599f5cf6a0dec14d91d5442a08560e254d35c (diff) | |
download | openttd-28fc7b47bd35acc860e84e3885d13ffb0fad2c83.tar.xz |
(svn r18726) -Fix [FS#3463]: with non-uniform industries the 'supplies' text when building a station could be incorrect (missing a cargo)
-Change [NoAI]: AITile::GetCargoProduction now returns the number of producers and not the number of tiles of producers.
-Fix [NoAI]: AITileList_IndustryProducing would omit some tiles for at which a station would get cargo.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r-- | src/station_cmd.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 8b7bf5345..b66ccafb5 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -485,10 +485,25 @@ CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad) assert(w > 0); assert(h > 0); - for (int yc = y1; yc != y2; yc++) { - for (int xc = x1; xc != x2; xc++) { - TileIndex tile = TileXY(xc, yc); - AddProducedCargo(tile, produced); + 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); + + /* 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. + */ + const Industry *i; + FOR_ALL_INDUSTRIES(i) { + if (!ta.Intersects(i->location)) continue; + + for (uint j = 0; j < lengthof(i->produced_cargo); j++) { + CargoID cargo = i->produced_cargo[j]; + if (cargo != CT_INVALID) produced[cargo]++; } } |