30 #include "table/strings.h" 37 assert_compile(
sizeof(DestinationID) >=
sizeof(
DepotID));
38 assert_compile(
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;
293 this->first_shared = v;
295 this->num_orders = 0;
296 this->num_manual_orders = 0;
297 this->num_vehicles = 1;
298 this->timetable_duration = 0;
300 for (
Order *o = this->first; o !=
nullptr; o = o->
next) {
302 if (!o->IsType(OT_IMPLICIT)) ++this->num_manual_orders;
303 this->total_duration += o->GetWaitTime() + o->GetTravelTime();
306 this->RecalculateTimetableDuration();
309 ++this->num_vehicles;
310 this->first_shared = u;
322 this->timetable_duration = 0;
323 for (
Order *o = this->first; o !=
nullptr; o = o->
next) {
324 this->timetable_duration += o->GetTimetabledWait() + o->GetTimetabledTravel();
336 for (
Order *o = this->first; o !=
nullptr; o =
next) {
341 if (keep_orderlist) {
342 this->first =
nullptr;
343 this->num_orders = 0;
344 this->num_manual_orders = 0;
345 this->timetable_duration = 0;
358 if (index < 0)
return nullptr;
360 Order *order = this->first;
362 while (order !=
nullptr && index-- > 0) {
381 if (hops > this->GetNumOrders() || next ==
nullptr)
return nullptr;
383 if (next->
IsType(OT_CONDITIONAL)) {
388 return this->GetNextDecisionNode(
393 if (next->
IsType(OT_GOTO_DEPOT)) {
395 if (next->
IsRefit())
return next;
398 if (!next->CanLoadOrUnload()) {
399 return this->GetNextDecisionNode(this->GetNext(next), hops + 1);
418 if (first ==
nullptr) {
420 if (next ==
nullptr) {
421 next = this->GetFirstOrder();
422 if (next ==
nullptr)
return INVALID_STATION;
427 next = this->GetNext(next);
428 assert(next !=
nullptr);
433 next = this->GetNextDecisionNode(next, ++hops);
436 while (next !=
nullptr && next->
IsType(OT_CONDITIONAL)) {
438 const Order *skip_to = this->GetNextDecisionNode(
440 const Order *advance = this->GetNextDecisionNode(
441 this->GetNext(next), hops);
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;
447 StationIDStack st1 = this->GetNextStoppingStation(v, skip_to, hops);
448 StationIDStack st2 = this->GetNextStoppingStation(v, advance, hops);
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;
478 new_order->
next = this->first;
479 this->first = new_order;
480 }
else if (index >= this->num_orders) {
482 this->GetLastOrder()->
next = new_order;
485 Order *order = this->GetOrderAt(index - 1);
487 order->
next = new_order;
491 if (!new_order->
IsType(OT_IMPLICIT)) ++this->num_manual_orders;
497 if (new_order->
IsType(OT_GOTO_STATION) || new_order->
IsType(OT_GOTO_WAYPOINT)) {
511 if (index >= this->num_orders)
return;
516 to_remove = this->first;
517 this->first = to_remove->
next;
519 Order *prev = GetOrderAt(index - 1);
520 to_remove = prev->
next;
524 if (!to_remove->
IsType(OT_IMPLICIT)) --this->num_manual_orders;
537 if (from >= this->num_orders || to >= this->num_orders || from == to)
return;
543 moving_one = this->first;
544 this->first = moving_one->
next;
546 Order *one_before = GetOrderAt(from - 1);
547 moving_one = one_before->
next;
548 one_before->
next = moving_one->
next;
553 moving_one->
next = this->first;
554 this->first = moving_one;
556 Order *one_before = GetOrderAt(to - 1);
557 moving_one->
next = one_before->
next;
558 one_before->
next = moving_one;
569 --this->num_vehicles;
570 if (v == this->first_shared) this->first_shared = v->
NextShared();
579 for (
const Vehicle *v_shared = this->first_shared; v_shared !=
nullptr; v_shared = v_shared->
NextShared()) {
580 if (v_shared == v)
return true;
604 for (
Order *o = this->first; o !=
nullptr; o = o->
next) {
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);
625 for (
const Order *o = this->first; o !=
nullptr; o = o->
next) {
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();
631 assert(this->num_orders == check_num_orders);
632 assert(this->num_manual_orders == check_num_manual_orders);
633 assert(this->timetable_duration == check_timetable_duration);
634 assert(this->total_duration == check_total_duration);
637 ++check_num_vehicles;
638 assert(v->orders.list ==
this);
640 assert(this->num_vehicles == check_num_vehicles);
641 DEBUG(misc, 6,
"... detected %u orders (%u manual), %u vehicles, %i timetabled, %i total",
642 (uint)this->num_orders, (uint)this->num_manual_orders,
643 this->num_vehicles, this->timetable_duration, this->total_duration);
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 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 FOR_VEHICLE_ORDERS(v, order) {
974 if (order->
IsType(OT_CONDITIONAL)) {
976 if (order_id >= sel_ord) {
979 if (order_id == cur_order_id) {
1024 if (ret.
Failed())
return ret;
1068 if (sel_ord < u->cur_real_order_index) {
1074 if (sel_ord < u->cur_implicit_order_index) {
1093 Order *order =
nullptr;
1094 FOR_VEHICLE_ORDERS(v, order) {
1095 if (order->
IsType(OT_CONDITIONAL)) {
1097 if (order_id >= sel_ord) {
1098 order_id =
max(order_id - 1, 0);
1100 if (order_id == cur_order_id) {
1130 if (ret.
Failed())
return ret;
1171 if (ret.
Failed())
return ret;
1179 if (moving_one ==
nullptr)
return CMD_ERROR;
1229 FOR_VEHICLE_ORDERS(v, order) {
1230 if (order->
IsType(OT_CONDITIONAL)) {
1232 if (order_id == moving_order) {
1233 order_id = target_order;
1234 }
else if (order_id > moving_order && order_id <= target_order) {
1236 }
else if (order_id < moving_order && order_id >= target_order) {
1270 uint16 data =
GB(p2, 4, 11);
1278 if (ret.
Failed())
return ret;
1285 case OT_GOTO_STATION:
1293 case OT_GOTO_WAYPOINT:
1297 case OT_CONDITIONAL:
1306 default: NOT_REACHED();
1466 default: NOT_REACHED();
1507 for (
const Order *o = first; o !=
nullptr; o = o->
next) {
1508 switch (o->GetType()) {
1509 case OT_GOTO_STATION:
1511 case OT_GOTO_WAYPOINT:
1543 if (ret.
Failed())
return ret;
1545 switch (
GB(p1, 30, 2)) {
1553 if (ret.
Failed())
return ret;
1565 FOR_VEHICLE_ORDERS(src, order) {
1612 if (ret.
Failed())
return ret;
1617 FOR_VEHICLE_ORDERS(src, order) {
1636 Order *first =
nullptr;
1645 FOR_VEHICLE_ORDERS(src, order) {
1646 *order_dst =
new Order();
1647 (*order_dst)->AssignOrder(*order);
1648 order_dst = &(*order_dst)->next;
1697 if (ret.
Failed())
return ret;
1721 if (u->cur_real_order_index == order_number && (u->current_order.GetDepotOrderType() &
ODTFB_PART_OF_ORDERS)) {
1722 u->current_order.SetRefit(cargo);
1758 FOR_VEHICLE_ORDERS(v, order) {
1760 if (order->
IsType(OT_DUMMY)) {
1761 message = STR_NEWS_VEHICLE_HAS_VOID_ORDER;
1765 if (order->
IsType(OT_GOTO_STATION)) {
1770 message = STR_NEWS_VEHICLE_HAS_INVALID_ENTRY;
1772 (AircraftVehInfo(v->
engine_type)->subtype & AIR_FAST) &&
1776 message = STR_NEWS_PLANE_USES_TOO_SHORT_RUNWAY;
1786 message = STR_NEWS_VEHICLE_HAS_DUPLICATE_ENTRY;
1791 if (n_st < 2 && message ==
INVALID_STRING_ID) message = STR_NEWS_VEHICLE_HAS_TOO_FEW_ORDERS;
1823 order = &v->current_order;
1824 if ((v->type ==
VEH_AIRCRAFT && order->
IsType(OT_GOTO_DEPOT) && !hangar ? OT_GOTO_STATION : order->
GetType()) == type &&
1825 (!hangar || v->type ==
VEH_AIRCRAFT) && v->current_order.GetDestination() == destination) {
1832 FOR_VEHICLE_ORDERS(v, order) {
1838 if (ot == OT_GOTO_DEPOT && hangar && v->type !=
VEH_AIRCRAFT)
continue;
1839 if (ot == OT_IMPLICIT || (v->type ==
VEH_AIRCRAFT && ot == OT_GOTO_DEPOT && !hangar)) ot = OT_GOTO_STATION;
1844 if (order->
IsType(OT_IMPLICIT)) {
1845 order = order->
next;
1847 if (order !=
nullptr)
goto restart;
1852 v->orders.list->UpdateTotalDuration(-order->
GetWaitTime());
1884 FOR_VEHICLE_ORDERS(
this, order) {
1885 if (order->
IsType(OT_GOTO_DEPOT))
return true;
1911 if (!keep_orderlist) v->
orders.
list =
nullptr;
1914 if (reset_order_indices) {
1930 return ispercent ?
Clamp(interval, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) :
Clamp(interval, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
1945 FOR_VEHICLE_ORDERS(v, order) {
1947 case OT_GOTO_STATION:
1949 case OT_GOTO_WAYPOINT:
1974 default: NOT_REACHED();
1988 bool skip_order =
false;
2001 default: NOT_REACHED();
2023 case OT_GOTO_STATION:
2029 assert(!pbs_look_ahead);
2038 DestinationID destination;
2043 if (pbs_look_ahead && reverse)
return false;
2045 v->SetDestTile(location);
2063 if (pbs_look_ahead)
return false;
2082 case OT_GOTO_WAYPOINT:
2086 case OT_CONDITIONAL: {
2087 assert(!pbs_look_ahead);
2120 if (order !=
nullptr && order->IsType(OT_IMPLICIT)) {
2125 if (order ==
nullptr) {
2132 return UpdateOrderDest(v, order, conditional_depth + 1, pbs_look_ahead);
2153 case OT_LEAVESTATION:
2188 if (order !=
nullptr && order->
IsType(OT_IMPLICIT)) {
2197 extern void HandleMissingAircraftOrders(
Aircraft *v);
2243 bool is_dest_station = this->
IsType(OT_GOTO_STATION) && this->
dest == station;
2251 bool Order::CanLoadOrUnload()
const 2253 return (this->
IsType(OT_GOTO_STATION) || this->
IsType(OT_IMPLICIT)) &&
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
Functions related to OTTD's strings.
uint16 reliability
Current reliability of the engine.
StationFacility facilities
The facilities that this station has.
Vehicle is stopped by the player.
This airport has a short landing strip, dangerous for fast aircraft.
void InsertOrderAt(Order *new_order, int index)
Insert a new order into the order chain.
bool IsVehicleInSharedOrdersList(const Vehicle *v) const
Checks whether a vehicle is part of the shared vehicle chain.
Definition of stuff that is very close to a company, like the company struct itself.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Delete an order from the orderlist of a vehicle.
uint16 DepotID
Type for the unique identifier of depots.
Passes an OrderUnloadType.
uint16 GetTravelTime() const
Get the time in ticks a vehicle will probably take to reach the destination (timetabled or not)...
StationID targetairport
Airport to go to next.
Minimal stack that uses a pool to avoid pointers.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Skip if both values are equal.
Load as long as there is cargo that fits in the train.
OrderConditionComparator GetConditionComparator() const
What is the comparator to use?
uint16 GetServiceIntervalClamped(uint interval, bool ispercent)
Clamp the service interval to the correct min/max.
void SetConditionValue(uint16 value)
Set the value to base the skip on.
void CheckOrders(const Vehicle *v)
Check the orders of a vehicle, to see if there are invalid orders and stuff.
bool HasHangar() const
Check if this airport has at least one hangar.
void InvalidateVehicleOrder(const Vehicle *v, int data)
Updates the widgets of a vehicle which contains the order-data.
union Vehicle::@49 orders
The orders currently assigned to the vehicle.
static Titem * Get(size_t index)
Returns Titem with given index.
const AirportFTAClass * GetFTA() const
Get the finite-state machine for this airport or the finite-state machine for the dummy airport in ca...
VehicleOrderID GetConditionSkipToOrder() const
Get the order to skip to.
void SetWaitTime(uint16 time)
Set the time in ticks to wait at the destination.
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
Other order modifications.
Functions related to debugging.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
void SetDepotOrderType(OrderDepotTypeFlags depot_order_type)
Set the cause to go to the depot.
static void AddVehicleAdviceNewsItem(StringID string, VehicleID vehicle)
Adds a vehicle-advice news item.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Maximal number of cargo types in a game.
void SetDepotActionType(OrderDepotActionFlags depot_service_type)
Set what we are going to do in the depot.
Selects the OrderDepotAction.
OrderList * list
Pointer to the order list for this vehicle.
Skip if the variable is true.
static void RemoveOrder(OrderType type, DestinationID destination, bool hangar)
Removes an order from all vehicles.
TileIndex dest_tile
Heading for this tile.
bool IsCompleteTimetable() const
Checks whether all orders of the list have a filled timetable.
bool IsTravelTimetabled() const
Does this order have an explicit travel time set?
Skip based on the reliability.
Functions related to vehicles.
Aircraft, helicopters, rotors and their shadows belong to this class.
void InsertOrder(Vehicle *v, Order *new_o, VehicleOrderID sel_ord)
Insert a new order but skip the validation.
Stop at the middle of the platform.
void IncrementImplicitOrderIndex()
Increments cur_implicit_order_index, keeps care of the wrap-around and invalidates the GUI...
void IncrementRealOrderIndex()
Advanced cur_real_order_index to the next real order, keeps care of the wrap-around and invalidates t...
uint32 current_order_time
How many ticks have passed since this order started.
VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v)
Process a conditional order and determine the next order.
Base for all depots (except hangars)
void SetRefit(CargoID cargo)
Make this depot/station order also a refit order.
Flags flags
Flags for this airport type.
Unload all cargo that the station accepts.
void LeaveStation()
Perform all actions when leaving a station.
Tindex index
Index of this pool item.
Vehicle is flying in the air.
Helper functions to extract data from command parameters.
CargoID refit_cargo
Refit CargoID.
Representation of a waypoint.
StationID last_station_visited
The last station we stopped at.
void DeleteVehicleOrders(Vehicle *v, bool keep_orderlist, bool reset_order_indices)
Delete all orders from a vehicle.
OrderNonStopFlags
Non-stop order flags.
void SetUnloadType(OrderUnloadFlags unload_type)
Set how the consist must be unloaded.
Skip if the value is more or equal to the limit.
void AircraftNextAirportPos_and_Order(Aircraft *v)
set the right pos when heading to other airports after takeoff
void SetConditionComparator(OrderConditionComparator condition_comparator)
Set the comparator to use.
Automatically choose cargo type when doing auto refitting.
Common return value for all commands.
static T max(const T a, const T b)
Returns the maximum of two values.
uint16 MapOldOrder() const
Pack this order into a 16 bits integer as close to the TTD representation as possible.
void SetConditionVariable(OrderConditionVariable condition_variable)
Set variable we have to compare.
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...
TileIndex GetLocation(const Vehicle *v, bool airport=false) const
Returns a tile somewhat representing the order destination (not suitable for pathfinding).
static RoadVehicle * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
bool CanLeaveWithCargo(bool has_cargo) const
A vehicle can leave the current station with cargo if:
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord)
Delete an order but skip the parameter validation.
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
The vehicle will stop at any station it passes except the destination.
uint GetOrderDistance(const Order *prev, const Order *cur, const Vehicle *v, int conditional_depth)
Get the distance between two orders of a vehicle.
Stop at the near end of the platform.
Order * next
Pointer to next order. If nullptr, end of list.
void DeleteOrderAt(int index)
Remove an order from the order list and delete it.
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
Order * GetOrderAt(int index) const
Get a certain order of the order chain.
Cheat no_jetcrash
no jet will crash on small airports anymore
Pseudo random number generator.
void MoveOrder(int from, int to)
Move an order to another position within the order list.
void SetConditionSkipToOrder(VehicleOrderID order_id)
Get the order to skip to.
Stop at the far end of the platform.
DestinationID dest
The destination of the order.
uint16 travel_time
How long in ticks the journey to this destination should take.
The vehicle will stop at any station it passes and the destination.
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...
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...
Passes an OrderStopLocation.
void RemoveVehicle(Vehicle *v)
Removes the vehicle from the shared order list.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
OrderDepotTypeFlags GetDepotOrderType() const
What caused us going to the depot?
static CommandCost DecloneOrder(Vehicle *dst, DoCommandFlag flags)
Declone an order-list.
Vehicle orders; Window numbers:
virtual int GetDisplayMaxSpeed() const
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
bool IsEmpty() const
Check if the stack is empty.
Some methods of Pool are placed here in order to reduce compilation time and binary size...
OrderConditionVariable GetConditionVariable() const
What variable do we have to compare?
The tile has no ownership.
Types related to cheating.
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
uint8 type
The type of order + non-stop flags.
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
void MakeImplicit(StationID destination)
Makes this order an implicit order.
void DeleteVehicleNews(VehicleID vid, StringID news)
Delete a news item type about a vehicle.
bool IsRefit() const
Is this order a refit order.
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...
bool NeedsServicing() const
Check if the vehicle needs to go to a depot in near future (if a opportunity presents itself) for ser...
void MakeDummy()
Makes this order a Dummy order.
uint32 VehicleID
The type all our vehicle IDs have.
bool IsType(OrderType type) const
Check whether this order is of the given type.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
DoCommandFlag
List of flags for a command.
Skip if the value is less or equal to the limit.
CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Add an order to the orderlist of a vehicle.
ClientSettings _settings_client
The current settings for this game.
Definition of base types and functions in a cross-platform compatible way.
Removed / replaced all orders (after deleting / sharing).
A number of safeguards to prevent using unsafe methods.
bool value
tells if the bool cheat is active or not
Change the destination of a conditional order.
bool ProcessOrders(Vehicle *v)
Handle the orders of a vehicle and determine the next place to go to if needed.
void MakeLoading(bool ordered)
Makes this order a Loading order.
static bool IsRoadDepotTile(TileIndex t)
Return whether a tile is a road depot tile.
void FreeChain(bool keep_orderlist=false)
Free a complete order chain.
Titem Pop()
Pop an item from the stack.
void UpdateRealOrderIndex()
Skip implicit orders until cur_real_order_index is a non-implicit order.
OrderDepotActionFlags
Actions that can be performed when the vehicle enters the depot.
uint8 flags
Load/unload types, depot order/action types.
CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Move an order inside the orderlist.
void AddToShared(Vehicle *shared_chain)
Adds this vehicle to a shared vehicle chain.
Vehicle view; Window numbers:
bool IsWaitTimetabled() const
Does this order have an explicit wait time set?
Functions related to order backups.
uint16 GetTimetabledTravel() const
Get the time in ticks a vehicle should take to reach the destination or 0 if it's not timetabled...
bool IsShared() const
Is this a shared order list?
Order * GetFirstOrder() const
Get the first order of the order chain.
void Initialize(Order *chain, Vehicle *v)
Recomputes everything.
TileIndex tile
Current tile index.
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
void Push(const Titem &item)
Pushes a new item onto the stack if there is still space in the underlying pool.
Vehicle timetable; Window numbers:
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
Can this station be used by the given engine type?
OrderConditionComparator
Comparator for the skip reasoning.
OrderLoadFlags GetLoadType() const
How must the consist be loaded?
Service the vehicle and then halt it.
virtual TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
void SetWaitTimetabled(bool timetabled)
Set if the wait time is explicitly timetabled (unless the order is conditional).
Owner owner
Which company owns the vehicle?
bool Equals(const Order &other) const
Does this order have the same type, flags and destination?
static bool IsShipDepotTile(TileIndex t)
Is it a ship depot tile?
Order * GetLastOrder() const
Returns the last order of a vehicle, or nullptr if it doesn't exists.
uint16 reliability
Reliability.
static void CancelLoadingDueToDeletedOrder(Vehicle *v)
Cancel the current loading order of the vehicle as the order was deleted.
CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Goto order of order-list.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
bool Failed() const
Did this command fail?
bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool pbs_look_ahead)
Update the vehicle's destination tile from an order.
Order * GetFirstOrder() const
Get the first order of the vehicles order list.
CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Modify an order in the orderlist of a vehicle.
The value to set the condition to.
static bool OrderConditionCompare(OrderConditionComparator occ, int variable, int value)
Compare the variable and value based on the given comparator.
Skip based on the remaining lifetime.
Skip if the value is less than the limit.
static void DeleteOrderWarnings(const Vehicle *v)
Delete all news items regarding defective orders about a vehicle This could kill still valid warnings...
Transfer all cargo onto the platform.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
byte state
State of the airport.
Base class for all pools.
Station list; Window numbers:
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
OrderUnloadFlags GetUnloadType() const
How must the consist be unloaded?
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
#define DEBUG(name, level,...)
Output a line of debugging information.
Skip when the vehicle requires service.
TileIndex tile
The base tile of the area.
bool HasDepotOrder() const
Checks if a vehicle has a depot in its order list.
OrderUnloadFlags
Flags related to the unloading order.
uint16 GetWaitTime() const
Get the time in ticks a vehicle will probably wait at the destination (timetabled or not)...
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
void RemoveFromShared()
Removes the vehicle from the shared order list.
execute the given command
A conditional variable changes.
Functions related to companies.
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
OrderStopLocation
Where to stop the trains.
uint16 GetTimetabledWait() const
Get the time in ticks a vehicle should wait at the destination or 0 if it's not timetabled.
bool IsBus() const
Check whether a roadvehicle is a bus.
Passes an OrderNonStopFlags.
uint16 cached_max_range
Cached maximum range.
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
GUISettings gui
settings related to the GUI
DestinationID GetDestination() const
Gets the destination of this order.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static bool IsRailDepotTile(TileIndex t)
Is this tile rail tile and a rail depot?
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.
static bool CheckForValidOrders(const Vehicle *v)
Check if a vehicle has any valid orders.
OrderStopLocation GetStopLocation() const
Where must we stop at the platform?
StationIDStack GetNextStoppingStation(const Vehicle *v, const Order *first=nullptr, uint hops=0) const
Recursively determine the next deterministic station to stop at.
Ships list; Window numbers:
uint32 TileIndex
The index/ID of a Tile.
Skip if both values are not equal.
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
OrderLoadFlags
Flags related to the loading order.
void MakeLeaveStation()
Makes this order a Leave Station order.
static bool OrderGoesToStation(const Vehicle *v, const Order *o)
Checks whether the order goes to a station or not, i.e.
Vehicle * PreviousShared() const
Get the previous vehicle of the shared vehicle chain.
uint16 wait_time
How long in ticks to wait at the destination.
Send the vehicle to the nearest depot.
int32 Ticks
The type to store ticks in.
void Free()
'Free' the order
uint16 GetConditionValue() const
Get the value to base the skip on.
TileIndex xy
Base tile of the station.
void SetTravelTimetabled(bool timetabled)
Set if the travel time is explicitly timetabled (unless the order is conditional).
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
uint32 cached_max_range_sqr
Cached squared maximum range.
Full load all cargoes of the consist.
VehicleType type
Type of vehicle.
void DeleteUnreachedImplicitOrders()
Delete all implicit orders which were not reached.
Skip based on the amount of load.
int GetPositionInSharedOrderList(const Vehicle *v) const
Gets the position of the given vehicle within the shared order vehicle list.
Totally no unloading will be done.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() ...
static uint ToPercent16(uint i)
Converts a "fract" value 0..65535 to "percent" value 0..100.
void AssignOrder(const Order &other)
Assign data to an order (from another order) This function makes sure that the index is maintained co...
The vehicle will not stop at any stations it passes except the destination.
Skip based on the maximum speed.
Aircraft list; Window numbers:
uint16 & GetGroundVehicleFlags()
Access the ground vehicle flags of the vehicle.
Functions related to commands.
CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Add/remove refit orders from an order.
uint8 CalcPercentVehicleFilled(const Vehicle *front, StringID *colour)
Calculates how full a vehicle is.
void DebugCheckSanity() const
Checks for internal consistency of order list.
Owner owner
The owner of this station.
ModifyOrderFlags
Enumeration for the data to set in CmdModifyOrder.
static WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Clone/share/copy an order-list of another vehicle.
Order * GetOrder(int index) const
Returns order 'index' of a vehicle or nullptr when it doesn't exists.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
VehicleOrderID GetNumOrders() const
Get the number of orders this vehicle has.
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.
Airport airport
Tile area the airport covers.
bool IsOrderListShared() const
Check if we share our orders with another vehicle.
void MakeGoToWaypoint(StationID destination)
Makes this order a Go To Waypoint order.
EngineID engine_type
The type of engine used for this vehicle.
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
void RecalculateTimetableDuration()
Recomputes Timetable duration.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
uint32 Pack() const
Pack this order into a 32 bits integer, or actually only the type, flags and destination.
void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool hangar)
Removes an order from all vehicles.
OrderType GetType() const
Get the type of order of this order.
byte CargoID
Cargo slots to indicate a cargo type within a game.
uint8 order_review_system
perform order reviews on vehicles
uint DistanceSquare(TileIndex t0, TileIndex t1)
Gets the 'Square' distance between the two given tiles.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
Station with train station.
Force unloading all cargo onto the platform, possibly not getting paid.
static const VehicleOrderID MAX_VEH_ORDER_ID
Last valid VehicleOrderID.
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
This depot order is because of a regular order.
Functions related to news.
Go to the depot and stop there.
Base classes/functions for stations.
static Station * Get(size_t index)
Gets station with given index.
VehicleOrderID cur_implicit_order_index
The index to the current implicit order.
Skip if the value is more than the limit.
uint16 max_speed
How fast the vehicle may go on the way to the destination.
Full load a single cargo of the consist.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
This depot order is because of the servicing limit.
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
Skip if the variable is false.
Skip based on the maximum reliability.
void SetStopLocation(OrderStopLocation stop_location)
Set where we must stop at the platform.
Base class for all station-ish types.
OrderNonStopFlags GetNonStopType() const
At which stations must we stop?
Disable insertion and removal of automatic orders until the vehicle completes the real order...
byte day_counter
Increased by one for each day.
Order current_order
The current order (+ status, like: loading)
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-...
static const int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
void MakeGoToStation(StationID destination)
Makes this order a Go To Station order.
OrderDepotTypeFlags
Reasons that could cause us to go to the depot.
CargoID GetRefitCargo() const
Get the cargo to to refit to.
Cheats _cheats
All the cheats.
VehicleOrderID GetNumManualOrders() const
Get the number of manually added orders this vehicle has.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
static Station * GetIfValid(size_t index)
Returns station if the index is a valid index for this station type.