author | convert-repo |
Mon, 07 Apr 2008 16:21:55 +0000 | |
changeset 10076 | dfd70e42c4ae |
parent 9344 | 1be7ac6bd504 |
child 10079 | 99aba130db3c |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9280
9c03416d26b1
(svn r12488) -Codechange: split order.h into order_base.h and order_func.h.
rubidium
parents:
9267
diff
changeset
|
3 |
/** @file order_base.h */ |
2214
75d037f8dcc4
(svn r2732) -Codechange: Cleaned the order flags some more. Hit some inconsistencies while trying to locate bug 1244167
celestar
parents:
2186
diff
changeset
|
4 |
|
9280
9c03416d26b1
(svn r12488) -Codechange: split order.h into order_base.h and order_func.h.
rubidium
parents:
9267
diff
changeset
|
5 |
#ifndef ORDER_BASE_H |
9c03416d26b1
(svn r12488) -Codechange: split order.h into order_base.h and order_func.h.
rubidium
parents:
9267
diff
changeset
|
6 |
#define ORDER_BASE_H |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
diff
changeset
|
7 |
|
9267
71cf88230dc1
(svn r12470) -Codechange: split order related types from order.h (and openttd.h) to order_type.h.
rubidium
parents:
9266
diff
changeset
|
8 |
#include "order_type.h" |
5216
d581e4db95b6
(svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents:
4977
diff
changeset
|
9 |
#include "oldpool.h" |
8609
8c0c3e9dd6a0
(svn r11674) -Codechange: refactor some functions out of macros.h into more logical locations.
rubidium
parents:
8149
diff
changeset
|
10 |
#include "core/bitmath_func.hpp" |
8615
6b91ca653bad
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
8609
diff
changeset
|
11 |
#include "cargo_type.h" |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
12 |
#include "depot_type.h" |
9328
a7ad10a9b0cb
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium
parents:
9280
diff
changeset
|
13 |
#include "station_type.h" |
a7ad10a9b0cb
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium
parents:
9280
diff
changeset
|
14 |
#include "vehicle_type.h" |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
15 |
#include "waypoint_type.h" |
1314
d6a253cf92c3
(svn r1818) -Add: Dynamic orders (up to 64k orders)
truelight
parents:
1093
diff
changeset
|
16 |
|
7887
5740662fc5ce
(svn r10760) -Codechange: make the order struct use the pool item class as super class.
rubidium
parents:
7871
diff
changeset
|
17 |
DECLARE_OLD_POOL(Order, Order, 6, 1000) |
5740662fc5ce
(svn r10760) -Codechange: make the order struct use the pool item class as super class.
rubidium
parents:
7871
diff
changeset
|
18 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
diff
changeset
|
19 |
/* If you change this, keep in mind that it is saved on 3 places: |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3347
diff
changeset
|
20 |
* - Load_ORDR, all the global orders |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3347
diff
changeset
|
21 |
* - Vehicle -> current_order |
7476
7f086e4b2a76
(svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents:
6589
diff
changeset
|
22 |
* - REF_ORDER (all REFs are currently limited to 16 bits!!) |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3347
diff
changeset
|
23 |
*/ |
7887
5740662fc5ce
(svn r10760) -Codechange: make the order struct use the pool item class as super class.
rubidium
parents:
7871
diff
changeset
|
24 |
struct Order : PoolItem<Order, OrderID, &_Order_pool> { |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
25 |
private: |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
26 |
friend const struct SaveLoad *GetVehicleDescription(VehicleType vt); ///< Saving and loading the current order of vehicles. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
27 |
friend void Load_VEHS(); ///< Loading of ancient vehicles. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
28 |
friend const struct SaveLoad *GetOrderDescription(); ///< Saving and loading of orders. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
29 |
|
9334
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
30 |
OrderTypeByte type; ///< The type of order |
9341
00c8dbaaf0ee
(svn r12595) -Codechange: hide Order's flags in the last few cases.
rubidium
parents:
9339
diff
changeset
|
31 |
uint8 flags; ///< 'Sub'type of order |
9336
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
32 |
DestinationID dest; ///< The destination of the order. |
9334
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
33 |
|
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
34 |
CargoID refit_cargo; ///< Refit CargoID |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
35 |
byte refit_subtype; ///< Refit subtype |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
36 |
|
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
37 |
public: |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
38 |
Order *next; ///< Pointer to next order. If NULL, end of list |
6189 | 39 |
|
7476
7f086e4b2a76
(svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents:
6589
diff
changeset
|
40 |
uint16 wait_time; ///< How long in ticks to wait at the destination. |
7f086e4b2a76
(svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents:
6589
diff
changeset
|
41 |
uint16 travel_time; ///< How long in ticks the journey to this destination should take. |
7f086e4b2a76
(svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents:
6589
diff
changeset
|
42 |
|
7887
5740662fc5ce
(svn r10760) -Codechange: make the order struct use the pool item class as super class.
rubidium
parents:
7871
diff
changeset
|
43 |
Order() : refit_cargo(CT_NO_REFIT) {} |
5740662fc5ce
(svn r10760) -Codechange: make the order struct use the pool item class as super class.
rubidium
parents:
7871
diff
changeset
|
44 |
~Order() { this->type = OT_NOTHING; } |
5740662fc5ce
(svn r10760) -Codechange: make the order struct use the pool item class as super class.
rubidium
parents:
7871
diff
changeset
|
45 |
|
7992
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7887
diff
changeset
|
46 |
/** |
9335
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
47 |
* Create an order based on a packed representation of that order. |
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
48 |
* @param packed the packed representation. |
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
49 |
*/ |
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
50 |
Order(uint32 packed); |
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
51 |
|
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
52 |
/** |
7992
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7887
diff
changeset
|
53 |
* Check if a Order really exists. |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
54 |
* @return true if the order is valid. |
7992
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7887
diff
changeset
|
55 |
*/ |
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7887
diff
changeset
|
56 |
inline bool IsValid() const { return this->type != OT_NOTHING; } |
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7887
diff
changeset
|
57 |
|
9330
828cc0ca9654
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium
parents:
9328
diff
changeset
|
58 |
/** |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
59 |
* Check whether this order is of the given type. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
60 |
* @param type the type to check against. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
61 |
* @return true if the order matches. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
62 |
*/ |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
63 |
inline bool IsType(OrderType type) const { return this->type == type; } |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
64 |
|
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
65 |
/** |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
66 |
* Get the type of order of this order. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
67 |
* @return the order type. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
68 |
*/ |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
69 |
inline OrderType GetType() const { return this->type; } |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
70 |
|
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
71 |
/** |
9330
828cc0ca9654
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium
parents:
9328
diff
changeset
|
72 |
* 'Free' the order |
828cc0ca9654
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium
parents:
9328
diff
changeset
|
73 |
* @note ONLY use on "current_order" vehicle orders! |
828cc0ca9654
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium
parents:
9328
diff
changeset
|
74 |
*/ |
6589
addf4b6946d0
(svn r9072) -Codechange: [Orders] added methods to orders to free them and check if they are in use
bjarni
parents:
6574
diff
changeset
|
75 |
void Free(); |
9330
828cc0ca9654
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium
parents:
9328
diff
changeset
|
76 |
|
828cc0ca9654
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium
parents:
9328
diff
changeset
|
77 |
/** |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
78 |
* Makes this order a Go To Station order. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
79 |
* @param destsination the station to go to. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
80 |
*/ |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
81 |
void MakeGoToStation(StationID destination); |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
82 |
|
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
83 |
/** |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
84 |
* Makes this order a Go To Depot order. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
85 |
* @param destination the depot to go to. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
86 |
* @param order is this order a 'default' order, or an overriden vehicle order? |
9334
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
87 |
* @param cargo the cargo type to change to. |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
88 |
* @param subtype the subtype to change to. |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
89 |
*/ |
9334
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
90 |
void MakeGoToDepot(DepotID destination, bool order, CargoID cargo = CT_NO_REFIT, byte subtype = 0); |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
91 |
|
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
92 |
/** |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
93 |
* Makes this order a Go To Waypoint order. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
94 |
* @param destination the waypoint to go to. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
95 |
*/ |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
96 |
void MakeGoToWaypoint(WaypointID destination); |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
97 |
|
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
98 |
/** |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
99 |
* Makes this order a Loading order. |
9339
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
100 |
* @param ordered is this an ordered stop? |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
101 |
*/ |
9339
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
102 |
void MakeLoading(bool ordered); |
9332
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
103 |
|
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
104 |
/** |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
105 |
* Makes this order a Leave Station order. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
106 |
*/ |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
107 |
void MakeLeaveStation(); |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
108 |
|
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
109 |
/** |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
110 |
* Makes this order a Dummy order. |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
111 |
*/ |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
112 |
void MakeDummy(); |
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
113 |
|
2e120d0bd632
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
9331
diff
changeset
|
114 |
/** |
9330
828cc0ca9654
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium
parents:
9328
diff
changeset
|
115 |
* Free a complete order chain. |
828cc0ca9654
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium
parents:
9328
diff
changeset
|
116 |
* @note do not use on "current_order" vehicle orders! |
828cc0ca9654
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium
parents:
9328
diff
changeset
|
117 |
*/ |
6589
addf4b6946d0
(svn r9072) -Codechange: [Orders] added methods to orders to free them and check if they are in use
bjarni
parents:
6574
diff
changeset
|
118 |
void FreeChain(); |
9328
a7ad10a9b0cb
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium
parents:
9280
diff
changeset
|
119 |
|
9334
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
120 |
/** |
9336
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
121 |
* Gets the destination of this order. |
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
122 |
* @pre IsType(OT_GOTO_WAYPOINT) || IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION). |
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
123 |
* @return the destination of the order. |
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
124 |
*/ |
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
125 |
inline DestinationID GetDestination() const { return this->dest; } |
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
126 |
|
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
127 |
/** |
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
128 |
* Sets the destination of this order. |
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
129 |
* @param destination the new destination of the order. |
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
130 |
* @pre IsType(OT_GOTO_WAYPOINT) || IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION). |
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
131 |
*/ |
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
132 |
inline void SetDestination(DestinationID destination) { this->dest = destination; } |
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
133 |
|
3f75a2c5e0d3
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
9335
diff
changeset
|
134 |
/** |
9334
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
135 |
* Is this order a refit order. |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
136 |
* @pre IsType(OT_GOTO_DEPOT) |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
137 |
* @return true if a refit should happen. |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
138 |
*/ |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
139 |
inline bool IsRefit() const { return this->refit_cargo < NUM_CARGO; } |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
140 |
|
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
141 |
/** |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
142 |
* Get the cargo to to refit to. |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
143 |
* @pre IsType(OT_GOTO_DEPOT) |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
144 |
* @return the cargo type. |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
145 |
*/ |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
146 |
inline CargoID GetRefitCargo() const { return this->refit_cargo; } |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
147 |
|
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
148 |
/** |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
149 |
* Get the cargo subtype to to refit to. |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
150 |
* @pre IsType(OT_GOTO_DEPOT) |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
151 |
* @return the cargo subtype. |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
152 |
*/ |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
153 |
inline byte GetRefitSubtype() const { return this->refit_subtype; } |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
154 |
|
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
155 |
/** |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
156 |
* Make this depot order also a refit order. |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
157 |
* @param cargo the cargo type to change to. |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
158 |
* @param subtype the subtype to change to. |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
159 |
* @pre IsType(OT_GOTO_DEPOT). |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
160 |
*/ |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
161 |
void SetRefit(CargoID cargo, byte subtype = 0); |
db2f5161fcba
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium
parents:
9332
diff
changeset
|
162 |
|
9339
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
163 |
/** How must the consist be loaded? */ |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
164 |
inline byte GetLoadType() const { return this->flags & OFB_FULL_LOAD; } |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
165 |
/** How must the consist be unloaded? */ |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
166 |
inline byte GetUnloadType() const { return GB(this->flags, 0, 2); } |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
167 |
/** Where must we stop? */ |
9344
1be7ac6bd504
(svn r12600) -Codechange: make GetNonStopType return a more augmented type; not is there a non-stop order but the kind of non-stop order, so one doesn't need to check _patches.new_nonstop type everywhere.
rubidium
parents:
9341
diff
changeset
|
168 |
OrderNonStopFlags GetNonStopType() const; |
9339
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
169 |
/** What caused us going to the depot? */ |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
170 |
inline byte GetDepotOrderType() const { return this->flags; } |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
171 |
/** What are we going to do when in the depot. */ |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
172 |
inline byte GetDepotActionType() const { return this->flags; } |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
173 |
|
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
174 |
/** Set how the consist must be loaded. */ |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
175 |
inline void SetLoadType(byte load_type) { SB(this->flags, 2, 1, !!load_type); } |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
176 |
/** Set how the consist must be unloaded. */ |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
177 |
inline void SetUnloadType(byte unload_type) { SB(this->flags, 0, 2, unload_type); } |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
178 |
/** Set whether we must stop at stations or not. */ |
9344
1be7ac6bd504
(svn r12600) -Codechange: make GetNonStopType return a more augmented type; not is there a non-stop order but the kind of non-stop order, so one doesn't need to check _patches.new_nonstop type everywhere.
rubidium
parents:
9341
diff
changeset
|
179 |
inline void SetNonStopType(OrderNonStopFlags non_stop_type) { SB(this->flags, 3, 1, !!non_stop_type); } |
9339
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
180 |
/** Set the cause to go to the depot. */ |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
181 |
inline void SetDepotOrderType(byte depot_order_type) { this->flags = depot_order_type; } |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
182 |
/** Set what we are going to do in the depot. */ |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
183 |
inline void SetDepotActionType(byte depot_service_type) { this->flags = depot_service_type; } |
daaa2adbaf99
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
9336
diff
changeset
|
184 |
|
9328
a7ad10a9b0cb
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium
parents:
9280
diff
changeset
|
185 |
bool ShouldStopAtStation(const Vehicle *v, StationID station) const; |
9331
f67d4fd5ed5d
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium
parents:
9330
diff
changeset
|
186 |
|
f67d4fd5ed5d
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium
parents:
9330
diff
changeset
|
187 |
/** |
f67d4fd5ed5d
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium
parents:
9330
diff
changeset
|
188 |
* Assign the given order to this one. |
f67d4fd5ed5d
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium
parents:
9330
diff
changeset
|
189 |
* @param other the data to copy (except next pointer). |
f67d4fd5ed5d
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium
parents:
9330
diff
changeset
|
190 |
*/ |
f67d4fd5ed5d
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium
parents:
9330
diff
changeset
|
191 |
void AssignOrder(const Order &other); |
f67d4fd5ed5d
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium
parents:
9330
diff
changeset
|
192 |
|
f67d4fd5ed5d
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium
parents:
9330
diff
changeset
|
193 |
/** |
f67d4fd5ed5d
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium
parents:
9330
diff
changeset
|
194 |
* Does this order have the same type, flags and destination? |
f67d4fd5ed5d
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium
parents:
9330
diff
changeset
|
195 |
* @param other the second order to compare to. |
f67d4fd5ed5d
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium
parents:
9330
diff
changeset
|
196 |
* @return true if the type, flags and destination match. |
f67d4fd5ed5d
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium
parents:
9330
diff
changeset
|
197 |
*/ |
f67d4fd5ed5d
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium
parents:
9330
diff
changeset
|
198 |
bool Equals(const Order &other) const; |
9335
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
199 |
|
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
200 |
/** |
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
201 |
* Pack this order into a 32 bits integer, or actually only |
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
202 |
* the type, flags and destination. |
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
203 |
* @return the packed representation. |
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
204 |
* @note unpacking is done in the constructor. |
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
205 |
*/ |
18d3658adc60
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium
parents:
9334
diff
changeset
|
206 |
uint32 Pack() const; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
207 |
}; |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
diff
changeset
|
208 |
|
6573 | 209 |
static inline VehicleOrderID GetMaxOrderIndex() |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4351
diff
changeset
|
210 |
{ |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4351
diff
changeset
|
211 |
/* TODO - This isn't the real content of the function, but |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4351
diff
changeset
|
212 |
* with the new pool-system this will be replaced with one that |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
213 |
* _really_ returns the highest index. Now it just returns |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4351
diff
changeset
|
214 |
* the next safe value we are sure about everything is below. |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4351
diff
changeset
|
215 |
*/ |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
216 |
return GetOrderPoolSize() - 1; |
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
217 |
} |
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
218 |
|
6573 | 219 |
static inline VehicleOrderID GetNumOrders() |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
220 |
{ |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4351
diff
changeset
|
221 |
return GetOrderPoolSize(); |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4351
diff
changeset
|
222 |
} |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4351
diff
changeset
|
223 |
|
6589
addf4b6946d0
(svn r9072) -Codechange: [Orders] added methods to orders to free them and check if they are in use
bjarni
parents:
6574
diff
changeset
|
224 |
#define FOR_ALL_ORDERS_FROM(order, start) for (order = GetOrder(start); order != NULL; order = (order->index + 1U < GetOrderPoolSize()) ? GetOrder(order->index + 1U) : NULL) if (order->IsValid()) |
1314
d6a253cf92c3
(svn r1818) -Add: Dynamic orders (up to 64k orders)
truelight
parents:
1093
diff
changeset
|
225 |
#define FOR_ALL_ORDERS(order) FOR_ALL_ORDERS_FROM(order, 0) |
d6a253cf92c3
(svn r1818) -Add: Dynamic orders (up to 64k orders)
truelight
parents:
1093
diff
changeset
|
226 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
diff
changeset
|
227 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
diff
changeset
|
228 |
#define FOR_VEHICLE_ORDERS(v, order) for (order = v->orders; order != NULL; order = order->next) |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
diff
changeset
|
229 |
|
9330
828cc0ca9654
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium
parents:
9328
diff
changeset
|
230 |
/* (Un)pack routines */ |
828cc0ca9654
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium
parents:
9328
diff
changeset
|
231 |
Order UnpackOldOrder(uint16 packed); |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
diff
changeset
|
232 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
diff
changeset
|
233 |
#endif /* ORDER_H */ |