* Convert an order index from OpenTTD to a ScriptOrder::OrderPosition (which is the manual order index) * @param order_position The OpenTTD-internal index to convert. * @return An OrderPosition for the same order. */
| 101 | * @return An OrderPosition for the same order. |
| 102 | */ |
| 103 | static ScriptOrder::OrderPosition RealOrderPositionToScriptOrderPosition(VehicleID vehicle_id, int order_position) |
| 104 | { |
| 105 | const Vehicle *v = ::Vehicle::Get(vehicle_id); |
| 106 | |
| 107 | auto orders = v->Orders(); |
| 108 | auto first = std::begin(orders); |
| 109 | auto last = std::ranges::next(first, order_position, std::end(orders)); |
| 110 | int num_implicit = static_cast<int>(std::count_if(first, last, [](const Order &order) { return order.IsType(OT_IMPLICIT); })); |
| 111 | return static_cast<ScriptOrder::OrderPosition>(order_position - num_implicit); |
| 112 | } |
| 113 | |
| 114 | /* static */ bool ScriptOrder::IsGotoStationOrder(VehicleID vehicle_id, OrderPosition order_position) |
| 115 | { |
no test coverage detected