32 #include "table/strings.h" 39 assert_compile(
sizeof(DestinationID) >=
sizeof(
DepotID));
40 assert_compile(
sizeof(DestinationID) >=
sizeof(StationID));
50 if (CleaningPool())
return;
54 if (this->IsType(OT_GOTO_STATION) || this->IsType(OT_GOTO_WAYPOINT)) {
66 this->
type = OT_NOTHING;
78 this->
type = OT_GOTO_STATION;
80 this->
dest = destination;
93 this->
type = OT_GOTO_DEPOT;
97 this->
dest = destination;
107 this->
type = OT_GOTO_WAYPOINT;
109 this->
dest = destination;
118 this->
type = OT_LOADING;
119 if (!ordered) this->
flags = 0;
127 this->
type = OT_LEAVESTATION;
136 this->
type = OT_DUMMY;
146 this->
type = OT_CONDITIONAL;
157 this->
type = OT_IMPLICIT;
158 this->
dest = destination;
211 uint16 order = this->
GetType();
212 switch (this->
type) {
213 case OT_GOTO_STATION:
235 Order::Order(uint32 packed)
238 this->
flags =
GB(packed, 8, 8);
239 this->
dest =
GB(packed, 16, 16);
295 this->first_shared = v;
297 this->num_orders = 0;
298 this->num_manual_orders = 0;
299 this->num_vehicles = 1;
300 this->timetable_duration = 0;
301 this->total_duration = 0;
303 for (
Order *o = this->first; o != NULL; o = o->
next) {
305 if (!o->IsType(OT_IMPLICIT)) ++this->num_manual_orders;
306 this->timetable_duration += o->GetTimetabledWait() + o->GetTimetabledTravel();
307 this->total_duration += o->GetWaitTime() + o->GetTravelTime();
311 ++this->num_vehicles;
312 this->first_shared = u;
326 for (
Order *o = this->first; o != NULL; o =
next) {
331 if (keep_orderlist) {
333 this->num_orders = 0;
334 this->num_manual_orders = 0;
335 this->timetable_duration = 0;
348 if (index < 0)
return NULL;
350 Order *order = this->first;
352 while (order != NULL && index-- > 0) {
371 if (hops > this->GetNumOrders() || next == NULL)
return NULL;
373 if (next->
IsType(OT_CONDITIONAL)) {
378 return this->GetNextDecisionNode(
383 if (next->
IsType(OT_GOTO_DEPOT)) {
385 if (next->
IsRefit())
return next;
388 if (!next->CanLoadOrUnload()) {
389 return this->GetNextDecisionNode(this->GetNext(next), hops + 1);
411 next = this->GetFirstOrder();
412 if (next == NULL)
return INVALID_STATION;
417 next = this->GetNext(next);
418 assert(next != NULL);
423 next = this->GetNextDecisionNode(next, ++hops);
426 while (next != NULL && next->
IsType(OT_CONDITIONAL)) {
428 const Order *skip_to = this->GetNextDecisionNode(
430 const Order *advance = this->GetNextDecisionNode(
431 this->GetNext(next), hops);
432 if (advance == NULL || advance == first || skip_to == advance) {
433 next = (skip_to == first) ? NULL : skip_to;
434 }
else if (skip_to == NULL || skip_to == first) {
435 next = (advance == first) ? NULL : advance;
437 StationIDStack st1 = this->GetNextStoppingStation(v, skip_to, hops);
438 StationIDStack st2 = this->GetNextStoppingStation(v, advance, hops);
446 if (next == NULL || ((next->
IsType(OT_GOTO_STATION) || next->
IsType(OT_IMPLICIT)) &&
449 return INVALID_STATION;
463 if (this->first == NULL) {
464 this->first = new_order;
468 new_order->
next = this->first;
469 this->first = new_order;
470 }
else if (index >= this->num_orders) {
472 this->GetLastOrder()->
next = new_order;
475 Order *order = this->GetOrderAt(index - 1);
477 order->
next = new_order;
481 if (!new_order->
IsType(OT_IMPLICIT)) ++this->num_manual_orders;
487 if (new_order->
IsType(OT_GOTO_STATION) || new_order->
IsType(OT_GOTO_WAYPOINT)) {
501 if (index >= this->num_orders)
return;
506 to_remove = this->first;
507 this->first = to_remove->
next;
509 Order *prev = GetOrderAt(index - 1);
510 to_remove = prev->
next;
514 if (!to_remove->
IsType(OT_IMPLICIT)) --this->num_manual_orders;
527 if (from >= this->num_orders || to >= this->num_orders || from == to)
return;
533 moving_one = this->first;
534 this->first = moving_one->
next;
536 Order *one_before = GetOrderAt(from - 1);
537 moving_one = one_before->
next;
538 one_before->
next = moving_one->
next;
543 moving_one->
next = this->first;
544 this->first = moving_one;
546 Order *one_before = GetOrderAt(to - 1);
547 moving_one->
next = one_before->
next;
548 one_before->
next = moving_one;
559 --this->num_vehicles;
560 if (v == this->first_shared) this->first_shared = v->
NextShared();
569 for (
const Vehicle *v_shared = this->first_shared; v_shared != NULL; v_shared = v_shared->
NextShared()) {
570 if (v_shared == v)
return true;
594 for (
Order *o = this->first; o != NULL; o = o->
next) {
596 if (o->IsType(OT_IMPLICIT))
continue;
597 if (!o->IsCompletelyTimetabled())
return false;
609 uint check_num_vehicles = 0;
610 Ticks check_timetable_duration = 0;
611 Ticks check_total_duration = 0;
613 DEBUG(misc, 6,
"Checking OrderList %hu for sanity...", this->
index);
615 for (
const Order *o = this->first; o != NULL; o = o->
next) {
617 if (!o->IsType(OT_IMPLICIT)) ++check_num_manual_orders;
618 check_timetable_duration += o->GetTimetabledWait() + o->GetTimetabledTravel();
619 check_total_duration += o->GetWaitTime() + o->GetTravelTime();
621 assert(this->num_orders == check_num_orders);
622 assert(this->num_manual_orders == check_num_manual_orders);
623 assert(this->timetable_duration == check_timetable_duration);
624 assert(this->total_duration == check_total_duration);
627 ++check_num_vehicles;
628 assert(v->orders.list ==
this);
630 assert(this->num_vehicles == check_num_vehicles);
631 DEBUG(misc, 6,
"... detected %u orders (%u manual), %u vehicles, %i timetabled, %i total",
632 (uint)this->num_orders, (uint)this->num_manual_orders,
633 this->num_vehicles, this->timetable_duration, this->total_duration);
645 return o->
IsType(OT_GOTO_STATION) ||
673 case OT_GOTO_WAYPOINT:
674 case OT_GOTO_STATION:
699 if (cur->
IsType(OT_CONDITIONAL)) {
706 return max(dist1, dist2);
738 if (ret.
Failed())
return ret;
743 case OT_GOTO_STATION: {
749 if (ret.
Failed())
return ret;
787 case OT_GOTO_DEPOT: {
795 if (ret.
Failed())
return ret;
806 if (ret.
Failed())
return ret;
833 case OT_GOTO_WAYPOINT: {
844 if (ret.
Failed())
return ret;
852 if (ret.
Failed())
return ret;
864 case OT_CONDITIONAL: {
904 const Order *prev = NULL;
911 FOR_VEHICLE_ORDERS(v, o) {
913 case OT_GOTO_STATION:
915 case OT_GOTO_WAYPOINT:
921 if (++n == sel_ord && prev != NULL)
break;
925 if (new_order.
IsType(OT_CONDITIONAL)) {
971 if (sel_ord <= u->cur_real_order_index) {
974 if (cur < u->GetNumOrders()) {
985 if (sel_ord <= u->cur_implicit_order_index) {
988 if (cur < u->GetNumOrders()) {
999 FOR_VEHICLE_ORDERS(v, order) {
1000 if (order->
IsType(OT_CONDITIONAL)) {
1002 if (order_id >= sel_ord) {
1005 if (order_id == cur_order_id) {
1050 if (ret.
Failed())
return ret;
1094 if (sel_ord < u->cur_real_order_index) {
1100 if (sel_ord < u->cur_implicit_order_index) {
1119 Order *order = NULL;
1120 FOR_VEHICLE_ORDERS(v, order) {
1121 if (order->
IsType(OT_CONDITIONAL)) {
1123 if (order_id >= sel_ord) {
1124 order_id =
max(order_id - 1, 0);
1126 if (order_id == cur_order_id) {
1156 if (ret.
Failed())
return ret;
1197 if (ret.
Failed())
return ret;
1205 if (moving_one == NULL)
return CMD_ERROR;
1255 FOR_VEHICLE_ORDERS(v, order) {
1256 if (order->
IsType(OT_CONDITIONAL)) {
1258 if (order_id == moving_order) {
1259 order_id = target_order;
1260 }
else if (order_id > moving_order && order_id <= target_order) {
1262 }
else if (order_id < moving_order && order_id >= target_order) {
1296 uint16 data =
GB(p2, 4, 11);
1304 if (ret.
Failed())
return ret;
1311 case OT_GOTO_STATION:
1319 case OT_GOTO_WAYPOINT:
1323 case OT_CONDITIONAL:
1332 default: NOT_REACHED();
1492 default: NOT_REACHED();
1533 for (
const Order *o = first; o != NULL; o = o->
next) {
1534 switch (o->GetType()) {
1535 case OT_GOTO_STATION:
1537 case OT_GOTO_WAYPOINT:
1569 if (ret.
Failed())
return ret;
1571 switch (
GB(p1, 30, 2)) {
1579 if (ret.
Failed())
return ret;
1591 FOR_VEHICLE_ORDERS(src, order) {
1638 if (ret.
Failed())
return ret;
1643 FOR_VEHICLE_ORDERS(src, order) {
1662 Order *first = NULL;
1671 FOR_VEHICLE_ORDERS(src, order) {
1672 *order_dst =
new Order();
1673 (*order_dst)->AssignOrder(*order);
1674 order_dst = &(*order_dst)->next;
1723 if (ret.
Failed())
return ret;
1747 if (u->cur_real_order_index == order_number && (u->current_order.GetDepotOrderType() &
ODTFB_PART_OF_ORDERS)) {
1748 u->current_order.SetRefit(cargo);
1784 FOR_VEHICLE_ORDERS(v, order) {
1786 if (order->
IsType(OT_DUMMY)) {
1787 message = STR_NEWS_VEHICLE_HAS_VOID_ORDER;
1791 if (order->
IsType(OT_GOTO_STATION)) {
1796 message = STR_NEWS_VEHICLE_HAS_INVALID_ENTRY;
1798 (AircraftVehInfo(v->
engine_type)->subtype & AIR_FAST) &&
1803 message = STR_NEWS_PLANE_USES_TOO_SHORT_RUNWAY;
1813 message = STR_NEWS_VEHICLE_HAS_DUPLICATE_ENTRY;
1818 if (n_st < 2 && message ==
INVALID_STRING_ID) message = STR_NEWS_VEHICLE_HAS_TOO_FEW_ORDERS;
1858 FOR_VEHICLE_ORDERS(v, order) {
1864 if (ot == OT_IMPLICIT || (v->
type ==
VEH_AIRCRAFT && ot == OT_GOTO_DEPOT)) ot = OT_GOTO_STATION;
1869 if (order->
IsType(OT_IMPLICIT)) {
1870 order = order->
next;
1872 if (order != NULL)
goto restart;
1909 FOR_VEHICLE_ORDERS(
this, order) {
1910 if (order->
IsType(OT_GOTO_DEPOT))
return true;
1939 if (reset_order_indices) {
1956 return ispercent ?
Clamp(interval, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) :
Clamp(interval, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
1971 FOR_VEHICLE_ORDERS(v, order) {
1973 case OT_GOTO_STATION:
1975 case OT_GOTO_WAYPOINT:
2000 default: NOT_REACHED();
2014 bool skip_order =
false;
2026 default: NOT_REACHED();
2048 case OT_GOTO_STATION:
2054 assert(!pbs_look_ahead);
2063 DestinationID destination;
2068 if (pbs_look_ahead && reverse)
return false;
2088 if (pbs_look_ahead)
return false;
2100 case OT_GOTO_WAYPOINT:
2104 case OT_CONDITIONAL: {
2105 assert(!pbs_look_ahead);
2138 if (order != NULL && order->IsType(OT_IMPLICIT)) {
2143 if (order == NULL) {
2150 return UpdateOrderDest(v, order, conditional_depth + 1, pbs_look_ahead);
2171 case OT_LEAVESTATION:
2206 if (order != NULL && order->
IsType(OT_IMPLICIT)) {
2215 extern void HandleMissingAircraftOrders(
Aircraft *v);
2261 bool is_dest_station = this->
IsType(OT_GOTO_STATION) && this->
dest == station;
2269 bool Order::CanLoadOrUnload()
const 2271 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.
VehicleSettings vehicle
options for vehicles
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.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
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.
Automatically choose cargo type when doing auto refitting.
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.
static Titem * Get(size_t index)
Returns Titem with given index.
void UpdateTimetableDuration(Ticks delta)
Must be called if an order's timetable is changed to update internal book keeping.
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.
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.
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.
PathfinderSettings pf
settings for all pathfinders
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.
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.
bool CanLeaveWithCargo(bool has_cargo) const
A vehicle can leave the current station with cargo if:
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 NULL, 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.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
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...
StationIDStack GetNextStoppingStation(const Vehicle *v, const Order *first=NULL, uint hops=0) const
Recursively determine the next deterministic station to stop at.
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?
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 give 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.
void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
Removes an order from all vehicles.
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...
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
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.
The tile has no ownership.
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).
StationFacilityByte facilities
The facilities that this station has.
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 NULL 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.
uint8 plane_crashes
number of plane crashes, 0 = none, 1 = reduced, 2 = normal
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.
Maximal number of cargo types in a game.
TileIndex tile
The base tile of the area.
bool HasDepotOrder() const
Checks if a vehicle has a depot in its order list.
OwnerByte owner
The owner of this station.
OrderUnloadFlags
Flags related to the unloading order.
static void RemoveOrder(OrderType type, DestinationID destination)
Removes an order from all vehicles.
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.
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 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?
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
OwnerByte owner
Which company owns the vehicle?
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.
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.
Station with train station.
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.
void UpdateTotalDuration(Ticks delta)
Must be called if an order's timetable is changed to update internal book keeping.
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.
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 NULL 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)
#define FOR_ALL_VEHICLES(var)
Iterate over all vehicles.
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.
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.
Force unloading all cargo onto the platform, possibly not getting paid.
uint8 pathfinder_for_ships
the pathfinder to use for ships
union Vehicle::@46 orders
The orders currently assigned to the vehicle.
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.
This depot order is because of the servicing limit.
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
VehicleTypeByte type
Type of vehicle.
Skip if the variable is false.
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.