(svn r12254) [NoAI] -Fix: make AITileList_Industry* newgrf compatible (tnx glx)
--- a/src/ai/api/ai_tilelist.cpp Mon Feb 25 15:40:08 2008 +0000
+++ b/src/ai/api/ai_tilelist.cpp Mon Feb 25 16:10:13 2008 +0000
@@ -77,7 +77,13 @@
const IndustrySpec *indsp = ::GetIndustrySpec(i->type);
/* Check if this industry accepts anything */
- if (indsp->accepts_cargo[0] == CT_INVALID) return;
+ {
+ bool cargo_accepts = false;
+ for (byte j = 0; j < lengthof(indsp->accepts_cargo); j++) {
+ if (indsp->accepts_cargo[j] != CT_INVALID) cargo_accepts = true;
+ }
+ if (!cargo_accepts) return;
+ }
if (!_patches.modified_catchment) radius = CA_UNMODIFIED;
@@ -89,7 +95,13 @@
* industry triggers the acceptance). */
AcceptedCargo accepts;
::GetAcceptanceAroundTiles(accepts, cur_tile, 1, 1, radius);
- if (accepts[indsp->accepts_cargo[0]] == 0) continue;
+ {
+ bool cargo_accepts = false;
+ for (byte j = 0; j < lengthof(indsp->accepts_cargo); j++) {
+ if (indsp->accepts_cargo[j] != CT_INVALID && accepts[indsp->accepts_cargo[j]] != 0) cargo_accepts = true;
+ }
+ if (!cargo_accepts) continue;
+ }
this->AddTile(cur_tile);
} END_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius))
@@ -103,7 +115,13 @@
const IndustrySpec *indsp = ::GetIndustrySpec(i->type);
/* Check if this industry produces anything */
- if (indsp->produced_cargo[0] == CT_INVALID) return;
+ {
+ bool cargo_produces = false;
+ for (byte j = 0; j < lengthof(indsp->produced_cargo); j++) {
+ if (indsp->produced_cargo[j] != CT_INVALID) cargo_produces = true;
+ }
+ if (!cargo_produces) return;
+ }
if (!_patches.modified_catchment) radius = CA_UNMODIFIED;