summaryrefslogtreecommitdiff
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
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
-rw-r--r--src/economy.cpp2
-rw-r--r--src/industry_cmd.cpp23
-rw-r--r--src/station_base.h2
-rw-r--r--src/tile_cmd.h2
4 files changed, 25 insertions, 4 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index 6f5d84391..faa043b62 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -932,7 +932,7 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti
/* Give the goods to the industry. */
uint accepted = DeliverGoodsToIndustry(st, cargo_type, num_pieces, src_type == ST_INDUSTRY ? src : INVALID_INDUSTRY);
- /* If there are non-industries around accepting the cargo, accept it all */
+ /* If this cargo type is always accepted, accept all */
if (HasBit(st->always_accepted, cargo_type)) accepted = num_pieces;
/* Determine profit */
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);
}
}
diff --git a/src/station_base.h b/src/station_base.h
index fbbf04cbd..ce87b2cf6 100644
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -85,7 +85,7 @@ public:
byte last_vehicle_type;
std::list<Vehicle *> loading_vehicles;
GoodsEntry goods[NUM_CARGO]; ///< Goods at this station
- uint32 always_accepted; ///< Bitmask of cargos accepted by town houses and headquarters
+ uint32 always_accepted; ///< Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept cargo)
IndustryVector industries_near; ///< Cached list of industries near the station that can accept cargo, @see DeliverGoodsToIndustry()
diff --git a/src/tile_cmd.h b/src/tile_cmd.h
index 748db79e8..4ce9aa1a7 100644
--- a/src/tile_cmd.h
+++ b/src/tile_cmd.h
@@ -80,7 +80,7 @@ typedef CommandCost ClearTileProc(TileIndex tile, DoCommandFlag flags);
* Tile callback function signature for obtaining cargo acceptance of a tile
* @param tile Tile queried for its accepted cargo
* @param acceptance Storage destination of the cargo acceptance in 1/8
- * @param always_accepted Bitmask of town and headquarters-accepted cargo
+ * @param always_accepted Bitmask of always accepted cargo types
*/
typedef void AddAcceptedCargoProc(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted);