summaryrefslogtreecommitdiff
path: root/src/newgrf_engine.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-04-12 01:28:11 +0200
committerPeterN <peter@fuzzle.org>2019-04-13 12:49:18 +0100
commit801cbea9cce1e04e6921bb087add8206cffe1fe1 (patch)
tree9ac04e07320af1b5bd0fa8e822ec571e6bd58303 /src/newgrf_engine.cpp
parent5b77102b63f77bfbad02ae3383b87fbef6e60e7d (diff)
downloadopenttd-801cbea9cce1e04e6921bb087add8206cffe1fe1.tar.xz
Codechange: use std::sort() for all std::vector types
Diffstat (limited to 'src/newgrf_engine.cpp')
-rw-r--r--src/newgrf_engine.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index d6f4b0997..3a4318873 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -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) {