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

Function RoadVehEngineCapacitySorter

src/build_vehicle_gui.cpp:359–368  ·  view source on GitHub ↗

* Determines order of road vehicles 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

357 * @return for descending order: returns true if a < b. Vice versa for ascending order
358 */
359static bool RoadVehEngineCapacitySorter(const GUIEngineListItem &a, const GUIEngineListItem &b)
360{
361 int va = GetTotalCapacityOfArticulatedParts(a.engine_id);
362 int vb = GetTotalCapacityOfArticulatedParts(b.engine_id);
363 int r = va - vb;
364
365 /* Use EngineID to sort instead since we want consistent sorting */
366 if (r == 0) return EngineNumberSorter(a, b);
367 return _engine_sort_direction ? r > 0 : r < 0;
368}
369
370/* Ship vehicle sorting functions */
371

Callers

nothing calls this directly

Calls 2

EngineNumberSorterFunction · 0.70

Tested by

no test coverage detected