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

Function ShipEngineCapacitySorter

src/build_vehicle_gui.cpp:378–390  ·  view source on GitHub ↗

* Determines order of ships by capacity * @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

376 * @return for descending order: returns true if a < b. Vice versa for ascending order
377 */
378static bool ShipEngineCapacitySorter(const GUIEngineListItem &a, const GUIEngineListItem &b)
379{
380 const Engine *e_a = Engine::Get(a.engine_id);
381 const Engine *e_b = Engine::Get(b.engine_id);
382
383 int va = e_a->GetDisplayDefaultCapacity();
384 int vb = e_b->GetDisplayDefaultCapacity();
385 int r = va - vb;
386
387 /* Use EngineID to sort instead since we want consistent sorting */
388 if (r == 0) return EngineNumberSorter(a, b);
389 return _engine_sort_direction ? r > 0 : r < 0;
390}
391
392/* Aircraft sorting functions */
393

Callers

nothing calls this directly

Calls 2

EngineNumberSorterFunction · 0.70

Tested by

no test coverage detected