Changeset - r10161:fbc2bd5a86b2
[Not reviewed]
master
0 2 0
belugas - 16 years ago 2008-09-17 02:30:24
belugas@openttd.org
(svn r14352) -Feature: Allow sorting vehicles by remaining life time.
Patch by yorick
2 files changed with 11 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -380,6 +380,7 @@ STR_SORT_BY_MAX_SPEED                   
 
STR_SORT_BY_MODEL                                               :Model
 
STR_SORT_BY_VALUE                                               :Value
 
STR_SORT_BY_LENGTH                                              :Length
 
STR_SORT_BY_LIFE_TIME                                           :Remaining life time
 
STR_SORT_BY_FACILITY                                            :Station type
 
STR_SORT_BY_WAITING                                             :Waiting cargo value
 
STR_SORT_BY_RATING_MAX                                          :Cargo rating
src/vehicle_gui.cpp
Show inline comments
 
@@ -57,6 +57,7 @@ static GUIVehicleList::SortFunction Vehi
 
static GUIVehicleList::SortFunction VehicleModelSorter;
 
static GUIVehicleList::SortFunction VehicleValueSorter;
 
static GUIVehicleList::SortFunction VehicleLengthSorter;
 
static GUIVehicleList::SortFunction VehicleTimeToLiveSorter;
 

	
 
GUIVehicleList::SortFunction* const BaseVehicleListWindow::vehicle_sorter_funcs[] = {
 
	&VehicleNumberSorter,
 
@@ -70,6 +71,7 @@ GUIVehicleList::SortFunction* const Base
 
	&VehicleModelSorter,
 
	&VehicleValueSorter,
 
	&VehicleLengthSorter,
 
	&VehicleTimeToLiveSorter,
 
};
 

	
 
const StringID BaseVehicleListWindow::vehicle_sorter_names[] = {
 
@@ -84,6 +86,7 @@ const StringID BaseVehicleListWindow::ve
 
	STR_SORT_BY_MODEL,
 
	STR_SORT_BY_VALUE,
 
	STR_SORT_BY_LENGTH,
 
	STR_SORT_BY_LIFE_TIME,
 
	INVALID_STRING_ID
 
};
 

	
 
@@ -629,6 +632,13 @@ static int CDECL VehicleLengthSorter(con
 
	return (r != 0) ? r : VehicleNumberSorter(a, b);
 
}
 

	
 
/** Sort vehicles by the time they can still live */
 
static int CDECL VehicleTimeToLiveSorter(const Vehicle* const *a, const Vehicle* const *b)
 
{
 
	int r = ClampToI32(((*a)->max_age - (*a)->age) - ((*b)->max_age - (*b)->age));
 
	return (r != 0) ? r : VehicleNumberSorter(a, b);
 
}
 

	
 
void InitializeGUI()
 
{
 
	MemSetT(&_sorting, 0);
0 comments (0 inline, 0 general)