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

Function CmdSkipToOrder

src/order_cmd.cpp:1036–1062  ·  view source on GitHub ↗

* 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 */

Source from the content-addressed store, hash-verified

1034 * @return the cost of this operation or an error
1035 */
1036CommandCost 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

Callers

nothing calls this directly

Calls 12

CheckOwnershipFunction · 0.85
InvalidateVehicleOrderFunction · 0.85
SetWindowClassesDirtyFunction · 0.85
CommandCostClass · 0.85
FailedMethod · 0.80
TestMethod · 0.80
IsTypeMethod · 0.80
LeaveStationMethod · 0.80
UpdateRealOrderIndexMethod · 0.80
ResetDepotUnbunchingMethod · 0.80
IsPrimaryVehicleMethod · 0.45
GetNumOrdersMethod · 0.45

Tested by

no test coverage detected