* Goto order of order-list. * @param flags operation to perform * @param veh_id The ID of the vehicle which order is skipped * @param sel_ord the selected order to which we want to skip * @return the cost of this operation or an error */
| 1034 | * @return the cost of this operation or an error |
| 1035 | */ |
| 1036 | CommandCost CmdSkipToOrder(DoCommandFlags flags, VehicleID veh_id, VehicleOrderID sel_ord) |
| 1037 | { |
| 1038 | Vehicle *v = Vehicle::GetIfValid(veh_id); |
| 1039 | |
| 1040 | if (v == nullptr || !v->IsPrimaryVehicle() || sel_ord == v->cur_implicit_order_index || sel_ord >= v->GetNumOrders() || v->GetNumOrders() < 2) return CMD_ERROR; |
| 1041 | |
| 1042 | CommandCost ret = CheckOwnership(v->owner); |
| 1043 | if (ret.Failed()) return ret; |
| 1044 | |
| 1045 | if (flags.Test(DoCommandFlag::Execute)) { |
| 1046 | if (v->current_order.IsType(OT_LOADING)) v->LeaveStation(); |
| 1047 | |
| 1048 | v->cur_implicit_order_index = v->cur_real_order_index = sel_ord; |
| 1049 | v->UpdateRealOrderIndex(); |
| 1050 | |
| 1051 | /* Unbunching data is no longer valid. */ |
| 1052 | v->ResetDepotUnbunching(); |
| 1053 | |
| 1054 | InvalidateVehicleOrder(v, VIWD_MODIFY_ORDERS); |
| 1055 | |
| 1056 | /* We have an aircraft/ship, they have a mini-schedule, so update them all */ |
| 1057 | if (v->type == VEH_AIRCRAFT) SetWindowClassesDirty(WC_AIRCRAFT_LIST); |
| 1058 | if (v->type == VEH_SHIP) SetWindowClassesDirty(WC_SHIPS_LIST); |
| 1059 | } |
| 1060 | |
| 1061 | return CommandCost(); |
| 1062 | } |
| 1063 | |
| 1064 | /** |
| 1065 | * Move an order inside the orderlist |
nothing calls this directly
no test coverage detected