(svn r18571) -Fix (r18551): Vehicles not carrying any cargo (e.g. engines) were not considered for sending to depot for replacement.

This commit is contained in:
frosch 2009-12-20 15:21:39 +00:00
parent d00efae030
commit 640442ae03
1 changed files with 14 additions and 3 deletions

View File

@ -125,9 +125,20 @@ bool Vehicle::NeedsServicing() const
if (new_engine == INVALID_ENGINE || !HasBit(Engine::Get(new_engine)->company_avail, v->owner)) continue; if (new_engine == INVALID_ENGINE || !HasBit(Engine::Get(new_engine)->company_avail, v->owner)) continue;
/* Check refittability */ /* Check refittability */
CargoID cargo_type = CT_INVALID; uint32 available_cargo_types, union_mask;
if (IsArticulatedVehicleCarryingDifferentCargos(v, &cargo_type) || cargo_type == CT_INVALID || GetArticulatedRefitMasks(new_engine, true, &union_mask, &available_cargo_types);
!HasBit(GetIntersectionOfArticulatedRefitMasks(new_engine, true), cargo_type)) continue; /* 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. /* Check money.
* We want 2*(the price of the new vehicle) without looking at the value of the vehicle we are going to sell. */ * We want 2*(the price of the new vehicle) without looking at the value of the vehicle we are going to sell. */