From 1b48a2bd9d41bb1f52fec30aabd05c342e3f0b5b Mon Sep 17 00:00:00 2001 From: peter1138 Date: Fri, 9 Jun 2006 06:34:28 +0000 Subject: (svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p) --- aircraft.h | 7 +++++++ aircraft_cmd.c | 2 +- aircraft_gui.c | 17 ++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/aircraft.h b/aircraft.h index 55fc35c89..06e53797a 100644 --- a/aircraft.h +++ b/aircraft.h @@ -1,5 +1,8 @@ /* $Id$ */ +#ifndef AIRCRAFT_H +#define AIRCRAFT_H + #include "station_map.h" #include "vehicle.h" @@ -14,3 +17,7 @@ static inline bool IsAircraftInHangarStopped(const Vehicle* v) { return IsAircraftInHangar(v) && v->vehstatus & VS_STOPPED; } + +uint16 AircraftDefaultCargoCapacity(CargoID cid, EngineID engine_type); + +#endif /* AIRCRAFT_H */ diff --git a/aircraft_cmd.c b/aircraft_cmd.c index 1729dcdbe..9a3306c3d 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -164,7 +164,7 @@ static int32 EstimateAircraftCost(EngineID engine_type) * @param engine Which engine to find a cargo capacity for. * @return New cargo capacity value. */ -static uint16 AircraftDefaultCargoCapacity(CargoID cid, EngineID engine_type) +uint16 AircraftDefaultCargoCapacity(CargoID cid, EngineID engine_type) { const AircraftVehicleInfo *avi = AircraftVehInfo(engine_type); diff --git a/aircraft_gui.c b/aircraft_gui.c index 51695618f..a76acd34f 100644 --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -32,6 +32,7 @@ void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number) { const AircraftVehicleInfo *avi = AircraftVehInfo(engine_number); const Engine* e = GetEngine(engine_number); + CargoID cargo; YearMonthDay ymd; ConvertDayToYMD(&ymd, e->intro_date); @@ -42,9 +43,19 @@ void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number) y += 10; /* Cargo capacity */ - SetDParam(0, avi->passenger_capacity); - SetDParam(1, avi->mail_capacity); - DrawString(x, y, STR_PURCHASE_INFO_AIRCRAFT_CAPACITY, 0); + cargo = FindFirstRefittableCargo(engine_number); + if (cargo == CT_INVALID || cargo == CT_PASSENGERS) { + SetDParam(0, avi->passenger_capacity); + SetDParam(1, avi->mail_capacity); + DrawString(x, y, STR_PURCHASE_INFO_AIRCRAFT_CAPACITY, 0); + } else { + /* Note, if the default capacity is selected by the refit capacity + * callback, then the capacity shown is likely to be incorrect. */ + SetDParam(0, _cargoc.names_long[cargo]); + SetDParam(1, AircraftDefaultCargoCapacity(cargo, engine_number)); + SetDParam(2, STR_9842_REFITTABLE); + DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); + } y += 10; /* Running cost */ -- cgit v1.2.3-70-g09d2