125 const Station* st1 = *(const Station**)a; |
125 const Station* st1 = *(const Station**)a; |
126 const Station* st2 = *(const Station**)b; |
126 const Station* st2 = *(const Station**)b; |
127 return (_internal_sort_order & 1) ? st2->facilities - st1->facilities : st1->facilities - st2->facilities; |
127 return (_internal_sort_order & 1) ? st2->facilities - st1->facilities : st1->facilities - st2->facilities; |
128 } |
128 } |
129 |
129 |
|
130 static const uint32 _cargo_filter_max = ~0; |
|
131 static uint32 _cargo_filter = _cargo_filter_max; |
|
132 |
130 static int CDECL StationWaitingSorter(const void *a, const void *b) |
133 static int CDECL StationWaitingSorter(const void *a, const void *b) |
131 { |
134 { |
132 const Station* st1 = *(const Station**)a; |
135 const Station* st1 = *(const Station**)a; |
133 const Station* st2 = *(const Station**)b; |
136 const Station* st2 = *(const Station**)b; |
134 Money sum1 = 0, sum2 = 0; |
137 Money sum1 = 0, sum2 = 0; |
135 |
138 |
136 for (CargoID j = 0; j < NUM_CARGO; j++) { |
139 for (CargoID j = 0; j < NUM_CARGO; j++) { |
|
140 if (!HASBIT(_cargo_filter, j)) continue; |
137 if (!st1->goods[j].cargo.Empty()) sum1 += GetTransportedGoodsIncome(st1->goods[j].cargo.Count(), 20, 50, j); |
141 if (!st1->goods[j].cargo.Empty()) sum1 += GetTransportedGoodsIncome(st1->goods[j].cargo.Count(), 20, 50, j); |
138 if (!st2->goods[j].cargo.Empty()) sum2 += GetTransportedGoodsIncome(st2->goods[j].cargo.Count(), 20, 50, j); |
142 if (!st2->goods[j].cargo.Empty()) sum2 += GetTransportedGoodsIncome(st2->goods[j].cargo.Count(), 20, 50, j); |
139 } |
143 } |
140 |
144 |
141 return (_internal_sort_order & 1) ? ClampToI32(sum2 - sum1) : ClampToI32(sum1 - sum2); |
145 return (_internal_sort_order & 1) ? ClampToI32(sum2 - sum1) : ClampToI32(sum1 - sum2); |
269 qsort((void*)sl->sort_list, sl->list_length, sizeof(sl->sort_list[0]), _station_sorter[sl->sort_type]); |
273 qsort((void*)sl->sort_list, sl->list_length, sizeof(sl->sort_list[0]), _station_sorter[sl->sort_type]); |
270 |
274 |
271 sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
275 sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
272 sl->flags &= ~SL_RESORT; |
276 sl->flags &= ~SL_RESORT; |
273 } |
277 } |
274 |
|
275 static const uint32 _cargo_filter_max = ~0; |
|
276 static uint32 _cargo_filter = _cargo_filter_max; |
|
277 |
278 |
278 static void PlayerStationsWndProc(Window *w, WindowEvent *e) |
279 static void PlayerStationsWndProc(Window *w, WindowEvent *e) |
279 { |
280 { |
280 const PlayerID owner = (PlayerID)w->window_number; |
281 const PlayerID owner = (PlayerID)w->window_number; |
281 static byte facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK; |
282 static byte facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK; |