diff options
author | frosch <frosch@openttd.org> | 2009-02-21 12:52:41 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-02-21 12:52:41 +0000 |
commit | d3850e101c7deb3d6549dae3dcad9daa90c40946 (patch) | |
tree | 62e06798cf27a41c73412fa15906f2df18c9826c /src/build_vehicle_gui.cpp | |
parent | b674d1f6f5c680d42c3297f1a79a87a124d0e52d (diff) | |
download | openttd-d3850e101c7deb3d6549dae3dcad9daa90c40946.tar.xz |
(svn r15541) -Revert (r15399): 'v->cargo_type' is also used in other places, which cannot accept CT_INVALID.
-Codechange: Add Engine::GetDefaultCargoType() and Engine::CanCarryCargo() and use them.
-Fix [FS#2617]: When articulated parts have no available default cargo, use the cargo type of the first part for livery selection.
-Change: To decide whether a vehicle is refittable do not test its current capacity for being zero, but always use the 'capacity property'.
Note: The property is used unmodifed without calling CB 15/36. By setting it to a non-zero value and returning zero in the callback vehicles can be refitted to/from zero capacity for e.g. livery effects.
Note: It is intentional that you cannot control refittability by CB 36.
Diffstat (limited to 'src/build_vehicle_gui.cpp')
-rw-r--r-- | src/build_vehicle_gui.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index feb01a051..888091e04 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -484,7 +484,8 @@ static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const /* Wagon weight - (including cargo) */ uint weight = e->GetDisplayWeight(); SetDParam(0, weight); - SetDParam(1, (GetCargo(rvi->cargo_type)->weight * GetEngineProperty(engine_number, 0x14, rvi->capacity) >> 4) + weight); + uint cargo_weight = (e->CanCarryCargo() ? GetCargo(e->GetDefaultCargoType())->weight * GetEngineProperty(engine_number, 0x14, rvi->capacity) >> 4 : 0); + SetDParam(1, cargo_weight + weight); DrawString(x, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT, TC_FROMSTRING); y += 10; @@ -582,7 +583,7 @@ static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const Ship y += 10; /* Cargo type + capacity */ - SetDParam(0, svi->cargo_type); + SetDParam(0, e->GetDefaultCargoType()); SetDParam(1, GetEngineProperty(engine_number, 0x0D, svi->capacity)); SetDParam(2, IsEngineRefittable(engine_number) ? STR_9842_REFITTABLE : STR_EMPTY); DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING); @@ -599,8 +600,8 @@ static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const Ship /* Draw aircraft specific details */ static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const AircraftVehicleInfo *avi) { - CargoID cargo; const Engine *e = GetEngine(engine_number); + CargoID cargo = e->GetDefaultCargoType(); /* Purchase cost - Max speed */ SetDParam(0, e->GetCost()); @@ -609,7 +610,6 @@ static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const y += 10; /* Cargo capacity */ - cargo = FindFirstRefittableCargo(engine_number); if (cargo == CT_INVALID || cargo == CT_PASSENGERS) { SetDParam(0, avi->passenger_capacity); SetDParam(1, avi->mail_capacity); |