OpenTTD Source: src/order_cmd.h Source File

OpenTTD Source 14.0-beta1

order_cmd.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef ORDER_CMD_H
11 #define ORDER_CMD_H
12
13 #include "command_type.h"
14 #include "order_base.h"
15 #include "misc/endian_buffer.hpp"
16
17 CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16_t data);
18 CommandCost CmdSkipToOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord);
19 CommandCost CmdDeleteOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord);
20 CommandCost CmdInsertOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, const Order &new_order);
21 CommandCost CmdOrderRefit(DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, CargoID cargo);
22 CommandCost CmdCloneOrder(DoCommandFlag flags, CloneOptions action, VehicleID veh_dst, VehicleID veh_src);
23 CommandCost CmdMoveOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID moving_order, VehicleOrderID target_order);
24 CommandCost CmdClearOrderBackup(DoCommandFlag flags, TileIndex tile, ClientID user_id);
25
26 DEF_CMD_TRAIT(CMD_MODIFY_ORDER, CmdModifyOrder, CMD_LOCATION, CMDT_ROUTE_MANAGEMENT)
27 DEF_CMD_TRAIT(CMD_SKIP_TO_ORDER, CmdSkipToOrder, CMD_LOCATION, CMDT_ROUTE_MANAGEMENT)
28 DEF_CMD_TRAIT(CMD_DELETE_ORDER, CmdDeleteOrder, CMD_LOCATION, CMDT_ROUTE_MANAGEMENT)
29 DEF_CMD_TRAIT(CMD_INSERT_ORDER, CmdInsertOrder, CMD_LOCATION, CMDT_ROUTE_MANAGEMENT)
30 DEF_CMD_TRAIT(CMD_ORDER_REFIT, CmdOrderRefit, CMD_LOCATION, CMDT_ROUTE_MANAGEMENT)
31 DEF_CMD_TRAIT(CMD_CLONE_ORDER, CmdCloneOrder, CMD_LOCATION, CMDT_ROUTE_MANAGEMENT)
32 DEF_CMD_TRAIT(CMD_MOVE_ORDER, CmdMoveOrder, CMD_LOCATION, CMDT_ROUTE_MANAGEMENT)
33 DEF_CMD_TRAIT(CMD_CLEAR_ORDER_BACKUP, CmdClearOrderBackup, CMD_CLIENT_ID, CMDT_SERVER_SETTING)
34
35 template <typename Tcont, typename Titer>
36 inline EndianBufferWriter<Tcont, Titer> &operator <<(EndianBufferWriter<Tcont, Titer> &buffer, const Order &order)
37 {
38 return buffer << order.type << order.flags << order.dest << order.refit_cargo << order.wait_time << order.travel_time << order.max_speed;
39 }
40
41 inline EndianBufferReader &operator >>(EndianBufferReader &buffer, Order &order)
42 {
43 return buffer >> order.type >> order.flags >> order.dest >> order.refit_cargo >> order.wait_time >> order.travel_time >> order.max_speed;
44 }
45
46 #endif /* ORDER_CMD_H */
VehicleOrderID
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition: order_type.h:15
CmdModifyOrder
CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16_t data)
Modify an order in the orderlist of a vehicle.
Definition: order_cmd.cpp:1236
CloneOptions
CloneOptions
Clone actions.
Definition: order_type.h:179
CMD_MODIFY_ORDER
@ CMD_MODIFY_ORDER
modify an order (like set full-load)
Definition: command_type.h:238
CmdDeleteOrder
CommandCost CmdDeleteOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord)
Delete an order from the orderlist of a vehicle.
Definition: order_cmd.cpp:998
ModifyOrderFlags
ModifyOrderFlags
Enumeration for the data to set in CmdModifyOrder.
Definition: order_type.h:144
CmdCloneOrder
CommandCost CmdCloneOrder(DoCommandFlag flags, CloneOptions action, VehicleID veh_dst, VehicleID veh_src)
Clone/share/copy an order-list of another vehicle.
Definition: order_cmd.cpp:1527
CmdSkipToOrder
CommandCost CmdSkipToOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord)
Goto order of order-list.
Definition: order_cmd.cpp:1100
CmdMoveOrder
CommandCost CmdMoveOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID moving_order, VehicleOrderID target_order)
Move an order inside the orderlist.
Definition: order_cmd.cpp:1138
CmdInsertOrder
CommandCost CmdInsertOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, const Order &new_order)
Add an order to the orderlist of a vehicle.
Definition: order_cmd.cpp:713
CMD_LOCATION
@ CMD_LOCATION
the command has implicit location argument.
Definition: command_type.h:403
order_base.h
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
Order::type
uint8_t type
The type of order + non-stop flags.
Definition: order_base.h:48
CMD_CLONE_ORDER
@ CMD_CLONE_ORDER
clone (and share) an order
Definition: command_type.h:288
CmdClearOrderBackup
CommandCost CmdClearOrderBackup(DoCommandFlag flags, TileIndex tile, ClientID user_id)
Clear an OrderBackup.
Definition: order_backup.cpp:154
DoCommandFlag
DoCommandFlag
List of flags for a command.
Definition: command_type.h:369
CMD_DELETE_ORDER
@ CMD_DELETE_ORDER
delete an order
Definition: command_type.h:240
endian_buffer.hpp
Order::wait_time
uint16_t wait_time
How long in ticks to wait at the destination.
Definition: order_base.h:54
CMD_INSERT_ORDER
@ CMD_INSERT_ORDER
insert a new order
Definition: command_type.h:241
CMD_ORDER_REFIT
@ CMD_ORDER_REFIT
change the refit information of an order (for "goto depot" )
Definition: command_type.h:287
CMD_CLEAR_ORDER_BACKUP
@ CMD_CLEAR_ORDER_BACKUP
clear the order backup of a given user/tile
Definition: command_type.h:237
CommandCost
Common return value for all commands.
Definition: command_type.h:23
EndianBufferReader
Endian-aware buffer adapter that always reads values in little endian order.
Definition: endian_buffer.hpp:119
CMDT_ROUTE_MANAGEMENT
@ CMDT_ROUTE_MANAGEMENT
Modifications to route management (orders, groups, etc).
Definition: command_type.h:413
CMD_CLIENT_ID
@ CMD_CLIENT_ID
set p2 with the ClientID of the sending client.
Definition: command_type.h:399
VehicleID
uint32_t VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:16
Order::flags
uint8_t flags
Load/unload types, depot order/action types.
Definition: order_base.h:49
command_type.h
Order::refit_cargo
CargoID refit_cargo
Refit CargoID.
Definition: order_base.h:52
ClientID
ClientID
'Unique' identifier to be given to clients
Definition: network_type.h:49
CMD_MOVE_ORDER
@ CMD_MOVE_ORDER
move an order
Definition: command_type.h:346
CmdOrderRefit
CommandCost CmdOrderRefit(DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, CargoID cargo)
Add/remove refit orders from an order.
Definition: order_cmd.cpp:1669
CMDT_SERVER_SETTING
@ CMDT_SERVER_SETTING
Pausing/removing companies/server settings.
Definition: command_type.h:416
Order::max_speed
uint16_t max_speed
How fast the vehicle may go on the way to the destination.
Definition: order_base.h:56
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:20
EndianBufferWriter
Endian-aware buffer adapter that always writes values in little endian order.
Definition: endian_buffer.hpp:26
CMD_SKIP_TO_ORDER
@ CMD_SKIP_TO_ORDER
skip an order to the next of specific one
Definition: command_type.h:239
Order::travel_time
uint16_t travel_time
How long in ticks the journey to this destination should take.
Definition: order_base.h:55
Order
Definition: order_base.h:36
Order::dest
DestinationID dest
The destination of the order.
Definition: order_base.h:50