Changeset - r27775:76c248713fb5
[Not reviewed]
master
0 3 0
Tyler Trahan - 13 months ago 2023-08-11 12:18:32
tyler@tylertrahan.com
Codechange: Use auto type when sorting dates (#11175)
3 files changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -125,9 +125,9 @@ static bool EngineNumberSorter(const GUI
 
 */
 
static bool EngineIntroDateSorter(const GUIEngineListItem &a, const GUIEngineListItem &b)
 
{
 
	const int va = Engine::Get(a.engine_id)->intro_date;
 
	const int vb = Engine::Get(b.engine_id)->intro_date;
 
	const int r = va - vb;
 
	const auto va = Engine::Get(a.engine_id)->intro_date;
 
	const auto vb = Engine::Get(b.engine_id)->intro_date;
 
	const auto r = va - vb;
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
	if (r == 0) return EngineNumberSorter(a, b);
src/network/network_gui.cpp
Show inline comments
 
@@ -324,14 +324,14 @@ protected:
 
	/** Sort servers by current date */
 
	static bool NGameDateSorter(NetworkGameList * const &a, NetworkGameList * const &b)
 
	{
 
		int r = a->info.game_date - b->info.game_date;
 
		auto r = a->info.game_date - b->info.game_date;
 
		return (r != 0) ? r < 0 : NGameClientSorter(a, b);
 
	}
 

	
 
	/** Sort servers by the number of days the game is running */
 
	static bool NGameYearsSorter(NetworkGameList * const &a, NetworkGameList * const &b)
 
	{
 
		int r = a->info.game_date - a->info.start_date - b->info.game_date + b->info.start_date;
 
		auto r = a->info.game_date - a->info.start_date - b->info.game_date + b->info.start_date;
 
		return (r != 0) ? r < 0: NGameDateSorter(a, b);
 
	}
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -1360,7 +1360,7 @@ static bool VehicleNameSorter(const Vehi
 
/** Sort vehicles by their age */
 
static bool VehicleAgeSorter(const Vehicle * const &a, const Vehicle * const &b)
 
{
 
	int r = a->age - b->age;
 
	auto r = a->age - b->age;
 
	return (r != 0) ? r < 0 : VehicleNumberSorter(a, b);
 
}
 

	
0 comments (0 inline, 0 general)