summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-12-20 15:21:39 +0000
committerfrosch <frosch@openttd.org>2009-12-20 15:21:39 +0000
commit640442ae03d0c1f1a3dadedee7f66f145de31124 (patch)
treed427adda9f94db1f27598650f63952aeff10a575 /src
parentd00efae030154d8611fe5ef7201f751cbd688ce8 (diff)
downloadopenttd-640442ae03d0c1f1a3dadedee7f66f145de31124.tar.xz
(svn r18571) -Fix (r18551): Vehicles not carrying any cargo (e.g. engines) were not considered for sending to depot for replacement.
Diffstat (limited to 'src')
-rw-r--r--src/vehicle.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index b89d85554..459af8473 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -125,9 +125,20 @@ bool Vehicle::NeedsServicing() const
if (new_engine == INVALID_ENGINE || !HasBit(Engine::Get(new_engine)->company_avail, v->owner)) continue;
/* Check refittability */
- CargoID cargo_type = CT_INVALID;
- if (IsArticulatedVehicleCarryingDifferentCargos(v, &cargo_type) || cargo_type == CT_INVALID ||
- !HasBit(GetIntersectionOfArticulatedRefitMasks(new_engine, true), cargo_type)) continue;
+ uint32 available_cargo_types, union_mask;
+ GetArticulatedRefitMasks(new_engine, true, &union_mask, &available_cargo_types);
+ /* Is there anything to refit? */
+ if (union_mask != 0) {
+ CargoID cargo_type;
+ /* We cannot refit to mixed cargos in an automated way */
+ if (IsArticulatedVehicleCarryingDifferentCargos(v, &cargo_type)) continue;
+
+ /* Did the old vehicle carry anything? */
+ if (cargo_type != CT_INVALID) {
+ /* We can't refit the vehicle to carry the cargo we want */
+ if (!HasBit(available_cargo_types, cargo_type)) continue;
+ }
+ }
/* Check money.
* We want 2*(the price of the new vehicle) without looking at the value of the vehicle we are going to sell. */