OpenTTD Source  20241108-master-g80f628063a
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. More...
 
CommandCost CmdSkipToOrder (DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord)
 Goto order of order-list. More...
 
CommandCost CmdDeleteOrder (DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord)
 Delete an order from the orderlist of a vehicle. More...
 
CommandCost CmdInsertOrder (DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, const Order &new_order)
 Add an order to the orderlist of a vehicle. More...
 
CommandCost CmdOrderRefit (DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, CargoID cargo)
 Add/remove refit orders from an order. More...
 
CommandCost CmdCloneOrder (DoCommandFlag flags, CloneOptions action, VehicleID veh_dst, VehicleID veh_src)
 Clone/share/copy an order-list of another vehicle. More...
 
CommandCost CmdMoveOrder (DoCommandFlag flags, VehicleID veh, VehicleOrderID moving_order, VehicleOrderID target_order)
 Move an order inside the orderlist. More...
 
CommandCost CmdClearOrderBackup (DoCommandFlag flags, TileIndex tile, ClientID user_id)
 Clear an OrderBackup. More...
 
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 
)

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

Parameters
flagsoperation to perform
actionaction to perform
veh_dstdestination vehicle to clone orders to
veh_srcsource 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 CheckOwnership(), CMD_ERROR, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Vehicle::IsPrimaryVehicle(), and Vehicle::owner.

◆ 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 CARGO_NO_REFIT, CheckOwnership(), CMD_ERROR, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Order::GetMaxSpeed(), Order::GetRefitCargo(), Order::GetTravelTime(), Order::GetType(), Order::GetWaitTime(), Vehicle::IsPrimaryVehicle(), and Vehicle::owner.

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

◆ 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(), InvalidateVehicleOrder(), Vehicle::IsPrimaryVehicle(), OrderList::MoveOrder(), Vehicle::NextShared(), Vehicle::orders, Vehicle::Orders(), Vehicle::owner, and BaseConsist::ResetDepotUnbunching().

◆ CmdOrderRefit()

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

Add/remove refit orders from an order.

Parameters
flagsoperation to perform
vehVehicleIndex of the vehicle having the order
order_numbernumber of order to modify
cargoCargoID
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, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Vehicle::GetOrder(), Vehicle::IsPrimaryVehicle(), Order::IsType(), NUM_CARGO, and Vehicle::owner.

◆ CmdSkipToOrder()

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

Goto order of order-list.

Parameters
flagsoperation to perform
veh_idThe ID of the vehicle which order is skipped
sel_ordthe 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, Vehicle::current_order, DC_EXEC, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Vehicle::GetNumOrders(), Vehicle::IsPrimaryVehicle(), Order::IsType(), and Vehicle::owner.