(svn r27729) -Codechange: Do not count static NewGRF when checking for the maximum...
[openttd.git] / src / order_type.h
blobd3a771ce8b777d3be77f6d3831907b76a4067610
1 /* $Id$ */
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 */
10 /** @file order_type.h Types related to orders. */
12 #ifndef ORDER_TYPE_H
13 #define ORDER_TYPE_H
15 #include "core/enum_type.hpp"
17 typedef byte VehicleOrderID; ///< The index of an order within its current vehicle (not pool related)
18 typedef uint16 OrderID;
19 typedef uint16 OrderListID;
20 typedef uint16 DestinationID;
22 /** Invalid vehicle order index (sentinel) */
23 static const VehicleOrderID INVALID_VEH_ORDER_ID = 0xFF;
24 /** Last valid VehicleOrderID. */
25 static const VehicleOrderID MAX_VEH_ORDER_ID = INVALID_VEH_ORDER_ID - 1;
27 /** Invalid order (sentinel) */
28 static const OrderID INVALID_ORDER = 0xFFFF;
30 /**
31 * Maximum number of orders in implicit-only lists before we start searching
32 * harder for duplicates.
34 static const uint IMPLICIT_ORDER_ONLY_CAP = 32;
36 /** Order types */
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
51 /** It needs to be 8bits, because we save and load it as such */
52 typedef SimpleTinyEnumT<OrderType, byte> OrderTypeByte;
55 /**
56 * Flags related to the unloading order.
58 enum OrderUnloadFlags {
59 OUF_UNLOAD_IF_POSSIBLE = 0, ///< Unload all cargo that the station accepts.
60 OUFB_UNLOAD = 1 << 0, ///< Force unloading all cargo onto the platform, possibly not getting paid.
61 OUFB_TRANSFER = 1 << 1, ///< Transfer all cargo onto the platform.
62 OUFB_NO_UNLOAD = 1 << 2, ///< Totally no unloading will be done.
65 /**
66 * Flags related to the loading order.
68 enum OrderLoadFlags {
69 OLF_LOAD_IF_POSSIBLE = 0, ///< Load as long as there is cargo that fits in the train.
70 OLFB_FULL_LOAD = 1 << 1, ///< Full load all cargoes of the consist.
71 OLF_FULL_LOAD_ANY = 3, ///< Full load a single cargo of the consist.
72 OLFB_NO_LOAD = 4, ///< Do not load anything.
75 /**
76 * Non-stop order flags.
78 enum OrderNonStopFlags {
79 ONSF_STOP_EVERYWHERE = 0, ///< The vehicle will stop at any station it passes and the destination.
80 ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS = 1, ///< The vehicle will not stop at any stations it passes except the destination.
81 ONSF_NO_STOP_AT_DESTINATION_STATION = 2, ///< The vehicle will stop at any station it passes except the destination.
82 ONSF_NO_STOP_AT_ANY_STATION = 3, ///< The vehicle will not stop at any stations it passes including the destination.
83 ONSF_END
86 /**
87 * Where to stop the trains.
89 enum OrderStopLocation {
90 OSL_PLATFORM_NEAR_END = 0, ///< Stop at the near end of the platform
91 OSL_PLATFORM_MIDDLE = 1, ///< Stop at the middle of the platform
92 OSL_PLATFORM_FAR_END = 2, ///< Stop at the far end of the platform
93 OSL_END
96 /**
97 * Reasons that could cause us to go to the depot.
99 enum OrderDepotTypeFlags {
100 ODTF_MANUAL = 0, ///< Manually initiated order.
101 ODTFB_SERVICE = 1 << 0, ///< This depot order is because of the servicing limit.
102 ODTFB_PART_OF_ORDERS = 1 << 1, ///< This depot order is because of a regular order.
106 * Actions that can be performed when the vehicle enters the depot.
108 enum OrderDepotActionFlags {
109 ODATF_SERVICE_ONLY = 0, ///< Only service the vehicle.
110 ODATFB_HALT = 1 << 0, ///< Service the vehicle and then halt it.
111 ODATFB_NEAREST_DEPOT = 1 << 1, ///< Send the vehicle to the nearest depot.
113 DECLARE_ENUM_AS_BIT_SET(OrderDepotActionFlags)
116 * Variables (of a vehicle) to 'cause' skipping on.
118 enum OrderConditionVariable {
119 OCV_LOAD_PERCENTAGE, ///< Skip based on the amount of load
120 OCV_RELIABILITY, ///< Skip based on the reliability
121 OCV_MAX_SPEED, ///< Skip based on the maximum speed
122 OCV_AGE, ///< Skip based on the age
123 OCV_REQUIRES_SERVICE, ///< Skip when the vehicle requires service
124 OCV_UNCONDITIONALLY, ///< Always skip
125 OCV_REMAINING_LIFETIME, ///< Skip based on the remaining lifetime
126 OCV_END
130 * Comparator for the skip reasoning.
132 enum OrderConditionComparator {
133 OCC_EQUALS, ///< Skip if both values are equal
134 OCC_NOT_EQUALS, ///< Skip if both values are not equal
135 OCC_LESS_THAN, ///< Skip if the value is less than the limit
136 OCC_LESS_EQUALS, ///< Skip if the value is less or equal to the limit
137 OCC_MORE_THAN, ///< Skip if the value is more than the limit
138 OCC_MORE_EQUALS, ///< Skip if the value is more or equal to the limit
139 OCC_IS_TRUE, ///< Skip if the variable is true
140 OCC_IS_FALSE, ///< Skip if the variable is false
141 OCC_END
146 * Enumeration for the data to set in #CmdModifyOrder.
148 enum ModifyOrderFlags {
149 MOF_NON_STOP, ///< Passes an OrderNonStopFlags.
150 MOF_STOP_LOCATION, ///< Passes an OrderStopLocation.
151 MOF_UNLOAD, ///< Passes an OrderUnloadType.
152 MOF_LOAD, ///< Passes an OrderLoadType
153 MOF_DEPOT_ACTION, ///< Selects the OrderDepotAction
154 MOF_COND_VARIABLE, ///< A conditional variable changes.
155 MOF_COND_COMPARATOR, ///< A comparator changes.
156 MOF_COND_VALUE, ///< The value to set the condition to.
157 MOF_COND_DESTINATION,///< Change the destination of a conditional order.
158 MOF_END
160 template <> struct EnumPropsT<ModifyOrderFlags> : MakeEnumPropsT<ModifyOrderFlags, byte, MOF_NON_STOP, MOF_END, MOF_END, 4> {};
163 * Depot action to switch to when doing a #MOF_DEPOT_ACTION.
165 enum OrderDepotAction {
166 DA_ALWAYS_GO, ///< Always go to the depot
167 DA_SERVICE, ///< Service only if needed
168 DA_STOP, ///< Go to the depot and stop there
169 DA_END
173 * Enumeration for the data to set in #CmdChangeTimetable.
175 enum ModifyTimetableFlags {
176 MTF_WAIT_TIME, ///< Set wait time.
177 MTF_TRAVEL_TIME, ///< Set travel time.
178 MTF_TRAVEL_SPEED, ///< Set max travel speed.
179 MTF_END
181 template <> struct EnumPropsT<ModifyTimetableFlags> : MakeEnumPropsT<ModifyTimetableFlags, byte, MTF_WAIT_TIME, MTF_END, MTF_END, 2> {};
184 /** Clone actions. */
185 enum CloneOptions {
186 CO_SHARE = 0,
187 CO_COPY = 1,
188 CO_UNSHARE = 2
191 struct Order;
192 struct OrderList;
194 #endif /* ORDER_TYPE_H */