summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-09-20 18:52:12 +0000
committersmatz <smatz@openttd.org>2009-09-20 18:52:12 +0000
commit9cf2e921599e222a58884179e6c435f731f3d149 (patch)
treeebc1252913d089288fcb8365fbfe6ddd90d201e2 /src/industry_cmd.cpp
parent12ef0046dde205e0e111ed7e6d830ea4f93c45c9 (diff)
downloadopenttd-9cf2e921599e222a58884179e6c435f731f3d149.tar.xz
(svn r17592) -Fix [FS#3212](r17436): force all cargo being accepted when industry tiles accept it but industry itself doesn't
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index ec83f8d6c..fe992083e 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -429,9 +429,30 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, ui
}
}
+ const Industry *ind = Industry::GetByTile(tile);
for (byte i = 0; i < lengthof(itspec->accepts_cargo); i++) {
CargoID a = accepts_cargo[i];
- if (a != CT_INVALID) acceptance[a] += cargo_acceptance[i];
+ if (a == CT_INVALID) continue; // work only with valid cargos
+
+ /* Add accepted cargo */
+ acceptance[a] += cargo_acceptance[i];
+
+ /* Maybe set 'always accepted' bit (if it's not set already) */
+ if (HasBit(*always_accepted, a)) continue;
+
+ bool accepts = false;
+ for (uint cargo_index = 0; cargo_index < lengthof(ind->accepts_cargo); cargo_index++) {
+ /* Test whether the industry itself accepts the cargo type */
+ if (ind->accepts_cargo[cargo_index] == a) {
+ accepts = true;
+ break;
+ }
+ }
+
+ if (accepts) continue;
+
+ /* If the industry itself doesn't accept this cargo, set 'always accepted' bit */
+ SetBit(*always_accepted, a);
}
}