Codechange: Use auto type when sorting dates (#11175)

This commit is contained in:
Tyler Trahan 2023-08-11 08:18:32 -04:00 committed by GitHub
parent 6f057cbe6a
commit 93069066f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -125,9 +125,9 @@ static bool EngineNumberSorter(const GUIEngineListItem &a, const GUIEngineListIt
*/
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);

View File

@ -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);
}

View File

@ -1360,7 +1360,7 @@ static bool VehicleNameSorter(const Vehicle * const &a, const Vehicle * const &b
/** 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);
}