summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-09-03 18:05:02 +0000
committerfrosch <frosch@openttd.org>2008-09-03 18:05:02 +0000
commite6688ab190a64e98990917e02c1d0cd504fb019a (patch)
tree418a575d7ef0c97c900d2555ac21b66e612d84e8
parent6c924578de43710dd07a9b556c09d51f6394f9a6 (diff)
downloadopenttd-e6688ab190a64e98990917e02c1d0cd504fb019a.tar.xz
(svn r14239) -Fix [FS#2267]: The engine-purchase-list-sorter doubled running-cost and halfed capacity of double-headed engines.
-rw-r--r--src/build_vehicle_gui.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 7a2282097..0acdfa574 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -168,8 +168,8 @@ static int CDECL TrainEngineRunningCostSorter(const void *a, const void *b)
const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a);
const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b);
- Money va = rvi_a->running_cost * GetPriceByIndex(rvi_a->running_cost_class) * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
- Money vb = rvi_b->running_cost * GetPriceByIndex(rvi_b->running_cost_class) * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
+ Money va = rvi_a->running_cost * GetPriceByIndex(rvi_a->running_cost_class);
+ Money vb = rvi_b->running_cost * GetPriceByIndex(rvi_b->running_cost_class);
int r = ClampToI32(va - vb);
return _internal_sort_order ? -r : r;
@@ -195,8 +195,11 @@ static int CDECL TrainEnginePowerVsRunningCostSorter(const void *a, const void *
static int CDECL TrainEngineCapacitySorter(const void *a, const void *b)
{
- int va = RailVehInfo(*(const EngineID*)a)->capacity;
- int vb = RailVehInfo(*(const EngineID*)b)->capacity;
+ const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a);
+ const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b);
+
+ int va = rvi_a->capacity * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
+ int vb = rvi_b->capacity * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
int r = va - vb;
if (r == 0) {