mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-12 09:09:09 +00:00
Codechange: use std::sort() for all std::vector types
This commit is contained in:
@@ -1205,19 +1205,19 @@ void AlterVehicleListOrder(EngineID engine, uint target)
|
||||
* @param b right side
|
||||
* @return comparison result
|
||||
*/
|
||||
static int CDECL EnginePreSort(const EngineID *a, const EngineID *b)
|
||||
static bool EnginePreSort(const EngineID &a, const EngineID &b)
|
||||
{
|
||||
const EngineIDMapping &id_a = _engine_mngr.at(*a);
|
||||
const EngineIDMapping &id_b = _engine_mngr.at(*b);
|
||||
const EngineIDMapping &id_a = _engine_mngr.at(a);
|
||||
const EngineIDMapping &id_b = _engine_mngr.at(b);
|
||||
|
||||
/* 1. Sort by engine type */
|
||||
if (id_a.type != id_b.type) return (int)id_a.type - (int)id_b.type;
|
||||
if (id_a.type != id_b.type) return (int)id_a.type < (int)id_b.type;
|
||||
|
||||
/* 2. Sort by scope-GRFID */
|
||||
if (id_a.grfid != id_b.grfid) return id_a.grfid < id_b.grfid ? -1 : 1;
|
||||
if (id_a.grfid != id_b.grfid) return id_a.grfid < id_b.grfid;
|
||||
|
||||
/* 3. Sort by local ID */
|
||||
return (int)id_a.internal_id - (int)id_b.internal_id;
|
||||
return (int)id_a.internal_id < (int)id_b.internal_id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1231,7 +1231,7 @@ void CommitVehicleListOrderChanges()
|
||||
FOR_ALL_ENGINES(e) {
|
||||
ordering.push_back(e->index);
|
||||
}
|
||||
QSortT(ordering.data(), ordering.size(), EnginePreSort);
|
||||
std::sort(ordering.begin(), ordering.end(), EnginePreSort);
|
||||
|
||||
/* Apply Insertion-Sort operations */
|
||||
for (const ListOrderChange &it : _list_order_changes) {
|
||||
|
Reference in New Issue
Block a user