(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.
This commit is contained in:
rubidium
2010-01-04 21:10:20 +00:00
parent 9e3c107ffe
commit 21b4eb70c3
8 changed files with 151 additions and 122 deletions

View File

@@ -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]++;
}
}