3 |
3 |
4 void DrawVehicleProfitButton(Vehicle *v, int x, int y); |
4 void DrawVehicleProfitButton(Vehicle *v, int x, int y); |
5 void InitializeVehiclesGuiList(); |
5 void InitializeVehiclesGuiList(); |
6 |
6 |
7 /* sorter stuff */ |
7 /* sorter stuff */ |
8 int CDECL GeneralOwnerSorter (const void *a, const void *b); |
|
9 int CDECL VehicleNameSorter (const void *a, const void *b); |
|
10 int CDECL GeneralVehicleSorter(const void *a, const void *b); |
|
11 VARDEF uint32 _internal_name_sorter_id; // internal StringID for default vehicle-names |
|
12 VARDEF uint32 _last_vehicle_idx; // cached index to hopefully speed up name-sorting |
|
13 VARDEF bool _internal_sort_order; // descending/ascending |
|
14 VARDEF byte _internal_sort_type; // Miscalleneous sorting criteria |
|
15 |
|
16 typedef struct SortStruct { // store owner through sorting process |
8 typedef struct SortStruct { // store owner through sorting process |
17 uint32 index; |
9 uint32 index; |
18 byte owner; |
10 byte owner; |
19 } SortStruct; |
11 } SortStruct; |
20 |
12 |
|
13 int CDECL GeneralOwnerSorter(const void *a, const void *b); |
|
14 void VehicleSorter(SortStruct *firstelement, uint32 n, uint16 size); |
|
15 VARDEF uint32 _internal_name_sorter_id; // internal StringID for default vehicle-names |
|
16 VARDEF uint32 _last_vehicle_idx; // cached index to hopefully speed up name-sorting |
|
17 VARDEF bool _internal_sort_order; // descending/ascending |
|
18 |
21 #define PERIODIC_RESORT_DAYS 10 |
19 #define PERIODIC_RESORT_DAYS 10 |
|
20 #define DEF_SORTER(yyyy) int CDECL yyyy(const void *a, const void *b) |
22 |
21 |
23 enum VehicleSortListingTypes { |
22 DEF_SORTER(VehicleUnsortedSorter); |
24 SORT_BY_UNSORTED = 0, |
23 DEF_SORTER(VehicleNumberSorter); |
25 SORT_BY_NUMBER = 1, |
24 DEF_SORTER(VehicleNameSorter); |
26 SORT_BY_NAME = 2, |
25 DEF_SORTER(VehicleAgeSorter); |
27 SORT_BY_AGE = 3, |
26 DEF_SORTER(VehicleProfitThisYearSorter); |
28 SORT_BY_PROFIT_THIS_YEAR = 4, |
27 DEF_SORTER(VehicleProfitLastYearSorter); |
29 SORT_BY_PROFIT_LAST_YEAR = 5, |
28 DEF_SORTER(VehicleCargoSorter); |
30 SORT_BY_TOTAL_CAPACITY_PER_CARGOTYPE = 6, |
29 DEF_SORTER(VehicleReliabilitySorter); |
31 SORT_BY_RELIABILITY = 7, |
30 DEF_SORTER(VehicleMaxSpeedSorter); |
32 SORT_BY_MAX_SPEED = 8 |
31 |
|
32 typedef DEF_SORTER(VehicleSortListingTypeFunctions); |
|
33 |
|
34 static VehicleSortListingTypeFunctions * const _vehicle_sorter[] = { |
|
35 &VehicleUnsortedSorter, |
|
36 &VehicleNumberSorter, |
|
37 &VehicleNameSorter, |
|
38 &VehicleAgeSorter, |
|
39 &VehicleProfitThisYearSorter, |
|
40 &VehicleProfitLastYearSorter, |
|
41 &VehicleCargoSorter, |
|
42 &VehicleReliabilitySorter, |
|
43 &VehicleMaxSpeedSorter |
33 }; |
44 }; |
|
45 |
|
46 #define SORT_BY_UNSORTED 0 |
34 |
47 |
35 static const uint16 _vehicle_sort_listing[] = { |
48 static const uint16 _vehicle_sort_listing[] = { |
36 STR_SORT_BY_UNSORTED, |
49 STR_SORT_BY_UNSORTED, |
37 STR_SORT_BY_NUMBER, |
50 STR_SORT_BY_NUMBER, |
38 STR_SORT_BY_DROPDOWN_NAME, |
51 STR_SORT_BY_DROPDOWN_NAME, |