MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / EngineReliabilitySorter

Function EngineReliabilitySorter

src/build_vehicle_gui.cpp:176–185  ·  view source on GitHub ↗

* Determines order of engines by reliability * @param a first engine to compare * @param b second engine to compare * @return for descending order: returns true if a < b. Vice versa for ascending order */

Source from the content-addressed store, hash-verified

174 * @return for descending order: returns true if a < b. Vice versa for ascending order
175 */
176static bool EngineReliabilitySorter(const GUIEngineListItem &a, const GUIEngineListItem &b)
177{
178 const int va = Engine::Get(a.engine_id)->reliability;
179 const int vb = Engine::Get(b.engine_id)->reliability;
180 const int r = va - vb;
181
182 /* Use EngineID to sort instead since we want consistent sorting */
183 if (r == 0) return EngineNumberSorter(a, b);
184 return _engine_sort_direction ? r > 0 : r < 0;
185}
186
187/**
188 * Determines order of engines by purchase cost

Callers

nothing calls this directly

Calls 1

EngineNumberSorterFunction · 0.70

Tested by

no test coverage detected