OpenTTD

order_type.h
Go to the documentation of this file.
1 /* $Id: order_type.h 25735 2013-08-20 20:05:31Z fonsinchen $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #ifndef ORDER_TYPE_H
13 #define ORDER_TYPE_H
14
15 #include "core/enum_type.hpp"
16
17 typedef byte VehicleOrderID;
18 typedef uint16 OrderID;
19 typedef uint16 OrderListID;
20 typedef uint16 DestinationID;
21
23 static const VehicleOrderID INVALID_VEH_ORDER_ID = 0xFF;
25 static const VehicleOrderID MAX_VEH_ORDER_ID = INVALID_VEH_ORDER_ID - 1;
26
28 static const OrderID INVALID_ORDER = 0xFFFF;
29
34 static const uint IMPLICIT_ORDER_ONLY_CAP = 32;
35
37 enum OrderType {
38 OT_BEGIN = 0,
39 OT_NOTHING = 0,
40 OT_GOTO_STATION = 1,
41 OT_GOTO_DEPOT = 2,
42 OT_LOADING = 3,
43 OT_LEAVESTATION = 4,
44 OT_DUMMY = 5,
45 OT_GOTO_WAYPOINT = 6,
46 OT_CONDITIONAL = 7,
47 OT_IMPLICIT = 8,
48 OT_END
49 };
50
52 typedef SimpleTinyEnumT<OrderType, byte> OrderTypeByte;
53
54
58 enum OrderUnloadFlags {
59 OUF_UNLOAD_IF_POSSIBLE = 0,
60 OUFB_UNLOAD = 1 << 0,
61 OUFB_TRANSFER = 1 << 1,
62 OUFB_NO_UNLOAD = 1 << 2,
63 };
64
68 enum OrderLoadFlags {
69 OLF_LOAD_IF_POSSIBLE = 0,
70 OLFB_FULL_LOAD = 1 << 1,
71 OLF_FULL_LOAD_ANY = 3,
72 OLFB_NO_LOAD = 4,
73 };
74
78 enum OrderNonStopFlags {
79 ONSF_STOP_EVERYWHERE = 0,
80 ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS = 1,
81 ONSF_NO_STOP_AT_DESTINATION_STATION = 2,
82 ONSF_NO_STOP_AT_ANY_STATION = 3,
83 ONSF_END
84 };
85
89 enum OrderStopLocation {
90 OSL_PLATFORM_NEAR_END = 0,
91 OSL_PLATFORM_MIDDLE = 1,
92 OSL_PLATFORM_FAR_END = 2,
93 OSL_END
94 };
95
99 enum OrderDepotTypeFlags {
100 ODTF_MANUAL = 0,
101 ODTFB_SERVICE = 1 << 0,
102 ODTFB_PART_OF_ORDERS = 1 << 1,
103 };
104
108 enum OrderDepotActionFlags {
109 ODATF_SERVICE_ONLY = 0,
110 ODATFB_HALT = 1 << 0,
111 ODATFB_NEAREST_DEPOT = 1 << 1,
112 };
113 DECLARE_ENUM_AS_BIT_SET(OrderDepotActionFlags)
114
115
118 enum OrderConditionVariable {
119 OCV_LOAD_PERCENTAGE,
120 OCV_RELIABILITY,
121 OCV_MAX_SPEED,
122 OCV_AGE,
123 OCV_REQUIRES_SERVICE,
124 OCV_UNCONDITIONALLY,
125 OCV_REMAINING_LIFETIME,
126 OCV_END
127 };
128
132 enum OrderConditionComparator {
133 OCC_EQUALS,
134 OCC_NOT_EQUALS,
135 OCC_LESS_THAN,
136 OCC_LESS_EQUALS,
137 OCC_MORE_THAN,
138 OCC_MORE_EQUALS,
139 OCC_IS_TRUE,
140 OCC_IS_FALSE,
141 OCC_END
142 };
143
144
148 enum ModifyOrderFlags {
149 MOF_NON_STOP,
150 MOF_STOP_LOCATION,
151 MOF_UNLOAD,
152 MOF_LOAD,
153 MOF_DEPOT_ACTION,
154 MOF_COND_VARIABLE,
155 MOF_COND_COMPARATOR,
156 MOF_COND_VALUE,
157 MOF_COND_DESTINATION,
158 MOF_END
159 };
160 template <> struct EnumPropsT<ModifyOrderFlags> : MakeEnumPropsT<ModifyOrderFlags, byte, MOF_NON_STOP, MOF_END, MOF_END, 4> {};
161
165 enum OrderDepotAction {
166 DA_ALWAYS_GO,
167 DA_SERVICE,
168 DA_STOP,
169 DA_END
170 };
171
175 enum ModifyTimetableFlags {
176 MTF_WAIT_TIME,
177 MTF_TRAVEL_TIME,
178 MTF_TRAVEL_SPEED,
179 MTF_END
180 };
181 template <> struct EnumPropsT<ModifyTimetableFlags> : MakeEnumPropsT<ModifyTimetableFlags, byte, MTF_WAIT_TIME, MTF_END, MTF_END, 2> {};
182
183
185 enum CloneOptions {
186 CO_SHARE = 0,
187 CO_COPY = 1,
188 CO_UNSHARE = 2
189 };
190
191 struct Order;
192 struct OrderList;
193
194 #endif /* ORDER_TYPE_H */
OrderConditionVariable
OrderConditionVariable
Variables (of a vehicle) to &#39;cause&#39; skipping on.
Definition: order_type.h:118
MakeEnumPropsT
Helper template class that makes basic properties of given enumeration type visible from outsize...
Definition: enum_type.hpp:66
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:31
MTF_TRAVEL_SPEED
Set max travel speed.
Definition: order_type.h:178
MOF_UNLOAD
Passes an OrderUnloadType.
Definition: order_type.h:151
MTF_WAIT_TIME
Set wait time.
Definition: order_type.h:176
OCC_EQUALS
Skip if both values are equal.
Definition: order_type.h:133
OLF_LOAD_IF_POSSIBLE
Load as long as there is cargo that fits in the train.
Definition: order_type.h:69
INVALID_VEH_ORDER_ID
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
Definition: order_type.h:23
MOF_DEPOT_ACTION
Selects the OrderDepotAction.
Definition: order_type.h:153
OCC_IS_TRUE
Skip if the variable is true.
Definition: order_type.h:139
OCV_RELIABILITY
Skip based on the reliability.
Definition: order_type.h:120
OSL_PLATFORM_MIDDLE
Stop at the middle of the platform.
Definition: order_type.h:91
MOF_COND_COMPARATOR
A comparator changes.
Definition: order_type.h:155
OUF_UNLOAD_IF_POSSIBLE
Unload all cargo that the station accepts.
Definition: order_type.h:59
ODATF_SERVICE_ONLY
Only service the vehicle.
Definition: order_type.h:109
OrderTypeByte
SimpleTinyEnumT< OrderType, byte > OrderTypeByte
It needs to be 8bits, because we save and load it as such.
Definition: order_type.h:52
OrderNonStopFlags
OrderNonStopFlags
Non-stop order flags.
Definition: order_type.h:78
OCC_MORE_EQUALS
Skip if the value is more or equal to the limit.
Definition: order_type.h:138
ModifyTimetableFlags
ModifyTimetableFlags
Enumeration for the data to set in CmdChangeTimetable.
Definition: order_type.h:175
Order
Definition: order_base.h:34
OCV_AGE
Skip based on the age.
Definition: order_type.h:122
enum_type.hpp
Type (helpers) for enums.
ONSF_NO_STOP_AT_DESTINATION_STATION
The vehicle will stop at any station it passes except the destination.
Definition: order_type.h:81
OSL_PLATFORM_NEAR_END
Stop at the near end of the platform.
Definition: order_type.h:90
MTF_TRAVEL_TIME
Set travel time.
Definition: order_type.h:177
OSL_PLATFORM_FAR_END
Stop at the far end of the platform.
Definition: order_type.h:92
ONSF_STOP_EVERYWHERE
The vehicle will stop at any station it passes and the destination.
Definition: order_type.h:79
MOF_STOP_LOCATION
Passes an OrderStopLocation.
Definition: order_type.h:150
OrderList
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Definition: order_base.h:252
ONSF_NO_STOP_AT_ANY_STATION
The vehicle will not stop at any stations it passes including the destination.
Definition: order_type.h:82
OLFB_NO_LOAD
Do not load anything.
Definition: order_type.h:72
ODTF_MANUAL
Manually initiated order.
Definition: order_type.h:100
OCC_LESS_EQUALS
Skip if the value is less or equal to the limit.
Definition: order_type.h:136
MOF_COND_DESTINATION
Change the destination of a conditional order.
Definition: order_type.h:157
EnumPropsT
Informative template class exposing basic enumeration properties used by several other templates belo...
Definition: enum_type.hpp:52
OCV_UNCONDITIONALLY
Always skip.
Definition: order_type.h:124
OrderDepotActionFlags
OrderDepotActionFlags
Actions that can be performed when the vehicle enters the depot.
Definition: order_type.h:108
OrderConditionComparator
OrderConditionComparator
Comparator for the skip reasoning.
Definition: order_type.h:132
DA_ALWAYS_GO
Always go to the depot.
Definition: order_type.h:166
ODATFB_HALT
Service the vehicle and then halt it.
Definition: order_type.h:110
DA_SERVICE
Service only if needed.
Definition: order_type.h:167
MOF_COND_VALUE
The value to set the condition to.
Definition: order_type.h:156
OCV_REMAINING_LIFETIME
Skip based on the remaining lifetime.
Definition: order_type.h:125
OCC_LESS_THAN
Skip if the value is less than the limit.
Definition: order_type.h:135
SimpleTinyEnumT
Template of struct holding enum types (on most archs, enums are stored in an int32).
Definition: enum_type.hpp:139
OrderType
OrderType
Order types.
Definition: order_type.h:37
OUFB_TRANSFER
Transfer all cargo onto the platform.
Definition: order_type.h:61
OCV_REQUIRES_SERVICE
Skip when the vehicle requires service.
Definition: order_type.h:123
OrderUnloadFlags
OrderUnloadFlags
Flags related to the unloading order.
Definition: order_type.h:58
MOF_COND_VARIABLE
A conditional variable changes.
Definition: order_type.h:154
OrderStopLocation
OrderStopLocation
Where to stop the trains.
Definition: order_type.h:89
MOF_NON_STOP
Passes an OrderNonStopFlags.
Definition: order_type.h:149
INVALID_ORDER
static const OrderID INVALID_ORDER
Invalid order (sentinel)
Definition: order_type.h:28
OCC_NOT_EQUALS
Skip if both values are not equal.
Definition: order_type.h:134
OrderLoadFlags
OrderLoadFlags
Flags related to the loading order.
Definition: order_type.h:68
OrderDepotAction
OrderDepotAction
Depot action to switch to when doing a MOF_DEPOT_ACTION.
Definition: order_type.h:165
ODATFB_NEAREST_DEPOT
Send the vehicle to the nearest depot.
Definition: order_type.h:111
OLFB_FULL_LOAD
Full load all cargoes of the consist.
Definition: order_type.h:70
OCV_LOAD_PERCENTAGE
Skip based on the amount of load.
Definition: order_type.h:119
OUFB_NO_UNLOAD
Totally no unloading will be done.
Definition: order_type.h:62
ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
Definition: order_type.h:80
OCV_MAX_SPEED
Skip based on the maximum speed.
Definition: order_type.h:121
MOF_LOAD
Passes an OrderLoadType.
Definition: order_type.h:152
ModifyOrderFlags
ModifyOrderFlags
Enumeration for the data to set in CmdModifyOrder.
Definition: order_type.h:148
VehicleOrderID
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition: order_type.h:17
OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
Definition: order_type.h:60
MAX_VEH_ORDER_ID
static const VehicleOrderID MAX_VEH_ORDER_ID
Last valid VehicleOrderID.
Definition: order_type.h:25
ODTFB_PART_OF_ORDERS
This depot order is because of a regular order.
Definition: order_type.h:102
DA_STOP
Go to the depot and stop there.
Definition: order_type.h:168
OCC_MORE_THAN
Skip if the value is more than the limit.
Definition: order_type.h:137
OLF_FULL_LOAD_ANY
Full load a single cargo of the consist.
Definition: order_type.h:71
ODTFB_SERVICE
This depot order is because of the servicing limit.
Definition: order_type.h:101
OCC_IS_FALSE
Skip if the variable is false.
Definition: order_type.h:140
CloneOptions
CloneOptions
Clone actions.
Definition: order_type.h:185
IMPLICIT_ORDER_ONLY_CAP
static const uint IMPLICIT_ORDER_ONLY_CAP
Maximum number of orders in implicit-only lists before we start searching harder for duplicates...
Definition: order_type.h:34
OrderDepotTypeFlags
OrderDepotTypeFlags
Reasons that could cause us to go to the depot.
Definition: order_type.h:99