* Determines order of train engines 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 */
| 318 | * @return for descending order: returns true if a < b. Vice versa for ascending order |
| 319 | */ |
| 320 | static bool TrainEngineCapacitySorter(const GUIEngineListItem &a, const GUIEngineListItem &b) |
| 321 | { |
| 322 | const RailVehicleInfo *rvi_a = RailVehInfo(a.engine_id); |
| 323 | const RailVehicleInfo *rvi_b = RailVehInfo(b.engine_id); |
| 324 | |
| 325 | int va = GetTotalCapacityOfArticulatedParts(a.engine_id) * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1); |
| 326 | int vb = GetTotalCapacityOfArticulatedParts(b.engine_id) * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1); |
| 327 | int r = va - vb; |
| 328 | |
| 329 | /* Use EngineID to sort instead since we want consistent sorting */ |
| 330 | if (r == 0) return EngineNumberSorter(a, b); |
| 331 | return _engine_sort_direction ? r > 0 : r < 0; |
| 332 | } |
| 333 | |
| 334 | /** |
| 335 | * Determines order of train engines by engine / wagon |
nothing calls this directly
no test coverage detected