mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Use auto type when sorting dates (#11175)
This commit is contained in:
parent
6f057cbe6a
commit
93069066f9
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue