OpenTTD Source: src/order_cmd.h File Reference

OpenTTD Source 15.0-beta1

Functions
order_cmd.h File Reference

Command definitions related to orders. More...

`#include "command_type.h"`
`#include "order_base.h"`
`#include "misc/endian_buffer.hpp"`

Go to the source code of this file.

## Functions
CommandCost | CmdModifyOrder (DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16_t data)
| Modify an order in the orderlist of a vehicle.
CommandCost | CmdSkipToOrder (DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord)
| Goto order of order-list.
CommandCost | CmdDeleteOrder (DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord)
| Delete an order from the orderlist of a vehicle.
CommandCost | CmdInsertOrder (DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, const Order &new_order)
| Add an order to the orderlist of a vehicle.
CommandCost | CmdOrderRefit (DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, CargoID cargo)
| Add/remove refit orders from an order.
CommandCost | CmdCloneOrder (DoCommandFlag flags, CloneOptions action, VehicleID veh_dst, VehicleID veh_src)
| Clone/share/copy an order-list of another vehicle.
CommandCost | CmdMoveOrder (DoCommandFlag flags, VehicleID veh, VehicleOrderID moving_order, VehicleOrderID target_order)
| Move an order inside the orderlist.
CommandCost | CmdClearOrderBackup (DoCommandFlag flags, TileIndex tile, ClientID user_id)
| Clear an OrderBackup.
template<typename Tcont , typename Titer >
EndianBufferWriter< Tcont, Titer > & | operator<< (EndianBufferWriter< Tcont, Titer > &buffer, const Order &order)
EndianBufferReader & | operator>> (EndianBufferReader &buffer, Order &order)

## Detailed Description

Command definitions related to orders.

Definition in file order_cmd.h.

## Function Documentation

## ◆ CmdClearOrderBackup()

CommandCost CmdClearOrderBackup | ( | DoCommandFlag | flags,
|  | TileIndex | tile,
|  | ClientID | user_id
| ) |  |

Clear an OrderBackup.

Parameters

  flags | For command.
  tile | Tile related to the to-be-cleared OrderBackup.
  user_id | User that had the OrderBackup.

Returns
  The cost of this operation or an error.

Definition at line 154 of file order_backup.cpp.

References DC_EXEC, INVALID_TILE, and OrderBackup::ResetOfUser().

## ◆ CmdCloneOrder()

CommandCost CmdCloneOrder | ( | DoCommandFlag | flags,
|  | CloneOptions | action,
|  | VehicleID | veh_dst,
|  | VehicleID | veh_src
| ) |  |

Clone/share/copy an order-list of another vehicle.

Parameters

  flags | operation to perform
  action | action to perform
  veh_dst | destination vehicle to clone orders to
  veh_src | source vehicle to clone orders from, if any (none for CO_UNSHARE)

Returns
  the cost of this operation or an error

Definition at line 1522 of file order_cmd.cpp.

