* Determines order of engines by purchase cost * @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 */
| 191 | * @return for descending order: returns true if a < b. Vice versa for ascending order |
| 192 | */ |
| 193 | static bool EngineCostSorter(const GUIEngineListItem &a, const GUIEngineListItem &b) |
| 194 | { |
| 195 | Money va = Engine::Get(a.engine_id)->GetCost(); |
| 196 | Money vb = Engine::Get(b.engine_id)->GetCost(); |
| 197 | int r = ClampTo<int32_t>(va - vb); |
| 198 | |
| 199 | /* Use EngineID to sort instead since we want consistent sorting */ |
| 200 | if (r == 0) return EngineNumberSorter(a, b); |
| 201 | return _engine_sort_direction ? r > 0 : r < 0; |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Determines order of engines by speed |
nothing calls this directly
no test coverage detected