OpenTTD Source: src/order_base.h Source File

OpenTTD Source 15.0-beta1

order_base.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_BASE_H
11#define ORDER_BASE_H
12
13#include "order_type.h"
14#include "core/pool_type.hpp"
15#include "core/bitmath_func.hpp"
16#include "cargo_type.h"
17#include "depot_type.h"
18#include "station_type.h"
19#include "vehicle_type.h"
20#include "timer/timer_game_tick.h"
21#include "saveload/saveload.h"
22
23typedef Pool<Order, OrderID, 256, 0xFF0000> OrderPool;
24typedef Pool<OrderList, OrderListID, 128, 64000> OrderListPool;
25extern OrderPool _order_pool;
26extern OrderListPool _orderlist_pool;
27
28template <typename, typename>
29class EndianBufferWriter;
30
31/* If you change this, keep in mind that it is saved on 3 places:
32 * - Load_ORDR, all the global orders
33 * - Vehicle -> current_order
34 * - REF_ORDER (all REFs are currently limited to 16 bits!!)
35 */
36 struct Order : OrderPool::PoolItem<&_order_pool> {
37private:
38 friend struct VEHSChunkHandler;
39 friend SaveLoadTable GetOrderDescription();
40 /* So we can use private/protected variables in the saveload code */
41 friend class SlVehicleCommon;
42 friend class SlVehicleDisaster;
43
44 template <typename Tcont, typename Titer>
45 friend EndianBufferWriter<Tcont, Titer> &operator <<(EndianBufferWriter<Tcont, Titer> &buffer, const Order &data);
46 friend class EndianBufferReader &operator >>(class EndianBufferReader &buffer, Order &order);
47
48 uint8_t type = 0;
49 uint8_t flags = 0;
50 DestinationID dest = 0;
51
52 CargoID refit_cargo = CARGO_NO_REFIT;
53
54 uint16_t wait_time = 0;
55 uint16_t travel_time = 0;
56 uint16_t max_speed = UINT16_MAX;
57
58public:
59 Order *next = nullptr;
60
61 Order() {}
62 Order(uint8_t type, uint8_t flags, DestinationID dest) : type(type), flags(flags), dest(dest) {}
63 ~Order();
64
70 inline bool IsType(OrderType type) const { return this->GetType() == type; }
71
76 inline OrderType GetType() const { return (OrderType)GB(this->type, 0, 4); }
77
78 void Free();
79
80 void MakeGoToStation(StationID destination);
81 void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type = ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action = ODATF_SERVICE_ONLY, CargoID cargo = CARGO_NO_REFIT);
82 void MakeGoToWaypoint(StationID destination);
83 void MakeLoading(bool ordered);
84 void MakeLeaveStation();
85 void MakeDummy();
86 void MakeConditional(VehicleOrderID order);
87 void MakeImplicit(StationID destination);
88
93 inline bool IsGotoOrder() const
94 {
95 return IsType(OT_GOTO_WAYPOINT) || IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION);
96 }
97
103 inline DestinationID GetDestination() const { return this->dest; }
104
110 inline void SetDestination(DestinationID destination) { this->dest = destination; }
111
117 inline bool IsRefit() const { return this->refit_cargo < NUM_CARGO || this->refit_cargo == CARGO_AUTO_REFIT; }
118
124 inline bool IsAutoRefit() const { return this->refit_cargo == CARGO_AUTO_REFIT; }
125
131 inline CargoID GetRefitCargo() const { return this->refit_cargo; }
132
133 void SetRefit(CargoID cargo);
134
136 inline OrderLoadFlags GetLoadType() const { return (OrderLoadFlags)GB(this->flags, 4, 3); }
138 inline OrderUnloadFlags GetUnloadType() const { return (OrderUnloadFlags)GB(this->flags, 0, 3); }
140 inline OrderNonStopFlags GetNonStopType() const { return (OrderNonStopFlags)GB(this->type, 6, 2); }
142 inline OrderStopLocation GetStopLocation() const { return (OrderStopLocation)GB(this->type, 4, 2); }
144 inline OrderDepotTypeFlags GetDepotOrderType() const { return (OrderDepotTypeFlags)GB(this->flags, 0, 3); }
146 inline OrderDepotActionFlags GetDepotActionType() const { return (OrderDepotActionFlags)GB(this->flags, 3, 4); }
148 inline OrderConditionVariable GetConditionVariable() const { return (OrderConditionVariable)GB(this->dest, 11, 5); }
150 inline OrderConditionComparator GetConditionComparator() const { return (OrderConditionComparator)GB(this->type, 5, 3); }
152 inline VehicleOrderID GetConditionSkipToOrder() const { return this->flags; }
154 inline uint16_t GetConditionValue() const { return GB(this->dest, 0, 11); }
155
157 inline void SetLoadType(OrderLoadFlags load_type) { SB(this->flags, 4, 3, load_type); }
159 inline void SetUnloadType(OrderUnloadFlags unload_type) { SB(this->flags, 0, 3, unload_type); }
161 inline void SetNonStopType(OrderNonStopFlags non_stop_type) { SB(this->type, 6, 2, non_stop_type); }
163 inline void SetStopLocation(OrderStopLocation stop_location) { SB(this->type, 4, 2, stop_location); }
165 inline void SetDepotOrderType(OrderDepotTypeFlags depot_order_type) { SB(this->flags, 0, 3, depot_order_type); }
167 inline void SetDepotActionType(OrderDepotActionFlags depot_service_type) { SB(this->flags, 3, 4, depot_service_type); }
169 inline void SetConditionVariable(OrderConditionVariable condition_variable) { SB(this->dest, 11, 5, condition_variable); }
171 inline void SetConditionComparator(OrderConditionComparator condition_comparator) { SB(this->type, 5, 3, condition_comparator); }
173 inline void SetConditionSkipToOrder(VehicleOrderID order_id) { this->flags = order_id; }
175 inline void SetConditionValue(uint16_t value) { SB(this->dest, 0, 11, value); }
176
177 /* As conditional orders write their "skip to" order all over the flags, we cannot check the
178 * flags to find out if timetabling is enabled. However, as conditional orders are never
179 * autofilled we can be sure that any non-zero values for their wait_time and travel_time are
180 * explicitly set (but travel_time is actually unused for conditionals). */
181
183 inline bool IsWaitTimetabled() const { return this->IsType(OT_CONDITIONAL) ? this->wait_time > 0 : HasBit(this->flags, 3); }
185 inline bool IsTravelTimetabled() const { return this->IsType(OT_CONDITIONAL) ? this->travel_time > 0 : HasBit(this->flags, 7); }
186
188 inline uint16_t GetTimetabledWait() const { return this->IsWaitTimetabled() ? this->wait_time : 0; }
190 inline uint16_t GetTimetabledTravel() const { return this->IsTravelTimetabled() ? this->travel_time : 0; }
192 inline uint16_t GetWaitTime() const { return this->wait_time; }
194 inline uint16_t GetTravelTime() const { return this->travel_time; }
195
201 inline uint16_t GetMaxSpeed() const { return this->max_speed; }
202
204 inline void SetWaitTimetabled(bool timetabled) { if (!this->IsType(OT_CONDITIONAL)) AssignBit(this->flags, 3, timetabled); }
206 inline void SetTravelTimetabled(bool timetabled) { if (!this->IsType(OT_CONDITIONAL)) AssignBit(this->flags, 7, timetabled); }
207
212 inline void SetWaitTime(uint16_t time) { this->wait_time = time; }
213
218 inline void SetTravelTime(uint16_t time) { this->travel_time = time; }
219
225 inline void SetMaxSpeed(uint16_t speed) { this->max_speed = speed; }
226
227 bool ShouldStopAtStation(const Vehicle *v, StationID station) const;
228 bool CanLoadOrUnload() const;
229 bool CanLeaveWithCargo(bool has_cargo) const;
230
231 TileIndex GetLocation(const Vehicle *v, bool airport = false) const;
232
234 inline bool IsCompletelyTimetabled() const
235 {
236 if (!this->IsTravelTimetabled() && !this->IsType(OT_CONDITIONAL)) return false;
237 if (!this->IsWaitTimetabled() && this->IsType(OT_GOTO_STATION) &&
238 !(this->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) {
239 return false;
240 }
241 return true;
242 }
243
244 void AssignOrder(const Order &other);
245 bool Equals(const Order &other) const;
246
247 uint32_t Pack() const;
248 uint16_t MapOldOrder() const;
249 void ConvertFromOldSavegame();
250};
251
252void InsertOrder(Vehicle *v, Order *new_o, VehicleOrderID sel_ord);
253void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord);
254
259 struct OrderList : OrderListPool::PoolItem<&_orderlist_pool> {
260private:
261 friend void AfterLoadVehiclesPhase1(bool part_of_load);
262 friend SaveLoadTable GetOrderListDescription();
263
264 VehicleOrderID num_orders;
265 VehicleOrderID num_manual_orders;
266 uint num_vehicles;
267 Vehicle *first_shared;
268 Order *first;
269
270 TimerGameTick::Ticks timetable_duration;
271 TimerGameTick::Ticks total_duration;
272
273public:
275 OrderList(VehicleOrderID num_orders = INVALID_VEH_ORDER_ID)
276 : num_orders(num_orders), num_manual_orders(0), num_vehicles(0), first_shared(nullptr), first(nullptr),
277 timetable_duration(0), total_duration(0) { }
278
284 OrderList(Order *chain, Vehicle *v) { this->Initialize(chain, v); }
285
287 ~OrderList() {}
288
289 void Initialize(Order *chain, Vehicle *v);
290
291 void RecalculateTimetableDuration();
292
297 inline Order *GetFirstOrder() const { return this->first; }
298
299 Order *GetOrderAt(int index) const;
300
305 inline Order *GetLastOrder() const { return this->GetOrderAt(this->num_orders - 1); }
306
313 inline const Order *GetNext(const Order *curr) const { return (curr->next == nullptr) ? this->GetFirstOrder() : curr->next; }
314
319 inline VehicleOrderID GetNumOrders() const { return this->num_orders; }
320
325 inline VehicleOrderID GetNumManualOrders() const { return this->num_manual_orders; }
326
327 StationIDStack GetNextStoppingStation(const Vehicle *v, const Order *first = nullptr, uint hops = 0) const;
328 const Order *GetNextDecisionNode(const Order *next, uint hops) const;
329
330 void InsertOrderAt(Order *new_order, int index);
331 void DeleteOrderAt(int index);
332 void MoveOrder(int from, int to);
333
338 inline bool IsShared() const { return this->num_vehicles > 1; };
339
344 inline Vehicle *GetFirstSharedVehicle() const { return this->first_shared; }
345
350 inline uint GetNumVehicles() const { return this->num_vehicles; }
351
358 inline void AddVehicle([[maybe_unused]] Vehicle *v) { ++this->num_vehicles; }
359
360 void RemoveVehicle(Vehicle *v);
361
362 bool IsCompleteTimetable() const;
363
368 inline TimerGameTick::Ticks GetTimetableTotalDuration() const { return this->IsCompleteTimetable() ? this->timetable_duration : Ticks::INVALID_TICKS; }
369
374 inline TimerGameTick::Ticks GetTimetableDurationIncomplete() const { return this->timetable_duration; }
375
380 inline TimerGameTick::Ticks GetTotalDuration() const { return this->total_duration; }
381
386 void UpdateTimetableDuration(TimerGameTick::Ticks delta) { this->timetable_duration += delta; }
387
392 void UpdateTotalDuration(TimerGameTick::Ticks delta) { this->total_duration += delta; }
393
394 void FreeChain(bool keep_orderlist = false);
395
396 void DebugCheckSanity() const;
397};
398
399#endif /* ORDER_BASE_H */
bitmath_func.hpp
Functions related to bit mathematics.
HasBit
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition bitmath_func.hpp:103
AssignBit
constexpr T AssignBit(T &x, const uint8_t y, bool value)
Assigns a bit in a variable.
Definition bitmath_func.hpp:200
SB
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
Definition bitmath_func.hpp:58
GB
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Definition bitmath_func.hpp:32
cargo_type.h
Types related to cargoes...
CARGO_NO_REFIT
static const CargoID CARGO_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-renew).
Definition cargo_type.h:78
CargoID
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:22
NUM_CARGO
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
Definition cargo_type.h:74
CARGO_AUTO_REFIT
static const CargoID CARGO_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
Definition cargo_type.h:77
EndianBufferReader
Endian-aware buffer adapter that always reads values in little endian order.
Definition endian_buffer.hpp:119
EndianBufferWriter
Endian-aware buffer adapter that always writes values in little endian order.
Definition endian_buffer.hpp:26
SlVehicleCommon
Definition vehicle_sl.cpp:640
SlVehicleDisaster
Definition vehicle_sl.cpp:1032
SmallStack
Minimal stack that uses a pool to avoid pointers.
Definition smallstack_type.hpp:135
Ticks::INVALID_TICKS
static constexpr TimerGameTick::Ticks INVALID_TICKS
Representation of an invalid number of ticks.
Definition timer_game_tick.h:68
TimerGameTick::Ticks
int32_t Ticks
The type to store ticks in.
Definition timer_game_tick.h:24
depot_type.h
Header files for depots (not hangars)
DepotID
uint16_t DepotID
Type for the unique identifier of depots.
Definition depot_type.h:13
InsertOrder
void InsertOrder(Vehicle *v, Order *new_o, VehicleOrderID sel_ord)
Insert a new order but skip the validation.
Definition order_cmd.cpp:912
DeleteOrder
void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord)
Delete an order but skip the parameter validation.
Definition order_cmd.cpp:1037
order_type.h
Types related to orders.
OrderDepotActionFlags
OrderDepotActionFlags
Actions that can be performed when the vehicle enters the depot.
Definition order_type.h:102
ODATF_SERVICE_ONLY
@ ODATF_SERVICE_ONLY
Only service the vehicle.
Definition order_type.h:103
OrderConditionComparator
OrderConditionComparator
Comparator for the skip reasoning.
Definition order_type.h:128
OrderLoadFlags
OrderLoadFlags
Flags related to the loading order.
Definition order_type.h:62
OrderStopLocation
OrderStopLocation
Where to stop the trains.
Definition order_type.h:83
OrderConditionVariable
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
Definition order_type.h:113
VehicleOrderID
uint8_t VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition order_type.h:15
OrderUnloadFlags
OrderUnloadFlags
Flags related to the unloading order.
Definition order_type.h:52
OrderNonStopFlags
OrderNonStopFlags
Non-stop order flags.
Definition order_type.h:72
ONSF_NO_STOP_AT_DESTINATION_STATION
@ ONSF_NO_STOP_AT_DESTINATION_STATION
The vehicle will stop at any station it passes except the destination.
Definition order_type.h:75
ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
@ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
Definition order_type.h:74
OrderDepotTypeFlags
OrderDepotTypeFlags
Reasons that could cause us to go to the depot.
Definition order_type.h:93
INVALID_VEH_ORDER_ID
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
Definition order_type.h:21
OrderType
OrderType
Order types.
Definition order_type.h:35
pool_type.hpp
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
saveload.h
Functions/types related to saving and loading games.
SaveLoadTable
std::span< const struct SaveLoad > SaveLoadTable
A table of SaveLoad entries.
Definition saveload.h:515
station_type.h
Types related to stations.
OrderList
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Definition order_base.h:259
OrderList::GetTimetableDurationIncomplete
TimerGameTick::Ticks GetTimetableDurationIncomplete() const
Gets the known duration of the vehicles timetable even if the timetable is not complete.
Definition order_base.h:374
OrderList::GetLastOrder
Order * GetLastOrder() const
Get the last order of the order chain.
Definition order_base.h:305
OrderList::DeleteOrderAt
void DeleteOrderAt(int index)
Remove an order from the order list and delete it.
Definition order_cmd.cpp:494
OrderList::AfterLoadVehiclesPhase1
friend void AfterLoadVehiclesPhase1(bool part_of_load)
For instantiating the shared vehicle chain.
Definition vehicle_sl.cpp:256
OrderList::OrderList
OrderList(Order *chain, Vehicle *v)
Create an order list with the given order chain for the given vehicle.
Definition order_base.h:284
OrderList::GetNextStoppingStation
StationIDStack GetNextStoppingStation(const Vehicle *v, const Order *first=nullptr, uint hops=0) const
Recursively determine the next deterministic station to stop at.
Definition order_cmd.cpp:399
OrderList::IsCompleteTimetable
bool IsCompleteTimetable() const
Checks whether all orders of the list have a filled timetable.
Definition order_cmd.cpp:562
OrderList::GetOrderListDescription
friend SaveLoadTable GetOrderListDescription()
Saving and loading of order lists.
Definition order_sl.cpp:201
OrderList::UpdateTotalDuration
void UpdateTotalDuration(TimerGameTick::Ticks delta)
Must be called if an order's timetable is changed to update internal book keeping.
Definition order_base.h:392
OrderList::GetNumVehicles
uint GetNumVehicles() const
Return the number of vehicles that share this orders list.
Definition order_base.h:350
OrderList::GetNextDecisionNode
const Order * GetNextDecisionNode(const Order *next, uint hops) const
Get the next order which will make the given vehicle stop at a station or refit at a depot or evaluat...
Definition order_cmd.cpp:364
OrderList::~OrderList
~OrderList()
Destructor.
Definition order_base.h:287
OrderList::Initialize
void Initialize(Order *chain, Vehicle *v)
Recomputes everything.
Definition order_cmd.cpp:275
OrderList::RemoveVehicle
void RemoveVehicle(Vehicle *v)
Removes the vehicle from the shared order list.
Definition order_cmd.cpp:552
OrderList::num_vehicles
uint num_vehicles
NOSAVE: Number of vehicles that share this order list.
Definition order_base.h:266
OrderList::num_orders
VehicleOrderID num_orders
NOSAVE: How many orders there are in the list.
Definition order_base.h:264
OrderList::InsertOrderAt
void InsertOrderAt(Order *new_order, int index)
Insert a new order into the order chain.
Definition order_cmd.cpp:456
OrderList::AddVehicle
void AddVehicle(Vehicle *v)
Adds the given vehicle to this shared order list.
Definition order_base.h:358
OrderList::GetOrderAt
Order * GetOrderAt(int index) const
Get a certain order of the order chain.
Definition order_cmd.cpp:341
OrderList::OrderList
OrderList(VehicleOrderID num_orders=INVALID_VEH_ORDER_ID)
Default constructor producing an invalid order list.
Definition order_base.h:275
OrderList::GetNext
const Order * GetNext(const Order *curr) const
Get the order after the given one or the first one, if the given one is the last one.
Definition order_base.h:313
OrderList::GetFirstSharedVehicle
Vehicle * GetFirstSharedVehicle() const
Get the first vehicle of this vehicle chain.
Definition order_base.h:344
OrderList::MoveOrder
void MoveOrder(int from, int to)
Move an order to another position within the order list.
Definition order_cmd.cpp:520
OrderList::timetable_duration
TimerGameTick::Ticks timetable_duration
NOSAVE: Total timetabled duration of the order list.
Definition order_base.h:270
OrderList::first
Order * first
First order of the order list.
Definition order_base.h:268
OrderList::UpdateTimetableDuration
void UpdateTimetableDuration(TimerGameTick::Ticks delta)
Must be called if an order's timetable is changed to update internal book keeping.
Definition order_base.h:386
OrderList::first_shared
Vehicle * first_shared
NOSAVE: pointer to the first vehicle in the shared order chain.
Definition order_base.h:267
OrderList::GetTimetableTotalDuration
TimerGameTick::Ticks GetTimetableTotalDuration() const
Gets the total duration of the vehicles timetable or Ticks::INVALID_TICKS is the timetable is not com...
Definition order_base.h:368
OrderList::GetFirstOrder
Order * GetFirstOrder() const
Get the first order of the order chain.
Definition order_base.h:297
OrderList::num_manual_orders
VehicleOrderID num_manual_orders
NOSAVE: How many manually added orders are there in the list.
Definition order_base.h:265
OrderList::GetNumOrders
VehicleOrderID GetNumOrders() const
Get number of orders in the order list.
Definition order_base.h:319
OrderList::RecalculateTimetableDuration
void RecalculateTimetableDuration()
Recomputes Timetable duration.
Definition order_cmd.cpp:305
OrderList::FreeChain
void FreeChain(bool keep_orderlist=false)
Free a complete order chain.
Definition order_cmd.cpp:318
OrderList::GetNumManualOrders
VehicleOrderID GetNumManualOrders() const
Get number of manually added orders in the order list.
Definition order_base.h:325
OrderList::GetTotalDuration
TimerGameTick::Ticks GetTotalDuration() const
Gets the known duration of the vehicles orders, timetabled or not.
Definition order_base.h:380
OrderList::IsShared
bool IsShared() const
Is this a shared order list?
Definition order_base.h:338
OrderList::total_duration
TimerGameTick::Ticks total_duration
NOSAVE: Total (timetabled or not) duration of the order list.
Definition order_base.h:271
Order
Definition order_base.h:36
Order::GetLocation
TileIndex GetLocation(const Vehicle *v, bool airport=false) const
Returns a tile somewhat representing the order destination (not suitable for pathfinding).
Definition order_cmd.cpp:642
Order::IsGotoOrder
bool IsGotoOrder() const
Is this a 'goto' order with a real destination?
Definition order_base.h:93
Order::GetDepotOrderType
OrderDepotTypeFlags GetDepotOrderType() const
What caused us going to the depot?
Definition order_base.h:144
Order::GetRefitCargo
CargoID GetRefitCargo() const
Get the cargo to to refit to.
Definition order_base.h:131
Order::GetTimetabledTravel
uint16_t GetTimetabledTravel() const
Get the time in ticks a vehicle should take to reach the destination or 0 if it's not timetabled.
Definition order_base.h:190
Order::GetConditionVariable
OrderConditionVariable GetConditionVariable() const
What variable do we have to compare?
Definition order_base.h:148
Order::Equals
bool Equals(const Order &other) const
Does this order have the same type, flags and destination?
Definition order_cmd.cpp:175
Order::MapOldOrder
uint16_t MapOldOrder() const
Pack this order into a 16 bits integer as close to the TTD representation as possible.
Definition order_cmd.cpp:208
Order::GetMaxSpeed
uint16_t GetMaxSpeed() const
Get the maxmimum speed in km-ish/h a vehicle is allowed to reach on the way to the destination.
Definition order_base.h:201
Order::SetUnloadType
void SetUnloadType(OrderUnloadFlags unload_type)
Set how the consist must be unloaded.
Definition order_base.h:159
Order::SetLoadType
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
Definition order_base.h:157
Order::max_speed
uint16_t max_speed
How fast the vehicle may go on the way to the destination.
Definition order_base.h:56
Order::ConvertFromOldSavegame
void ConvertFromOldSavegame()
Converts this order from an old savegame's version; it moves all bits to the new location.
Definition order_sl.cpp:26
Order::SetTravelTimetabled
void SetTravelTimetabled(bool timetabled)
Set if the travel time is explicitly timetabled (unless the order is conditional).
Definition order_base.h:206
Order::GetDestination
DestinationID GetDestination() const
Gets the destination of this order.
Definition order_base.h:103
Order::IsType
bool IsType(OrderType type) const
Check whether this order is of the given type.
Definition order_base.h:70
Order::SetNonStopType
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
Definition order_base.h:161
Order::GetConditionSkipToOrder
VehicleOrderID GetConditionSkipToOrder() const
Get the order to skip to.
Definition order_base.h:152
Order::GetStopLocation
OrderStopLocation GetStopLocation() const
Where must we stop at the platform?
Definition order_base.h:142
Order::GetWaitTime
uint16_t GetWaitTime() const
Get the time in ticks a vehicle will probably wait at the destination (timetabled or not).
Definition order_base.h:192
Order::GetType
OrderType GetType() const
Get the type of order of this order.
Definition order_base.h:76
Order::MakeGoToStation
void MakeGoToStation(StationID destination)
Makes this order a Go To Station order.
Definition order_cmd.cpp:75
Order::type
uint8_t type
The type of order + non-stop flags.
Definition order_base.h:48
Order::wait_time
uint16_t wait_time
How long in ticks to wait at the destination.
Definition order_base.h:54
Order::SetDepotOrderType
void SetDepotOrderType(OrderDepotTypeFlags depot_order_type)
Set the cause to go to the depot.
Definition order_base.h:165
Order::IsCompletelyTimetabled
bool IsCompletelyTimetabled() const
Checks if travel_time and wait_time apply to this order and if they are timetabled.
Definition order_base.h:234
Order::GetLoadType
OrderLoadFlags GetLoadType() const
How must the consist be loaded?
Definition order_base.h:136
Order::SetWaitTime
void SetWaitTime(uint16_t time)
Set the time in ticks to wait at the destination.
Definition order_base.h:212
Order::SetStopLocation
void SetStopLocation(OrderStopLocation stop_location)
Set where we must stop at the platform.
Definition order_base.h:163
Order::MakeDummy
void MakeDummy()
Makes this order a Dummy order.
Definition order_cmd.cpp:133
Order::MakeGoToWaypoint
void MakeGoToWaypoint(StationID destination)
Makes this order a Go To Waypoint order.
Definition order_cmd.cpp:104
Order::SetConditionVariable
void SetConditionVariable(OrderConditionVariable condition_variable)
Set variable we have to compare.
Definition order_base.h:169
Order::flags
uint8_t flags
Load/unload types, depot order/action types.
Definition order_base.h:49
Order::MakeGoToDepot
void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type=ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action=ODATF_SERVICE_ONLY, CargoID cargo=CARGO_NO_REFIT)
Makes this order a Go To Depot order.
Definition order_cmd.cpp:90
Order::IsWaitTimetabled
bool IsWaitTimetabled() const
Does this order have an explicit wait time set?
Definition order_base.h:183
Order::SetTravelTime
void SetTravelTime(uint16_t time)
Set the time in ticks to take for travelling to the destination.
Definition order_base.h:218
Order::next
Order * next
Pointer to next order. If nullptr, end of list.
Definition order_base.h:59
Order::GetOrderDescription
friend SaveLoadTable GetOrderDescription()
Saving and loading of orders.
Definition order_sl.cpp:105
Order::dest
DestinationID dest
The destination of the order.
Definition order_base.h:50
Order::~Order
~Order()
Clean everything up.
Definition order_cmd.cpp:47
Order::SetDestination
void SetDestination(DestinationID destination)
Sets the destination of this order.
Definition order_base.h:110
Order::SetRefit
void SetRefit(CargoID cargo)
Make this depot/station order also a refit order.
Definition order_cmd.cpp:165
Order::SetWaitTimetabled
void SetWaitTimetabled(bool timetabled)
Set if the wait time is explicitly timetabled (unless the order is conditional).
Definition order_base.h:204
Order::Pack
uint32_t Pack() const
Pack this order into a 32 bits integer, or actually only the type, flags and destination.
Definition order_cmd.cpp:198
Order::IsTravelTimetabled
bool IsTravelTimetabled() const
Does this order have an explicit travel time set?
Definition order_base.h:185
Order::SetConditionComparator
void SetConditionComparator(OrderConditionComparator condition_comparator)
Set the comparator to use.
Definition order_base.h:171
Order::MakeConditional
void MakeConditional(VehicleOrderID order)
Makes this order an conditional order.
Definition order_cmd.cpp:143
Order::SetDepotActionType
void SetDepotActionType(OrderDepotActionFlags depot_service_type)
Set what we are going to do in the depot.
Definition order_base.h:167
Order::SetConditionSkipToOrder
void SetConditionSkipToOrder(VehicleOrderID order_id)
Get the order to skip to.
Definition order_base.h:173
Order::GetDepotActionType
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
Definition order_base.h:146
Order::MakeLeaveStation
void MakeLeaveStation()
Makes this order a Leave Station order.
Definition order_cmd.cpp:124
Order::CanLeaveWithCargo
bool CanLeaveWithCargo(bool has_cargo) const
A vehicle can leave the current station with cargo if:
Definition order_cmd.cpp:2249
Order::SetConditionValue
void SetConditionValue(uint16_t value)
Set the value to base the skip on.
Definition order_base.h:175
Order::Free
void Free()
'Free' the order
Definition order_cmd.cpp:63
Order::refit_cargo
CargoID refit_cargo
Refit CargoID.
Definition order_base.h:52
Order::GetTimetabledWait
uint16_t GetTimetabledWait() const
Get the time in ticks a vehicle should wait at the destination or 0 if it's not timetabled.
Definition order_base.h:188
Order::ShouldStopAtStation
bool ShouldStopAtStation(const Vehicle *v, StationID station) const
Check whether the given vehicle should stop at the given station based on this order and the non-stop...
Definition order_cmd.cpp:2225
Order::GetTravelTime
uint16_t GetTravelTime() const
Get the time in ticks a vehicle will probably take to reach the destination (timetabled or not).
Definition order_base.h:194
Order::MakeImplicit
void MakeImplicit(StationID destination)
Makes this order an implicit order.
Definition order_cmd.cpp:154
Order::IsAutoRefit
bool IsAutoRefit() const
Is this order a auto-refit order.
Definition order_base.h:124
Order::GetUnloadType
OrderUnloadFlags GetUnloadType() const
How must the consist be unloaded?
Definition order_base.h:138
Order::AssignOrder
void AssignOrder(const Order &other)
Assign data to an order (from another order) This function makes sure that the index is maintained co...
Definition order_cmd.cpp:257
Order::GetConditionComparator
OrderConditionComparator GetConditionComparator() const
What is the comparator to use?
Definition order_base.h:150
Order::GetNonStopType
OrderNonStopFlags GetNonStopType() const
At which stations must we stop?
Definition order_base.h:140
Order::IsRefit
bool IsRefit() const
Is this order a refit order.
Definition order_base.h:117
Order::MakeLoading
void MakeLoading(bool ordered)
Makes this order a Loading order.
Definition order_cmd.cpp:115
Order::GetConditionValue
uint16_t GetConditionValue() const
Get the value to base the skip on.
Definition order_base.h:154
Order::SetMaxSpeed
void SetMaxSpeed(uint16_t speed)
Set the maxmimum speed in km-ish/h a vehicle is allowed to reach on the way to the destination.
Definition order_base.h:225
Order::travel_time
uint16_t travel_time
How long in ticks the journey to this destination should take.
Definition order_base.h:55
Pool::PoolItem
Base class for all PoolItems.
Definition pool_type.hpp:237
Pool::PoolItem<&_orderlist_pool >::index
Tindex index
Index of this pool item.
Definition pool_type.hpp:238
Pool
Base class for all pools.
Definition pool_type.hpp:80
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
VEHSChunkHandler
Definition vehicle_sl.cpp:1100
Vehicle
Vehicle data structure.
Definition vehicle_base.h:244
timer_game_tick.h
Definition of the tick-based game-timer.
vehicle_type.h
Types related to vehicles.