diff options
author | tron <tron@openttd.org> | 2005-09-26 13:38:12 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-09-26 13:38:12 +0000 |
commit | c76f01b6ff9221dd2ebdfc09031c9707d5404ce5 (patch) | |
tree | 5da77b7017fab40c35f85a487eb5cba567cd8d0a | |
parent | d28067445a9d854ccc1d8ce915bf20e8e63c5993 (diff) | |
download | openttd-c76f01b6ff9221dd2ebdfc09031c9707d5404ce5.tar.xz |
(svn r2988) static where static is due
-rw-r--r-- | vehicle_gui.c | 35 | ||||
-rw-r--r-- | vehicle_gui.h | 16 |
2 files changed, 24 insertions, 27 deletions
diff --git a/vehicle_gui.c b/vehicle_gui.c index 1d44f03f9..eba37916c 100644 --- a/vehicle_gui.c +++ b/vehicle_gui.c @@ -26,7 +26,20 @@ static bool _internal_sort_order; // descending/ascending static uint16 _player_num_engines[256]; static byte _railtype_selected_in_replace_gui; -VehicleSortListingTypeFunctions * const _vehicle_sorter[] = { + +typedef int CDECL VehicleSortListingTypeFunction(const void*, const void*); + +static VehicleSortListingTypeFunction VehicleUnsortedSorter; +static VehicleSortListingTypeFunction VehicleNumberSorter; +static VehicleSortListingTypeFunction VehicleNameSorter; +static VehicleSortListingTypeFunction VehicleAgeSorter; +static VehicleSortListingTypeFunction VehicleProfitThisYearSorter; +static VehicleSortListingTypeFunction VehicleProfitLastYearSorter; +static VehicleSortListingTypeFunction VehicleCargoSorter; +static VehicleSortListingTypeFunction VehicleReliabilitySorter; +static VehicleSortListingTypeFunction VehicleMaxSpeedSorter; + +static VehicleSortListingTypeFunction* const _vehicle_sorter[] = { &VehicleUnsortedSorter, &VehicleNumberSorter, &VehicleNameSorter, @@ -51,7 +64,7 @@ const StringID _vehicle_sort_listing[] = { INVALID_STRING_ID }; -const StringID _rail_types_list[] = { +static const StringID _rail_types_list[] = { STR_RAIL_VEHICLES, STR_MONORAIL_VEHICLES, STR_MAGLEV_VEHICLES, @@ -243,7 +256,7 @@ int CDECL GeneralOwnerSorter(const void *a, const void *b) * 3. (uint32)_internal_name_sorter_id: default StringID of the vehicle when no name is set. eg * STR_SV_TRAIN_NAME for trains or STR_SV_AIRCRAFT_NAME for aircraft */ -int CDECL VehicleUnsortedSorter(const void *a, const void *b) +static int CDECL VehicleUnsortedSorter(const void *a, const void *b) { return ((const SortStruct*)a)->index - ((const SortStruct*)b)->index; } @@ -251,7 +264,7 @@ int CDECL VehicleUnsortedSorter(const void *a, const void *b) // if the sorting criteria had the same value, sort vehicle by unitnumber #define VEHICLEUNITNUMBERSORTER(r, a, b) {if (r == 0) {r = a->unitnumber - b->unitnumber;}} -int CDECL VehicleNumberSorter(const void *a, const void *b) +static int CDECL VehicleNumberSorter(const void *a, const void *b) { const Vehicle *va = GetVehicle((*(const SortStruct*)a).index); const Vehicle *vb = GetVehicle((*(const SortStruct*)b).index); @@ -261,7 +274,7 @@ int CDECL VehicleNumberSorter(const void *a, const void *b) } static char _bufcache[64]; // used together with _last_vehicle_idx to hopefully speed up stringsorting -int CDECL VehicleNameSorter(const void *a, const void *b) +static int CDECL VehicleNameSorter(const void *a, const void *b) { const SortStruct *cmp1 = (const SortStruct*)a; const SortStruct *cmp2 = (const SortStruct*)b; @@ -291,7 +304,7 @@ int CDECL VehicleNameSorter(const void *a, const void *b) return (_internal_sort_order & 1) ? -r : r; } -int CDECL VehicleAgeSorter(const void *a, const void *b) +static int CDECL VehicleAgeSorter(const void *a, const void *b) { const Vehicle *va = GetVehicle((*(const SortStruct*)a).index); const Vehicle *vb = GetVehicle((*(const SortStruct*)b).index); @@ -302,7 +315,7 @@ int CDECL VehicleAgeSorter(const void *a, const void *b) return (_internal_sort_order & 1) ? -r : r; } -int CDECL VehicleProfitThisYearSorter(const void *a, const void *b) +static int CDECL VehicleProfitThisYearSorter(const void *a, const void *b) { const Vehicle *va = GetVehicle((*(const SortStruct*)a).index); const Vehicle *vb = GetVehicle((*(const SortStruct*)b).index); @@ -313,7 +326,7 @@ int CDECL VehicleProfitThisYearSorter(const void *a, const void *b) return (_internal_sort_order & 1) ? -r : r; } -int CDECL VehicleProfitLastYearSorter(const void *a, const void *b) +static int CDECL VehicleProfitLastYearSorter(const void *a, const void *b) { const Vehicle *va = GetVehicle((*(const SortStruct*)a).index); const Vehicle *vb = GetVehicle((*(const SortStruct*)b).index); @@ -324,7 +337,7 @@ int CDECL VehicleProfitLastYearSorter(const void *a, const void *b) return (_internal_sort_order & 1) ? -r : r; } -int CDECL VehicleCargoSorter(const void *a, const void *b) +static int CDECL VehicleCargoSorter(const void *a, const void *b) { const Vehicle *va = GetVehicle((*(const SortStruct*)a).index); const Vehicle *vb = GetVehicle((*(const SortStruct*)b).index); @@ -353,7 +366,7 @@ int CDECL VehicleCargoSorter(const void *a, const void *b) return (_internal_sort_order & 1) ? -r : r; } -int CDECL VehicleReliabilitySorter(const void *a, const void *b) +static int CDECL VehicleReliabilitySorter(const void *a, const void *b) { const Vehicle *va = GetVehicle((*(const SortStruct*)a).index); const Vehicle *vb = GetVehicle((*(const SortStruct*)b).index); @@ -364,7 +377,7 @@ int CDECL VehicleReliabilitySorter(const void *a, const void *b) return (_internal_sort_order & 1) ? -r : r; } -int CDECL VehicleMaxSpeedSorter(const void *a, const void *b) +static int CDECL VehicleMaxSpeedSorter(const void *a, const void *b) { const Vehicle *va = GetVehicle((*(const SortStruct*)a).index); const Vehicle *vb = GetVehicle((*(const SortStruct*)b).index); diff --git a/vehicle_gui.h b/vehicle_gui.h index ccb0d889b..0b93ceafd 100644 --- a/vehicle_gui.h +++ b/vehicle_gui.h @@ -21,24 +21,8 @@ void SortVehicleList(struct vehiclelist_d *vl); int CDECL GeneralOwnerSorter(const void *a, const void *b); #define PERIODIC_RESORT_DAYS 10 -#define DEF_SORTER(yyyy) int CDECL yyyy(const void *a, const void *b) - -DEF_SORTER(VehicleUnsortedSorter); -DEF_SORTER(VehicleNumberSorter); -DEF_SORTER(VehicleNameSorter); -DEF_SORTER(VehicleAgeSorter); -DEF_SORTER(VehicleProfitThisYearSorter); -DEF_SORTER(VehicleProfitLastYearSorter); -DEF_SORTER(VehicleCargoSorter); -DEF_SORTER(VehicleReliabilitySorter); -DEF_SORTER(VehicleMaxSpeedSorter); - -typedef DEF_SORTER(VehicleSortListingTypeFunctions); - #define SORT_BY_UNSORTED 0 -extern VehicleSortListingTypeFunctions * const _vehicle_sorter[]; extern const StringID _vehicle_sort_listing[]; -extern const StringID _rail_types_list[]; enum VehicleSortTypes { VEHTRAIN = 0, |