OpenTTD Source 20241224-master-gee860a5c8e
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)
 
EndianBufferReaderoperator>> (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
flagsFor command.
tileTile related to the to-be-cleared OrderBackup.
user_idUser 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 
)

◆ CmdDeleteOrder()

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

Delete an order from the orderlist of a vehicle.

Parameters
flagsoperation to perform
veh_idthe ID of the vehicle
sel_ordthe 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
flagsoperation to perform
vehID of the vehicle
sel_ordthe 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_orderorder 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
flagsoperation to perform
vehID of the vehicle
sel_ordthe 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.
mofwhat data to modify (
See also
ModifyOrderFlags)
Parameters
datathe 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
flagsoperation to perform
vehthe ID of the vehicle
moving_orderthe order to move
target_orderthe 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()

◆ CmdSkipToOrder()

◆ 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.