summaryrefslogtreecommitdiff
path: root/src
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
commitbce424a4aa3b52073ced0c38ce596a97dc3c488a (patch)
tree418a575d7ef0c97c900d2555ac21b66e612d84e8 /src
parent90e4744ca3bcf5bc866cdd24d3b940adf948b86f (diff)
downloadopenttd-bce424a4aa3b52073ced0c38ce596a97dc3c488a.tar.xz
(svn r14239) -Fix [FS#2267]: The engine-purchase-list-sorter doubled running-cost and halfed capacity of double-headed engines.
Diffstat (limited to 'src')
-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) {