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

Function CmdDeleteOrder

src/order_cmd.cpp:934–950  ·  view source on GitHub ↗

* Delete an order from the orderlist of a vehicle. * @param flags operation to perform * @param veh_id the ID of the vehicle * @param sel_ord the order to delete (max 255) * @return the cost of this operation or an error */

Source from the content-addressed store, hash-verified

932 * @return the cost of this operation or an error
933 */
934CommandCost CmdDeleteOrder(DoCommandFlags flags, VehicleID veh_id, VehicleOrderID sel_ord)
935{
936 Vehicle *v = Vehicle::GetIfValid(veh_id);
937
938 if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
939
940 CommandCost ret = CheckOwnership(v->owner);
941 if (ret.Failed()) return ret;
942
943 /* If we did not select an order, we maybe want to de-clone the orders */
944 if (sel_ord >= v->GetNumOrders()) return DecloneOrder(v, flags);
945
946 if (v->GetOrder(sel_ord) == nullptr) return CMD_ERROR;
947
948 if (flags.Test(DoCommandFlag::Execute)) DeleteOrder(v, sel_ord);
949 return CommandCost();
950}
951
952/**
953 * Cancel the current loading order of the vehicle as the order was deleted.

Callers

nothing calls this directly

Calls 9

CheckOwnershipFunction · 0.85
DecloneOrderFunction · 0.85
DeleteOrderFunction · 0.85
CommandCostClass · 0.85
FailedMethod · 0.80
GetOrderMethod · 0.80
TestMethod · 0.80
IsPrimaryVehicleMethod · 0.45
GetNumOrdersMethod · 0.45

Tested by

no test coverage detected