224 * We want power/running cost, but since we usually got higher running cost than power and we store the result in an int, |
224 * We want power/running cost, but since we usually got higher running cost than power and we store the result in an int, |
225 * we will actually calculate cunning cost/power (to make it more than 1). |
225 * we will actually calculate cunning cost/power (to make it more than 1). |
226 * Because of this, the return value have to be reversed as well and we return b - a instead of a - b. |
226 * Because of this, the return value have to be reversed as well and we return b - a instead of a - b. |
227 * Another thing is that both power and running costs should be doubled for multiheaded engines. |
227 * Another thing is that both power and running costs should be doubled for multiheaded engines. |
228 * Since it would be multipling with 2 in both numerator and denumerator, it will even themselves out and we skip checking for multiheaded. */ |
228 * Since it would be multipling with 2 in both numerator and denumerator, it will even themselves out and we skip checking for multiheaded. */ |
229 Money va = (rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class]) / max((uint16)1, rvi_a->power); |
229 Money va = (rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class]) / max(1U, (uint)rvi_a->power); |
230 Money vb = (rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class]) / max((uint16)1, rvi_b->power); |
230 Money vb = (rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class]) / max(1U, (uint)rvi_b->power); |
231 int r = ClampToI32(vb - va); |
231 int r = ClampToI32(vb - va); |
232 |
232 |
233 return _internal_sort_order ? -r : r; |
233 return _internal_sort_order ? -r : r; |
234 } |
234 } |
235 |
235 |