summaryrefslogtreecommitdiff
path: root/src/build_vehicle_gui.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2009-01-25 00:57:03 +0000
committerglx <glx@openttd.org>2009-01-25 00:57:03 +0000
commitc1cf3934fa5bd523dd1df01cf505c9f06927701d (patch)
treea8b3e55a2f1168021a45917b6fbf5777c3476634 /src/build_vehicle_gui.cpp
parent80ee3d3440233b50bbe818b2f74f6aac8841edfa (diff)
downloadopenttd-c1cf3934fa5bd523dd1df01cf505c9f06927701d.tar.xz
(svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
Diffstat (limited to 'src/build_vehicle_gui.cpp')
-rw-r--r--src/build_vehicle_gui.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 73945ba3a..a7840150f 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -482,8 +482,10 @@ static int DrawCargoCapacityInfo(int x, int y, EngineID engine, VehicleType type
/* Draw rail wagon specific details */
static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi)
{
+ const Engine *e = GetEngine(engine_number);
+
/* Purchase cost */
- SetDParam(0, (GetEngineProperty(engine_number, 0x17, rvi->cost_factor) * _price.build_railwagon) >> 8);
+ SetDParam(0, e->GetCost());
DrawString(x, y, STR_PURCHASE_INFO_COST, TC_FROMSTRING);
y += 10;
@@ -506,7 +508,7 @@ static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const
/* Running cost */
if (rvi->running_cost_class != 0xFF) {
- SetDParam(0, GetEngine(engine_number)->GetRunningCost());
+ SetDParam(0, e->GetRunningCost());
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
y += 10;
}
@@ -519,9 +521,10 @@ static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, cons
{
int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight);
+ const Engine *e = GetEngine(engine_number);
/* Purchase Cost - Engine weight */
- SetDParam(0, GetEngineProperty(engine_number, 0x17, rvi->cost_factor) * (_price.build_railvehicle >> 3) >> 5);
+ SetDParam(0, e->GetCost());
SetDParam(1, weight << multihead);
DrawString(x, y, STR_PURCHASE_INFO_COST_WEIGHT, TC_FROMSTRING);
y += 10;
@@ -541,7 +544,7 @@ static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, cons
/* Running cost */
if (rvi->running_cost_class != 0xFF) {
- SetDParam(0, GetEngine(engine_number)->GetRunningCost());
+ SetDParam(0, e->GetRunningCost());
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
y += 10;
}
@@ -560,14 +563,16 @@ static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, cons
/* Draw road vehicle specific details */
static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const RoadVehicleInfo *rvi)
{
+ const Engine *e = GetEngine(engine_number);
+
/* Purchase cost - Max speed */
- SetDParam(0, GetEngineProperty(engine_number, 0x11, rvi->cost_factor) * (_price.roadveh_base >> 3) >> 5);
+ SetDParam(0, e->GetCost());
SetDParam(1, rvi->max_speed * 10 / 32);
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING);
y += 10;
/* Running cost */
- SetDParam(0, GetEngine(engine_number)->GetRunningCost());
+ SetDParam(0, e->GetRunningCost());
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
y += 10;
@@ -578,8 +583,10 @@ static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const R
/* Draw ship specific details */
static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi)
{
+ const Engine *e = GetEngine(engine_number);
+
/* Purchase cost - Max speed */
- SetDParam(0, GetEngineProperty(engine_number, 0x0A, svi->cost_factor) * (_price.ship_base >> 3) >> 5);
+ SetDParam(0, e->GetCost());
SetDParam(1, GetEngineProperty(engine_number, 0x0B, svi->max_speed) * 10 / 32);
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING);
y += 10;
@@ -592,7 +599,7 @@ static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const Ship
y += 10;
/* Running cost */
- SetDParam(0, GetEngine(engine_number)->GetRunningCost());
+ SetDParam(0, e->GetRunningCost());
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
y += 10;
@@ -603,9 +610,10 @@ static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const Ship
static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const AircraftVehicleInfo *avi)
{
CargoID cargo;
+ const Engine *e = GetEngine(engine_number);
/* Purchase cost - Max speed */
- SetDParam(0, GetEngineProperty(engine_number, 0x0B, avi->cost_factor) * (_price.aircraft_base >> 3) >> 5);
+ SetDParam(0, e->GetCost());
SetDParam(1, avi->max_speed * 10 / 16);
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING);
y += 10;
@@ -627,7 +635,7 @@ static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const
y += 10;
/* Running cost */
- SetDParam(0, GetEngine(engine_number)->GetRunningCost());
+ SetDParam(0, e->GetRunningCost());
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, TC_FROMSTRING);
y += 10;