summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-06-20 07:23:00 +0000
committerpeter1138 <peter1138@openttd.org>2008-06-20 07:23:00 +0000
commit52c06f1baa1c14b7bc291e05177ecbe2cd241d07 (patch)
treea976ae543d82ed4ce6374f8eb6aa6b4dbc835ea9
parent1f4475d51895aee5bd777ef100fe19ff5de9c886 (diff)
downloadopenttd-52c06f1baa1c14b7bc291e05177ecbe2cd241d07.tar.xz
(svn r13591) -Codechange: Support CB36 in the vehicle offer window.
-rw-r--r--src/engine_gui.cpp44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index edbc0a8ab..0461520c4 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -16,6 +16,7 @@
#include "newgrf_engine.h"
#include "strings_func.h"
#include "engine_gui.h"
+#include "articulated_vehicles.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -117,21 +118,34 @@ void ShowEnginePreviewWindow(EngineID engine)
AllocateWindowDescFront<EnginePreviewWindow>(&_engine_preview_desc, engine);
}
+static uint GetTotalCapacityOfArticulatedParts(EngineID engine, VehicleType type)
+{
+ uint total = 0;
+
+ uint16 *cap = GetCapacityOfArticulatedParts(engine, type);
+ for (uint c = 0; c < NUM_CARGO; c++) {
+ total += cap[c];
+ }
+
+ return total;
+}
+
static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw)
{
const RailVehicleInfo *rvi = RailVehInfo(engine);
int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD) ? 1 : 0;
- SetDParam(0, (_price.build_railvehicle >> 3) * rvi->base_cost >> 5);
- SetDParam(2, rvi->max_speed * 10 / 16);
- SetDParam(3, rvi->power << multihead);
- SetDParam(1, rvi->weight << multihead);
+ SetDParam(0, (_price.build_railvehicle >> 3) * GetEngineProperty(engine, 0x17, rvi->base_cost) >> 5);
+ SetDParam(2, GetEngineProperty(engine, 0x09, rvi->max_speed) * 10 / 16);
+ SetDParam(3, GetEngineProperty(engine, 0x0B, rvi->power) << multihead);
+ SetDParam(1, GetEngineProperty(engine, 0x16, rvi->weight) << multihead);
- SetDParam(4, rvi->running_cost * GetPriceByIndex(rvi->running_cost_class) >> 8 << multihead);
+ SetDParam(4, GetEngineProperty(engine, 0x0D, rvi->running_cost) * GetPriceByIndex(rvi->running_cost_class) >> 8 << multihead);
- if (rvi->capacity != 0) {
+ uint capacity = GetTotalCapacityOfArticulatedParts(engine, VEH_TRAIN);
+ if (capacity != 0) {
SetDParam(5, rvi->cargo_type);
- SetDParam(6, rvi->capacity << multihead);
+ SetDParam(6, capacity << multihead);
} else {
SetDParam(5, CT_INVALID);
}
@@ -141,11 +155,11 @@ static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw)
static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw)
{
const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
- SetDParam(0, (_price.aircraft_base >> 3) * avi->base_cost >> 5);
+ SetDParam(0, (_price.aircraft_base >> 3) * GetEngineProperty(engine, 0x0B, avi->base_cost) >> 5);
SetDParam(1, avi->max_speed * 10 / 16);
SetDParam(2, avi->passenger_capacity);
SetDParam(3, avi->mail_capacity);
- SetDParam(4, avi->running_cost * _price.aircraft_running >> 8);
+ SetDParam(4, GetEngineProperty(engine, 0x0E, avi->running_cost) * _price.aircraft_running >> 8);
DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw);
}
@@ -154,11 +168,11 @@ static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw)
{
const RoadVehicleInfo *rvi = RoadVehInfo(engine);
- SetDParam(0, (_price.roadveh_base >> 3) * rvi->base_cost >> 5);
+ SetDParam(0, (_price.roadveh_base >> 3) * GetEngineProperty(engine, 0x11, rvi->base_cost) >> 5);
SetDParam(1, rvi->max_speed * 10 / 32);
SetDParam(2, rvi->running_cost * GetPriceByIndex(rvi->running_cost_class) >> 8);
SetDParam(3, rvi->cargo_type);
- SetDParam(4, rvi->capacity);
+ SetDParam(4, GetTotalCapacityOfArticulatedParts(engine, VEH_ROAD));
DrawStringMultiCenter(x, y, STR_902A_COST_SPEED_RUNNING_COST, maxw);
}
@@ -166,11 +180,11 @@ static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw)
static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw)
{
const ShipVehicleInfo *svi = ShipVehInfo(engine);
- SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5);
- SetDParam(1, svi->max_speed * 10 / 32);
+ SetDParam(0, GetEngineProperty(engine, 0x0A, svi->base_cost) * (_price.ship_base >> 3) >> 5);
+ SetDParam(1, GetEngineProperty(engine, 0x0B, svi->max_speed) * 10 / 32);
SetDParam(2, svi->cargo_type);
- SetDParam(3, svi->capacity);
- SetDParam(4, svi->running_cost * _price.ship_running >> 8);
+ SetDParam(3, GetEngineProperty(engine, 0x0D, svi->capacity));
+ SetDParam(4, GetEngineProperty(engine, 0x0F, svi->running_cost) * _price.ship_running >> 8);
DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
}