OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
30 #include "table/strings.h"
37 static_assert(
sizeof(DestinationID) >=
sizeof(
DepotID));
38 static_assert(
sizeof(DestinationID) >=
sizeof(StationID));
48 if (CleaningPool())
return;
52 if (this->IsType(OT_GOTO_STATION) || this->IsType(OT_GOTO_WAYPOINT)) {
64 this->
type = OT_NOTHING;
76 this->
type = OT_GOTO_STATION;
78 this->
dest = destination;
91 this->
type = OT_GOTO_DEPOT;
95 this->
dest = destination;
105 this->
type = OT_GOTO_WAYPOINT;
107 this->
dest = destination;
116 this->
type = OT_LOADING;
117 if (!ordered) this->
flags = 0;
125 this->
type = OT_LEAVESTATION;
134 this->
type = OT_DUMMY;
144 this->
type = OT_CONDITIONAL;
155 this->
type = OT_IMPLICIT;
156 this->
dest = destination;
209 uint16 order = this->
GetType();
210 switch (this->
type) {
211 case OT_GOTO_STATION:
233 Order::Order(uint32 packed)
236 this->
flags =
GB(packed, 8, 8);
237 this->
dest =
GB(packed, 16, 16);
238 this->
next =
nullptr;
336 for (
Order *o = this->
first; o !=
nullptr; o = next) {
341 if (keep_orderlist) {
342 this->
first =
nullptr;
358 if (
index < 0)
return nullptr;
362 while (order !=
nullptr &&
index-- > 0) {
381 if (hops > this->
GetNumOrders() || next ==
nullptr)
return nullptr;
383 if (next->
IsType(OT_CONDITIONAL)) {
393 if (next->
IsType(OT_GOTO_DEPOT)) {
395 if (next->
IsRefit())
return next;
398 if (!next->CanLoadOrUnload()) {
418 if (
first ==
nullptr) {
420 if (next ==
nullptr) {
422 if (next ==
nullptr)
return INVALID_STATION;
428 assert(next !=
nullptr);
436 while (next !=
nullptr && next->
IsType(OT_CONDITIONAL)) {
442 if (advance ==
nullptr || advance ==
first || skip_to == advance) {
443 next = (skip_to ==
first) ?
nullptr : skip_to;
444 }
else if (skip_to ==
nullptr || skip_to ==
first) {
445 next = (advance ==
first) ?
nullptr : advance;
456 if (next ==
nullptr || ((next->
IsType(OT_GOTO_STATION) || next->
IsType(OT_IMPLICIT)) &&
459 return INVALID_STATION;
473 if (this->
first ==
nullptr) {
474 this->
first = new_order;
479 this->
first = new_order;
487 order->
next = new_order;
497 if (new_order->
IsType(OT_GOTO_STATION) || new_order->
IsType(OT_GOTO_WAYPOINT)) {
516 to_remove = this->
first;
520 to_remove = prev->
next;
543 moving_one = this->
first;
547 moving_one = one_before->
next;
548 one_before->
next = moving_one->
next;
554 this->
first = moving_one;
557 moving_one->
next = one_before->
next;
558 one_before->
next = moving_one;
580 if (v_shared == v)
return true;
606 if (o->IsType(OT_IMPLICIT))
continue;
607 if (!o->IsCompletelyTimetabled())
return false;
619 uint check_num_vehicles = 0;
620 Ticks check_timetable_duration = 0;
621 Ticks check_total_duration = 0;
623 DEBUG(misc, 6,
"Checking OrderList %hu for sanity...", this->
index);
627 if (!o->IsType(OT_IMPLICIT)) ++check_num_manual_orders;
628 check_timetable_duration += o->GetTimetabledWait() + o->GetTimetabledTravel();
629 check_total_duration += o->GetWaitTime() + o->GetTravelTime();
637 ++check_num_vehicles;
638 assert(v->orders.list ==
this);
641 DEBUG(misc, 6,
"... detected %u orders (%u manual), %u vehicles, %i timetabled, %i total",
655 return o->
IsType(OT_GOTO_STATION) ||
683 case OT_GOTO_WAYPOINT:
684 case OT_GOTO_STATION:
709 if (cur->
IsType(OT_CONDITIONAL)) {
716 return std::max(dist1, dist2);
748 if (ret.
Failed())
return ret;
753 case OT_GOTO_STATION: {
759 if (ret.
Failed())
return ret;
797 case OT_GOTO_DEPOT: {
805 if (ret.
Failed())
return ret;
816 if (ret.
Failed())
return ret;
843 case OT_GOTO_WAYPOINT: {
854 if (ret.
Failed())
return ret;
862 if (ret.
Failed())
return ret;
874 case OT_CONDITIONAL: {
945 if (sel_ord <= u->cur_real_order_index) {
948 if (cur < u->GetNumOrders()) {
959 if (sel_ord <= u->cur_implicit_order_index) {
962 if (cur < u->GetNumOrders()) {
973 if (order->IsType(OT_CONDITIONAL)) {
975 if (order_id >= sel_ord) {
976 order->SetConditionSkipToOrder(order_id + 1);
978 if (order_id == cur_order_id) {
979 order->SetConditionSkipToOrder((order_id + 1) % v->
GetNumOrders());
1023 if (ret.
Failed())
return ret;
1067 if (sel_ord < u->cur_real_order_index) {
1073 if (sel_ord < u->cur_implicit_order_index) {
1093 if (order->IsType(OT_CONDITIONAL)) {
1095 if (order_id >= sel_ord) {
1096 order_id = std::max(order_id - 1, 0);
1098 if (order_id == cur_order_id) {
1101 order->SetConditionSkipToOrder(order_id);
1128 if (ret.
Failed())
return ret;
1169 if (ret.
Failed())
return ret;
1177 if (moving_one ==
nullptr)
return CMD_ERROR;
1227 if (order->IsType(OT_CONDITIONAL)) {
1229 if (order_id == moving_order) {
1230 order_id = target_order;
1231 }
else if (order_id > moving_order && order_id <= target_order) {
1233 }
else if (order_id < moving_order && order_id >= target_order) {
1236 order->SetConditionSkipToOrder(order_id);
1267 uint16 data =
GB(p2, 4, 11);
1275 if (ret.
Failed())
return ret;
1282 case OT_GOTO_STATION:
1290 case OT_GOTO_WAYPOINT:
1294 case OT_CONDITIONAL:
1303 default: NOT_REACHED();
1463 default: NOT_REACHED();
1504 for (
const Order *o = first; o !=
nullptr; o = o->
next) {
1505 switch (o->GetType()) {
1506 case OT_GOTO_STATION:
1508 case OT_GOTO_WAYPOINT:
1540 if (ret.
Failed())
return ret;
1542 switch (
GB(p1, 30, 2)) {
1550 if (ret.
Failed())
return ret;
1607 if (ret.
Failed())
return ret;
1629 Order *first =
nullptr;
1639 *order_dst =
new Order();
1640 (*order_dst)->AssignOrder(*order);
1641 order_dst = &(*order_dst)->
next;
1690 if (ret.
Failed())
return ret;
1714 if (u->cur_real_order_index == order_number && (u->current_order.GetDepotOrderType() &
ODTFB_PART_OF_ORDERS)) {
1715 u->current_order.SetRefit(cargo);
1752 if (order->IsType(OT_DUMMY)) {
1753 message = STR_NEWS_VEHICLE_HAS_VOID_ORDER;
1757 if (order->IsType(OT_GOTO_STATION)) {
1762 message = STR_NEWS_VEHICLE_HAS_INVALID_ENTRY;
1764 (AircraftVehInfo(v->
engine_type)->subtype & AIR_FAST) &&
1768 message = STR_NEWS_PLANE_USES_TOO_SHORT_RUNWAY;
1778 message = STR_NEWS_VEHICLE_HAS_DUPLICATE_ENTRY;
1783 if (n_st < 2 && message ==
INVALID_STRING_ID) message = STR_NEWS_VEHICLE_HAS_TOO_FEW_ORDERS;
1815 order = &v->current_order;
1816 if ((v->type ==
VEH_AIRCRAFT && order->
IsType(OT_GOTO_DEPOT) && !hangar ? OT_GOTO_STATION : order->
GetType()) == type &&
1817 (!hangar || v->type ==
VEH_AIRCRAFT) && v->current_order.GetDestination() == destination) {
1824 for (
Order *order : v->Orders()) {
1830 if (ot == OT_GOTO_DEPOT && hangar && v->type !=
VEH_AIRCRAFT)
continue;
1831 if (ot == OT_IMPLICIT || (v->type ==
VEH_AIRCRAFT && ot == OT_GOTO_DEPOT && !hangar)) ot = OT_GOTO_STATION;
1836 if (order->
IsType(OT_IMPLICIT)) {
1837 order = order->
next;
1839 if (order !=
nullptr)
goto restart;
1844 v->orders.list->UpdateTotalDuration(-order->
GetWaitTime());
1875 if (order->IsType(OT_GOTO_DEPOT))
return true;
1901 if (!keep_orderlist) v->
orders.
list =
nullptr;
1904 if (reset_order_indices) {
1920 return ispercent ?
Clamp(interval, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) :
Clamp(interval, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
1934 switch (order->GetType()) {
1935 case OT_GOTO_STATION:
1937 case OT_GOTO_WAYPOINT:
1962 default: NOT_REACHED();
1976 bool skip_order =
false;
1989 default: NOT_REACHED();
2011 case OT_GOTO_STATION:
2017 assert(!pbs_look_ahead);
2026 DestinationID destination;
2031 if (pbs_look_ahead && reverse)
return false;
2033 v->SetDestTile(location);
2051 if (pbs_look_ahead)
return false;
2070 case OT_GOTO_WAYPOINT:
2074 case OT_CONDITIONAL: {
2075 assert(!pbs_look_ahead);
2108 if (order !=
nullptr && order->
IsType(OT_IMPLICIT)) {
2113 if (order ==
nullptr) {
2120 return UpdateOrderDest(v, order, conditional_depth + 1, pbs_look_ahead);
2141 case OT_LEAVESTATION:
2176 if (order !=
nullptr && order->
IsType(OT_IMPLICIT)) {
2185 extern void HandleMissingAircraftOrders(
Aircraft *v);
2231 bool is_dest_station = this->
IsType(OT_GOTO_STATION) && this->
dest == station;
2239 bool Order::CanLoadOrUnload()
const
2241 return (this->
IsType(OT_GOTO_STATION) || this->
IsType(OT_IMPLICIT)) &&
@ VEH_AIRCRAFT
Aircraft vehicle type.
Vehicle * first_shared
NOSAVE: pointer to the first vehicle in the shared order chain.
@ DA_STOP
Go to the depot and stop there.
CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Delete an order from the orderlist of a vehicle.
StationFacility facilities
The facilities that this station has.
StationID targetairport
Airport to go to next.
VehicleOrderID cur_implicit_order_index
The index to the current implicit order.
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
bool IsRefit() const
Is this order a refit order.
Cheat no_jetcrash
no jet will crash on small airports anymore
void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord)
Delete an order but skip the parameter validation.
uint32 TileIndex
The index/ID of a Tile.
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
uint16 GetWaitTime() const
Get the time in ticks a vehicle will probably wait at the destination (timetabled or not).
void MakeDummy()
Makes this order a Dummy order.
Minimal stack that uses a pool to avoid pointers.
ModifyOrderFlags
Enumeration for the data to set in CmdModifyOrder.
Titem Pop()
Pop an item from the stack.
void AircraftNextAirportPos_and_Order(Aircraft *v)
set the right pos when heading to other airports after takeoff
@ OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
@ CMD_REVERSE_TRAIN_DIRECTION
turn a train around
bool IsType(OrderType type) const
Check whether this order is of the given type.
static Titem * Get(size_t index)
Returns Titem with given index.
uint16 GetTimetabledWait() const
Get the time in ticks a vehicle should wait at the destination or 0 if it's not timetabled.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Vehicle * PreviousShared() const
Get the previous vehicle of the shared vehicle chain.
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
uint16 GetServiceIntervalClamped(uint interval, bool ispercent)
Clamp the service interval to the correct min/max.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
VehicleOrderID GetNumManualOrders() const
Get the number of manually added orders this vehicle has.
@ MOF_DEPOT_ACTION
Selects the OrderDepotAction.
@ OCC_NOT_EQUALS
Skip if both values are not equal.
void Push(const Titem &item)
Pushes a new item onto the stack if there is still space in the underlying pool.
@ MOF_LOAD
Passes an OrderLoadType.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
@ ODTFB_SERVICE
This depot order is because of the servicing limit.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
uint16 & GetGroundVehicleFlags()
Access the ground vehicle flags of the vehicle.
@ MOF_COND_VALUE
The value to set the condition to.
void CheckOrders(const Vehicle *v)
Check the orders of a vehicle, to see if there are invalid orders and stuff.
@ GVF_SUPPRESS_IMPLICIT_ORDERS
Disable insertion and removal of automatic orders until the vehicle completes the real order.
OrderLoadFlags
Flags related to the loading order.
void MakeLoading(bool ordered)
Makes this order a Loading order.
void MakeLeaveStation()
Makes this order a Leave Station order.
void LeaveStation()
Perform all actions when leaving a station.
@ OUFB_TRANSFER
Transfer all cargo onto the platform.
virtual int GetDisplayMaxSpeed() const
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
@ OLFB_FULL_LOAD
Full load all cargoes of the consist.
DestinationID GetDestination() const
Gets the destination of this order.
VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v)
Process a conditional order and determine the next order.
void InsertOrder(Vehicle *v, Order *new_o, VehicleOrderID sel_ord)
Insert a new order but skip the validation.
Ticks total_duration
NOSAVE: Total (timetabled or not) duration of the order list.
uint16 GetTimetabledTravel() const
Get the time in ticks a vehicle should take to reach the destination or 0 if it's not timetabled.
uint16 GetConditionValue() const
Get the value to base the skip on.
static bool IsRoadDepotTile(TileIndex t)
Return whether a tile is a road depot tile.
void MoveOrder(int from, int to)
Move an order to another position within the order list.
uint16 DepotID
Type for the unique identifier of depots.
Tindex index
Index of this pool item.
@ SHORT_STRIP
This airport has a short landing strip, dangerous for fast aircraft.
uint16 wait_time
How long in ticks to wait at the destination.
@ MOF_UNLOAD
Passes an OrderUnloadType.
@ OSL_PLATFORM_MIDDLE
Stop at the middle of the platform.
void Free()
'Free' the order
void DeleteVehicleNews(VehicleID vid, StringID news)
Delete a news item type about a vehicle.
void SetTravelTimetabled(bool timetabled)
Set if the travel time is explicitly timetabled (unless the order is conditional).
OrderUnloadFlags GetUnloadType() const
How must the consist be unloaded?
Representation of a waypoint.
OrderDepotTypeFlags
Reasons that could cause us to go to the depot.
@ OCC_MORE_THAN
Skip if the value is more than the limit.
static Station * Get(size_t index)
Gets station with given index.
ClientSettings _settings_client
The current settings for this game.
void AssignOrder(const Order &other)
Assign data to an order (from another order) This function makes sure that the index is maintained co...
bool IsCompleteTimetable() const
Checks whether all orders of the list have a filled timetable.
@ WC_VEHICLE_TIMETABLE
Vehicle timetable; Window numbers:
@ MOF_COND_DESTINATION
Change the destination of a conditional order.
@ VEH_ROAD
Road vehicle type.
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
bool IsShared() const
Is this a shared order list?
Owner owner
Which company owns the vehicle?
@ MOF_COND_COMPARATOR
A comparator changes.
@ DC_EXEC
execute the given command
Owner owner
The owner of this station.
static CommandCost DecloneOrder(Vehicle *dst, DoCommandFlag flags)
Declone an order-list.
void RemoveVehicle(Vehicle *v)
Removes the vehicle from the shared order list.
void DeleteVehicleOrders(Vehicle *v, bool keep_orderlist, bool reset_order_indices)
Delete all orders from a vehicle.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
OrderStopLocation
Where to stop the trains.
DoCommandFlag
List of flags for a command.
void UpdateRealOrderIndex()
Skip implicit orders until cur_real_order_index is a non-implicit order.
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...
uint32 Pack() const
Pack this order into a 32 bits integer, or actually only the type, flags and destination.
const AirportFTAClass * GetFTA() const
Get the finite-state machine for this airport or the finite-state machine for the dummy airport in ca...
Ticks timetable_duration
NOSAVE: Total timetabled duration of the order list.
void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type=ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action=ODATF_SERVICE_ONLY, CargoID cargo=CT_NO_REFIT)
Makes this order a Go To Depot order.
OrderType GetType() const
Get the type of order of this order.
Aircraft, helicopters, rotors and their shadows belong to this class.
OrderStopLocation GetStopLocation() const
Where must we stop at the platform?
uint GetOrderDistance(const Order *prev, const Order *cur, const Vehicle *v, int conditional_depth)
Get the distance between two orders of a vehicle.
@ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
OrderNonStopFlags GetNonStopType() const
At which stations must we stop?
IterateWrapper Orders() const
Returns an iterable ensemble of orders of a vehicle.
bool HasHangar() const
Check if this airport has at least one hangar.
bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool pbs_look_ahead)
Update the vehicle's destination tile from an order.
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
static bool OrderConditionCompare(OrderConditionComparator occ, int variable, int value)
Compare the variable and value based on the given comparator.
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
@ OLF_FULL_LOAD_ANY
Full load a single cargo of the consist.
TileIndex dest_tile
Heading for this tile.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
CargoID GetRefitCargo() const
Get the cargo to to refit to.
uint8 CalcPercentVehicleFilled(const Vehicle *front, StringID *colour)
Calculates how full a vehicle is.
Common return value for all commands.
@ ONSF_STOP_EVERYWHERE
The vehicle will stop at any station it passes and the destination.
@ WC_VEHICLE_VIEW
Vehicle view; Window numbers:
void AddToShared(Vehicle *shared_chain)
Adds this vehicle to a shared vehicle chain.
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
void RemoveFromShared()
Removes the vehicle from the shared order list.
TileIndex tile
Current tile index.
#define DEBUG(name, level,...)
Output a line of debugging information.
static void CancelLoadingDueToDeletedOrder(Vehicle *v)
Cancel the current loading order of the vehicle as the order was deleted.
void MakeGoToWaypoint(StationID destination)
Makes this order a Go To Waypoint order.
EngineID engine_type
The type of engine used for this vehicle.
@ VS_CRASHED
Vehicle is crashed.
@ OUF_UNLOAD_IF_POSSIBLE
Unload all cargo that the station accepts.
Cheats _cheats
All the cheats.
CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Modify an order in the orderlist of a vehicle.
StationID last_station_visited
The last station we stopped at.
static bool CheckForValidOrders(const Vehicle *v)
Check if a vehicle has any valid orders.
uint16 GetTravelTime() const
Get the time in ticks a vehicle will probably take to reach the destination (timetabled or not).
bool Failed() const
Did this command fail?
Order current_order
The current order (+ status, like: loading)
Airport airport
Tile area the airport covers.
static void DeleteOrderWarnings(const Vehicle *v)
Delete all news items regarding defective orders about a vehicle This could kill still valid warnings...
CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Add an order to the orderlist of a vehicle.
Flags flags
Flags for this airport type.
Order * GetLastOrder() const
Returns the last order of a vehicle, or nullptr if it doesn't exists.
@ ODATFB_NEAREST_DEPOT
Send the vehicle to the nearest depot.
void DeleteOrderAt(int index)
Remove an order from the order list and delete it.
@ OCC_IS_TRUE
Skip if the variable is true.
@ VS_STOPPED
Vehicle is stopped by the player.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
static bool IsRailDepotTile(TileIndex t)
Is this tile rail tile and a rail depot?
@ OCC_LESS_EQUALS
Skip if the value is less or equal to the limit.
@ DA_ALWAYS_GO
Always go to the depot.
@ WC_SHIPS_LIST
Ships list; Window numbers:
void Initialize(Order *chain, Vehicle *v)
Recomputes everything.
VehicleOrderID num_manual_orders
NOSAVE: How many manually added orders are there in the list.
@ ODTFB_PART_OF_ORDERS
This depot order is because of a regular order.
int32 Ticks
The type to store ticks in.
OrderConditionComparator GetConditionComparator() const
What is the comparator to use?
void FreeChain(bool keep_orderlist=false)
Free a complete order chain.
int GetPositionInSharedOrderList(const Vehicle *v) const
Gets the position of the given vehicle within the shared order vehicle list.
CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Move an order inside the orderlist.
void SetConditionValue(uint16 value)
Set the value to base the skip on.
@ OCC_MORE_EQUALS
Skip if the value is more or equal to the limit.
virtual bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse)
Find the closest depot for this vehicle and tell us the location, DestinationID and whether we should...
@ FACIL_DOCK
Station with a dock.
bool HasDepotOrder() const
Checks if a vehicle has a depot in its order list.
void MakeGoToStation(StationID destination)
Makes this order a Go To Station order.
static const int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
StationIDStack GetNextStoppingStation(const Vehicle *v, const Order *first=nullptr, uint hops=0) const
Recursively determine the next deterministic station to stop at.
VehicleOrderID GetConditionSkipToOrder() const
Get the order to skip to.
CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Clone/share/copy an order-list of another vehicle.
uint16 max_speed
How fast the vehicle may go on the way to the destination.
bool IsOrderListShared() const
Check if we share our orders with another vehicle.
bool value
tells if the bool cheat is active or not
@ OLF_LOAD_IF_POSSIBLE
Load as long as there is cargo that fits in the train.
void SetStopLocation(OrderStopLocation stop_location)
Set where we must stop at the platform.
@ OSL_PLATFORM_NEAR_END
Stop at the near end of the platform.
Order * GetOrderAt(int index) const
Get a certain order of the order chain.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
@ ODATFB_HALT
Service the vehicle and then halt it.
void IncrementRealOrderIndex()
Advanced cur_real_order_index to the next real order, keeps care of the wrap-around and invalidates t...
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
bool IsTravelTimetabled() const
Does this order have an explicit travel time set?
OrderList * list
Pointer to the order list for this vehicle.
uint DistanceSquare(TileIndex t0, TileIndex t1)
Gets the 'Square' distance between the two given tiles.
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
@ ONSF_NO_STOP_AT_DESTINATION_STATION
The vehicle will stop at any station it passes except the destination.
TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
static WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
bool ProcessOrders(Vehicle *v)
Handle the orders of a vehicle and determine the next place to go to if needed.
CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Goto order of order-list.
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Add/remove refit orders from an order.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void SetRefit(CargoID cargo)
Make this depot/station order also a refit order.
OrderUnloadFlags
Flags related to the unloading order.
OrderNonStopFlags
Non-stop order flags.
void DebugCheckSanity() const
Checks for internal consistency of order list.
uint32 cached_max_range_sqr
Cached squared maximum range.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Base class for all pools.
void SetConditionVariable(OrderConditionVariable condition_variable)
Set variable we have to compare.
@ OCC_EQUALS
Skip if both values are equal.
@ OCV_MAX_SPEED
Skip based on the maximum speed.
@ OSL_PLATFORM_FAR_END
Stop at the far end of the platform.
CargoID refit_cargo
Refit CargoID.
void IncrementImplicitOrderIndex()
Increments cur_implicit_order_index, keeps care of the wrap-around and invalidates the GUI.
@ OCV_RELIABILITY
Skip based on the reliability.
@ MOF_STOP_LOCATION
Passes an OrderStopLocation.
@ FACIL_TRAIN
Station with train station.
Order * GetFirstOrder() const
Get the first order of the vehicles order list.
static RoadVehicle * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
void RecalculateTimetableDuration()
Recomputes Timetable duration.
@ OCV_REMAINING_LIFETIME
Skip based on the remaining lifetime.
@ OUFB_NO_UNLOAD
Totally no unloading will be done.
TileIndex tile
The base tile of the area.
void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool hangar)
Removes an order from all vehicles.
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
uint16 MapOldOrder() const
Pack this order into a 16 bits integer as close to the TTD representation as possible.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
uint32 current_order_time
How many ticks have passed since this order started.
void SetConditionSkipToOrder(VehicleOrderID order_id)
Get the order to skip to.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
@ OWNER_NONE
The tile has no ownership.
union Vehicle::@51 orders
The orders currently assigned to the vehicle.
@ CT_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
Order * GetLastOrder() const
Get the last order of the order chain.
@ MP_STATION
A tile of a station.
@ MOF_NON_STOP
Passes an OrderNonStopFlags.
@ NUM_CARGO
Maximal number of cargo types in a game.
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
void SetWaitTime(uint16 time)
Set the time in ticks to wait at the destination.
void SetDepotOrderType(OrderDepotTypeFlags depot_order_type)
Set the cause to go to the depot.
TileIndex xy
Base tile of the station.
Order * first
First order of the order list.
static void RemoveOrder(OrderType type, DestinationID destination, bool hangar)
Removes an order from all vehicles.
Base class for all station-ish types.
static const VehicleOrderID MAX_VEH_ORDER_ID
Last valid VehicleOrderID.
uint8 order_review_system
perform order reviews on vehicles
void SetDepotActionType(OrderDepotActionFlags depot_service_type)
Set what we are going to do in the depot.
@ OCV_LOAD_PERCENTAGE
Skip based on the amount of load.
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
void MakeConditional(VehicleOrderID order)
Makes this order an conditional order.
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...
uint32 VehicleID
The type all our vehicle IDs have.
bool NeedsServicing() const
Check if the vehicle needs to go to a depot in near future (if a opportunity presents itself) for ser...
OrderDepotTypeFlags GetDepotOrderType() const
What caused us going to the depot?
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.
static void AddVehicleAdviceNewsItem(StringID string, VehicleID vehicle)
Adds a vehicle-advice news item.
Order * GetFirstOrder() const
Get the first order of the order chain.
byte day_counter
Increased by one for each day.
OrderConditionVariable GetConditionVariable() const
What variable do we have to compare?
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
uint num_vehicles
NOSAVE: Number of vehicles that share this order list.
bool IsEmpty() const
Check if the stack is empty.
static Station * GetIfValid(size_t index)
Returns station if the index is a valid index for this station type.
void SetConditionComparator(OrderConditionComparator condition_comparator)
Set the comparator to use.
byte CargoID
Cargo slots to indicate a cargo type within a game.
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
static uint ToPercent16(uint i)
Converts a "fract" value 0..65535 to "percent" value 0..100.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
bool IsBus() const
Check whether a roadvehicle is a bus.
TileIndex GetLocation(const Vehicle *v, bool airport=false) const
Returns a tile somewhat representing the order destination (not suitable for pathfinding).
uint16 cached_max_range
Cached maximum range.
byte state
State of the airport.
void SetUnloadType(OrderUnloadFlags unload_type)
Set how the consist must be unloaded.
@ OCV_REQUIRES_SERVICE
Skip when the vehicle requires service.
@ VEH_TRAIN
Train vehicle type.
bool IsVehicleInSharedOrdersList(const Vehicle *v) const
Checks whether a vehicle is part of the shared vehicle chain.
Order * GetOrder(int index) const
Returns order 'index' of a vehicle or nullptr when it doesn't exists.
VehicleType type
Type of vehicle.
uint16 reliability
Reliability.
@ VIWD_MODIFY_ORDERS
Other order modifications.
static bool CheckAircraftOrderDistance(const Aircraft *v_new, const Vehicle *v_order, const Order *first)
Check if an aircraft has enough range for an order list.
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
Can this station be used by the given engine type?
static bool OrderGoesToStation(const Vehicle *v, const Order *o)
Checks whether the order goes to a station or not, i.e.
uint16 travel_time
How long in ticks the journey to this destination should take.
bool CanLeaveWithCargo(bool has_cargo) const
A vehicle can leave the current station with cargo if:
@ VEH_SHIP
Ship vehicle type.
@ OCV_MAX_RELIABILITY
Skip based on the maximum reliability.
static bool IsShipDepotTile(TileIndex t)
Is it a ship depot tile?
@ OCC_IS_FALSE
Skip if the variable is false.
VehicleOrderID GetNumOrders() const
Get the number of orders this vehicle has.
void InvalidateVehicleOrder(const Vehicle *v, int data)
Updates the widgets of a vehicle which contains the order-data.
OrderDepotActionFlags
Actions that can be performed when the vehicle enters the depot.
@ VIWD_REMOVE_ALL_ORDERS
Removed / replaced all orders (after deleting / sharing).
@ CT_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
@ WC_AIRCRAFT_LIST
Aircraft list; Window numbers:
void DeleteUnreachedImplicitOrders()
Delete all implicit orders which were not reached.
@ WC_STATION_LIST
Station list; Window numbers:
Order * next
Pointer to next order. If nullptr, end of list.
uint8 flags
Load/unload types, depot order/action types.
@ DA_SERVICE
Service only if needed.
uint8 type
The type of order + non-stop flags.
VehicleOrderID GetNumOrders() const
Get number of orders in the order list.
TileArea ship_station
Tile area the ship 'station' part covers.
bool Equals(const Order &other) const
Does this order have the same type, flags and destination?
@ OCV_AGE
Skip based on the age.
void InsertOrderAt(Order *new_order, int index)
Insert a new order into the order chain.
bool IsWaitTimetabled() const
Does this order have an explicit wait time set?
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
DestinationID dest
The destination of the order.
void MakeImplicit(StationID destination)
Makes this order an implicit order.
@ FLYING
Vehicle is flying in the air.
OrderConditionComparator
Comparator for the skip reasoning.
virtual TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
@ WC_VEHICLE_ORDERS
Vehicle orders; Window numbers:
GUISettings gui
settings related to the GUI
uint16 reliability
Current reliability of the engine.
@ OCC_LESS_THAN
Skip if the value is less than the limit.
@ OCV_UNCONDITIONALLY
Always skip.
@ OLFB_NO_LOAD
Do not load anything.
VehicleOrderID num_orders
NOSAVE: How many orders there are in the list.
OrderLoadFlags GetLoadType() const
How must the consist be loaded?
@ MOF_COND_VARIABLE
A conditional variable changes.
void SetWaitTimetabled(bool timetabled)
Set if the wait time is explicitly timetabled (unless the order is conditional).