diff options
author | rubidium <rubidium@openttd.org> | 2007-10-20 14:51:09 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-10-20 14:51:09 +0000 |
commit | 8212088c03c0a0af451f734391699e5dab8d8608 (patch) | |
tree | 28fbe813d418b83e119aa615200f98b20ba520c8 /src/build_vehicle_gui.cpp | |
parent | 54369cba0f9d1cda2d40752eb337d153b3b6775f (diff) | |
download | openttd-8212088c03c0a0af451f734391699e5dab8d8608.tar.xz |
(svn r11312) -Codechange: implement a overflow safe integer and use that for money and don't misuses CommandCost to have a overflow safe integer. Based on a patch by Noldo.
Diffstat (limited to 'src/build_vehicle_gui.cpp')
-rw-r--r-- | src/build_vehicle_gui.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index bd4938111..38b74cbb8 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -226,8 +226,8 @@ static int CDECL TrainEnginePowerVsRunningCostSorter(const void *a, const void * * Because of this, the return value have to be reversed as well and we return b - a instead of a - b. * Another thing is that both power and running costs should be doubled for multiheaded engines. * Since it would be multipling with 2 in both numerator and denumerator, it will even themselves out and we skip checking for multiheaded. */ - Money va = (rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class]) / max((uint16)1, rvi_a->power); - Money vb = (rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class]) / max((uint16)1, rvi_b->power); + Money va = (rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class]) / max(1U, (uint)rvi_a->power); + Money vb = (rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class]) / max(1U, (uint)rvi_b->power); int r = ClampToI32(vb - va); return _internal_sort_order ? -r : r; |