129 |
129 |
130 static int CDECL StationWaitingSorter(const void *a, const void *b) |
130 static int CDECL StationWaitingSorter(const void *a, const void *b) |
131 { |
131 { |
132 const Station* st1 = *(const Station**)a; |
132 const Station* st1 = *(const Station**)a; |
133 const Station* st2 = *(const Station**)b; |
133 const Station* st2 = *(const Station**)b; |
134 int sum1 = 0, sum2 = 0; |
134 Money sum1 = 0, sum2 = 0; |
135 |
135 |
136 for (CargoID j = 0; j < NUM_CARGO; j++) { |
136 for (CargoID j = 0; j < NUM_CARGO; j++) { |
137 if (st1->goods[j].waiting_acceptance & 0xfff) sum1 += GetTransportedGoodsIncome(st1->goods[j].waiting_acceptance & 0xfff, 20, 50, j); |
137 if (st1->goods[j].waiting_acceptance & 0xfff) sum1 += GetTransportedGoodsIncome(st1->goods[j].waiting_acceptance & 0xfff, 20, 50, j); |
138 if (st2->goods[j].waiting_acceptance & 0xfff) sum2 += GetTransportedGoodsIncome(st2->goods[j].waiting_acceptance & 0xfff, 20, 50, j); |
138 if (st2->goods[j].waiting_acceptance & 0xfff) sum2 += GetTransportedGoodsIncome(st2->goods[j].waiting_acceptance & 0xfff, 20, 50, j); |
139 } |
139 } |
140 |
140 |
141 return (_internal_sort_order & 1) ? sum2 - sum1 : sum1 - sum2; |
141 return (_internal_sort_order & 1) ? ClampToI32(sum2 - sum1) : ClampToI32(sum1 - sum2); |
142 } |
142 } |
143 |
143 |
144 /** |
144 /** |
145 * qsort-compatible version of sorting two stations by maximum rating |
145 * qsort-compatible version of sorting two stations by maximum rating |
146 * @param a First object to be sorted, must be of type (const Station *) |
146 * @param a First object to be sorted, must be of type (const Station *) |