References Vehicle::AddToShared(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_order_pool >::CanAllocateItem(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_orderlist_pool >::CanAllocateItem(), CanVehicleUseStation(), CheckAircraftOrderDistance(), CheckOwnership(), CMD_ERROR, DC_EXEC, DecloneOrder(), DeleteVehicleOrders(), CommandCost::Failed(), Vehicle::FirstShared(), SpecializedVehicle< T, Type >::From(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), SpecializedStation< Station, false >::Get(), OrderList::GetFirstOrder(), Vehicle::GetFirstOrder(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Vehicle::GetNumOrders(), GetVehicleCannotUseStationReason(), GetWindowClassForVehicleType(), InvalidateVehicleOrder(), InvalidateWindowClassesData(), Vehicle::IsPrimaryVehicle(), OrderList::IsShared(), Order::next, OrderGoesToStation(), Vehicle::orders, Vehicle::Orders(), Vehicle::owner, BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VIWD_MODIFY_ORDERS, and VIWD_REMOVE_ALL_ORDERS.

## ◆ CmdDeleteOrder()

CommandCost CmdDeleteOrder | ( | DoCommandFlag | flags,
|  | VehicleID | veh_id,
|  | VehicleOrderID | sel_ord
| ) |  |

Delete an order from the orderlist of a vehicle.

Parameters

  flags | operation to perform
  veh_id | the ID of the vehicle
  sel_ord | the order to delete (max 255)

Returns
  the cost of this operation or an error

Definition at line 999 of file order_cmd.cpp.

References CheckOwnership(), CMD_ERROR, DC_EXEC, DecloneOrder(), DeleteOrder(), CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Vehicle::GetNumOrders(), Vehicle::GetOrder(), Vehicle::IsPrimaryVehicle(), and Vehicle::owner.

## ◆ CmdInsertOrder()

CommandCost CmdInsertOrder | ( | DoCommandFlag | flags,
|  | VehicleID | veh,
|  | VehicleOrderID | sel_ord,
|  | const Order & | new_order
| ) |  |

Add an order to the orderlist of a vehicle.

Parameters

  flags | operation to perform
  veh | ID of the vehicle
  sel_ord | the selected order (if any). If the last order is given, the order will be inserted before that one the maximum vehicle order id is 254.
  new_order | order to insert

Returns
  the cost of this operation or an error

Definition at line 697 of file order_cmd.cpp.

References Station::airport, Order::AssignOrder(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_order_pool >::CanAllocateItem(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_orderlist_pool >::CanAllocateItem(), CanVehicleUseStation(), CARGO_NO_REFIT, CheckOwnership(), CMD_ERROR, DC_EXEC, FACIL_BUS_STOP, FACIL_DOCK, FACIL_TRAIN, FACIL_TRUCK_STOP, BaseStation::facilities, CommandCost::Failed(), Vehicle::FirstShared(), Order::GetConditionComparator(), Order::GetConditionSkipToOrder(), Order::GetConditionValue(), Order::GetConditionVariable(), Order::GetDepotActionType(), Order::GetDepotOrderType(), Order::GetDestination(), SpecializedStation< Waypoint, true >::GetIfValid(), SpecializedStation< Station, false >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_depot_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Order::GetLoadType(), Order::GetMaxSpeed(), Order::GetNonStopType(), Vehicle::GetNumOrders(), Order::GetRefitCargo(), Order::GetStopLocation(), GetTileOwner(), Order::GetTravelTime(), Order::GetType(), Order::GetUnloadType(), GetVehicleCannotUseStationReason(), Order::GetWaitTime(), Vehicle::HasConditionalOrder(), Vehicle::HasFullLoadOrder(), Airport::HasHangar(), Vehicle::HasUnbunchingOrder(), InsertOrder(), Vehicle::IsGroundVehicle(), Vehicle::IsPrimaryVehicle(), IsRailDepotTile(), IsRoadDepotTile(), IsShipDepotTile(), MAX_VEH_ORDER_ID, OCC_EQUALS, OCC_IS_FALSE, OCC_IS_TRUE, OCV_LOAD_PERCENTAGE, OCV_RELIABILITY, OCV_REQUIRES_SERVICE, OCV_UNCONDITIONALLY, ODATFB_HALT, ODATFB_NEAREST_DEPOT, ODATFB_UNBUNCH, ODTFB_PART_OF_ORDERS, ODTFB_SERVICE, OLF_FULL_LOAD_ANY, OLF_LOAD_IF_POSSIBLE, OLFB_FULL_LOAD, OLFB_NO_LOAD, ONSF_STOP_EVERYWHERE, Vehicle::orders, OSL_PLATFORM_FAR_END, OSL_PLATFORM_MIDDLE, OSL_PLATFORM_NEAR_END, OUF_UNLOAD_IF_POSSIBLE, OUFB_NO_UNLOAD, OUFB_TRANSFER, OUFB_UNLOAD, BaseStation::owner, Vehicle::owner, OWNER_NONE, BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

## ◆ CmdModifyOrder()

CommandCost CmdModifyOrder | ( | DoCommandFlag | flags,
|  | VehicleID | veh,
|  | VehicleOrderID | sel_ord,
|  | ModifyOrderFlags | mof,
|  | uint16_t | data
| ) |  |

Modify an order in the orderlist of a vehicle.

Parameters

  flags | operation to perform
  veh | ID of the vehicle
  sel_ord | the selected order (if any). If the last order is given, the order will be inserted before that one the maximum vehicle order id is 254.
  mof | what data to modify (

See also
  ModifyOrderFlags)

Parameters

  data | the data to modify

Returns
  the cost of this operation or an error

Definition at line 1237 of file order_cmd.cpp.

References CARGO_NO_REFIT, CheckOwnership(), CMD_ERROR, BaseConsist::cur_real_order_index, Vehicle::current_order, DA_ALWAYS_GO, DA_SERVICE, DA_STOP, DA_UNBUNCH, DC_EXEC, DeleteOrderWarnings(), CommandCost::Failed(), Vehicle::FirstShared(), Order::GetConditionComparator(), Order::GetConditionValue(), Order::GetConditionVariable(), Order::GetDepotActionType(), Order::GetDepotOrderType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Order::GetLoadType(), Order::GetNonStopType(), Vehicle::GetNumOrders(), Vehicle::GetOrder(), Order::GetType(), Order::GetUnloadType(), Vehicle::HasConditionalOrder(), Vehicle::HasFullLoadOrder(), Vehicle::HasUnbunchingOrder(), InvalidateVehicleOrder(), Vehicle::IsGroundVehicle(), Vehicle::IsPrimaryVehicle(), Order::IsType(), MOF_COND_COMPARATOR, MOF_COND_DESTINATION, MOF_COND_VALUE, MOF_COND_VARIABLE, MOF_DEPOT_ACTION, MOF_LOAD, MOF_NON_STOP, MOF_STOP_LOCATION, MOF_UNLOAD, Vehicle::NextShared(), OCC_EQUALS, OCC_IS_FALSE, OCC_IS_TRUE, OCV_LOAD_PERCENTAGE, OCV_RELIABILITY, OCV_REQUIRES_SERVICE, OCV_UNCONDITIONALLY, ODATFB_HALT, ODATFB_UNBUNCH, ODTFB_SERVICE, OLF_FULL_LOAD_ANY, OLF_LOAD_IF_POSSIBLE, OLFB_FULL_LOAD, OLFB_NO_LOAD, ONSF_NO_STOP_AT_DESTINATION_STATION, OUF_UNLOAD_IF_POSSIBLE, OUFB_NO_UNLOAD, OUFB_TRANSFER, OUFB_UNLOAD, Vehicle::owner, BaseConsist::ResetDepotUnbunching(), Order::SetConditionComparator(), Order::SetConditionSkipToOrder(), Order::SetConditionValue(), Order::SetConditionVariable(), Order::SetDepotActionType(), Order::SetDepotOrderType(), Order::SetLoadType(), Order::SetNonStopType(), Order::SetRefit(), Order::SetStopLocation(), Order::SetUnloadType(), BaseVehicle::type, VEH_TRAIN, and VIWD_MODIFY_ORDERS.

## ◆ CmdMoveOrder()

CommandCost CmdMoveOrder | ( | DoCommandFlag | flags,
|  | VehicleID | veh,
|  | VehicleOrderID | moving_order,
|  | VehicleOrderID | target_order
| ) |  |

Move an order inside the orderlist.

Parameters

  flags | operation to perform
  veh | the ID of the vehicle
  moving_order | the order to move
  target_order | the target order

Returns
  the cost of this operation or an error

Note
  The target order will move one place down in the orderlist if you move the order upwards else it'll move it one place down

Definition at line 1139 of file order_cmd.cpp.

References CheckOwnership(), CMD_ERROR, BaseConsist::cur_implicit_order_index, BaseConsist::cur_real_order_index, DC_EXEC, DeleteOrderWarnings(), CommandCost::Failed(), Vehicle::FirstShared(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Vehicle::GetNumOrders(), Vehicle::GetOrder(), GetWindowClassForVehicleType(), InvalidateVehicleOrder(), InvalidateWindowClassesData(), Vehicle::IsPrimaryVehicle(), OrderList::MoveOrder(), Vehicle::NextShared(), Vehicle::orders, Vehicle::Orders(), Vehicle::owner, BaseConsist::ResetDepotUnbunching(), and BaseVehicle::type.

## ◆ CmdOrderRefit()

CommandCost CmdOrderRefit | ( | DoCommandFlag | flags,
|  | VehicleID | veh,
|  | VehicleOrderID | order_number,
|  | CargoID | cargo
| ) |  |

Add/remove refit orders from an order.

Parameters

  flags | operation to perform
  veh | VehicleIndex of the vehicle having the order
  order_number | number of order to modify
  cargo | CargoID

Returns
  the cost of this operation or an error

Definition at line 1664 of file order_cmd.cpp.

References CARGO_AUTO_REFIT, CARGO_NO_REFIT, CheckOwnership(), CMD_ERROR, DC_EXEC, CommandCost::Failed(), Vehicle::FirstShared(), Order::GetDepotActionType(), Order::GetDepotOrderType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Order::GetLoadType(), Vehicle::GetOrder(), InvalidateVehicleOrder(), Vehicle::IsPrimaryVehicle(), Order::IsType(), NUM_CARGO, ODATFB_HALT, ODTFB_PART_OF_ORDERS, ODTFB_SERVICE, OLFB_NO_LOAD, Vehicle::owner, Order::SetDepotActionType(), Order::SetDepotOrderType(), Order::SetRefit(), and VIWD_MODIFY_ORDERS.

## ◆ CmdSkipToOrder()

CommandCost CmdSkipToOrder | ( | DoCommandFlag | flags,
|  | VehicleID | veh_id,
|  | VehicleOrderID | sel_ord
| ) |  |

Goto order of order-list.

Parameters

  flags | operation to perform
  veh_id | The ID of the vehicle which order is skipped
  sel_ord | the selected order to which we want to skip

Returns
  the cost of this operation or an error

Definition at line 1101 of file order_cmd.cpp.

References CheckOwnership(), CMD_ERROR, BaseConsist::cur_implicit_order_index, BaseConsist::cur_real_order_index, Vehicle::current_order, DC_EXEC, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Vehicle::GetNumOrders(), InvalidateVehicleOrder(), Vehicle::IsPrimaryVehicle(), Order::IsType(), Vehicle::LeaveStation(), Vehicle::owner, BaseConsist::ResetDepotUnbunching(), SetWindowClassesDirty(), BaseVehicle::type, Vehicle::UpdateRealOrderIndex(), VEH_AIRCRAFT, VEH_SHIP, VIWD_MODIFY_ORDERS, WC_AIRCRAFT_LIST, and WC_SHIPS_LIST.

## ◆ operator<<()

template<typename Tcont , typename Titer >

EndianBufferWriter< Tcont, Titer > & operator<< | ( | EndianBufferWriter< Tcont, Titer > & | buffer,
|  | const Order & | order
| ) |  |
| inline

Definition at line 24 of file order_cmd.h.

## ◆ operator>>()

EndianBufferReader & operator>> | ( | EndianBufferReader & | buffer,
|  | Order & | order
| ) |  |
| inline

Definition at line 41 of file order_cmd.h.