OpenTTD Source
20241108-master-g80f628063a
|
Functions related to orders. More...
Go to the source code of this file.
Functions | |
void | RemoveOrderFromAllVehicles (OrderType type, DestinationID destination, bool hangar=false) |
Removes an order from all vehicles. More... | |
void | InvalidateVehicleOrder (const Vehicle *v, int data) |
Updates the widgets of a vehicle which contains the order-data. | |
void | CheckOrders (const Vehicle *) |
Check the orders of a vehicle, to see if there are invalid orders and stuff. | |
void | DeleteVehicleOrders (Vehicle *v, bool keep_orderlist=false, bool reset_order_indices=true) |
Delete all orders from a vehicle. More... | |
bool | ProcessOrders (Vehicle *v) |
Handle the orders of a vehicle and determine the next place to go to if needed. More... | |
bool | UpdateOrderDest (Vehicle *v, const Order *order, int conditional_depth=0, bool pbs_look_ahead=false) |
Update the vehicle's destination tile from an order. More... | |
VehicleOrderID | ProcessConditionalOrder (const Order *order, const Vehicle *v) |
Process a conditional order and determine the next order. More... | |
uint | GetOrderDistance (const Order *prev, const Order *cur, const Vehicle *v, int conditional_depth=0) |
Get the distance between two orders of a vehicle. More... | |
void | DrawOrderString (const Vehicle *v, const Order *order, int order_index, int y, bool selected, bool timetable, int left, int middle, int right) |
Draws an order in order or timetable GUI. More... | |
uint16_t | GetServiceIntervalClamped (int interval, bool ispercent) |
Clamp the service interval to the correct min/max. More... | |
Functions related to orders.
Definition in file order_func.h.
void DeleteVehicleOrders | ( | Vehicle * | v, |
bool | keep_orderlist, | ||
bool | reset_order_indices | ||
) |
Delete all orders from a vehicle.
v | Vehicle whose orders to reset |
keep_orderlist | If true, do not free the order list, only empty it. |
reset_order_indices | If true, reset cur_implicit_order_index and cur_real_order_index and cancel the current full load order (if the vehicle is loading). If false, you have to make sure the order indices are valid after your messing with them! |
Definition at line 1869 of file order_cmd.cpp.
References BaseConsist::cur_implicit_order_index, BaseConsist::cur_real_order_index, Vehicle::current_order, DeleteOrderWarnings(), OrderList::FreeChain(), Vehicle::IsOrderListShared(), Order::IsType(), Vehicle::orders, Vehicle::RemoveFromShared(), and BaseConsist::ResetDepotUnbunching().
Referenced by CmdSellRailWagon(), and DecloneOrder().
void DrawOrderString | ( | const Vehicle * | v, |
const Order * | order, | ||
int | order_index, | ||
int | y, | ||
bool | selected, | ||
bool | timetable, | ||
int | left, | ||
int | middle, | ||
int | right | ||
) |
Draws an order in order or timetable GUI.
v | Vehicle the order belongs to |
order | The order to draw |
order_index | Index of the order in the orders of the vehicle |
y | Y position for drawing |
selected | True, if the order is selected |
timetable | True, when drawing in the timetable GUI |
left | Left border for text drawing |
middle | X position between order index and order text |
right | Right border for text drawing |
Definition at line 214 of file order_gui.cpp.
uint GetOrderDistance | ( | const Order * | prev, |
const Order * | cur, | ||
const Vehicle * | v, | ||
int | conditional_depth | ||
) |
Get the distance between two orders of a vehicle.
Conditional orders are resolved and the bigger distance of the two order branches is returned.
prev | Origin order. |
cur | Destination order. |
v | The vehicle to get the distance for. |
conditional_depth | Internal param for resolving conditional orders. |
Definition at line 669 of file order_cmd.cpp.
References Order::IsType().
uint16_t GetServiceIntervalClamped | ( | int | interval, |
bool | ispercent | ||
) |
Clamp the service interval to the correct min/max.
The actual min/max values depend on whether it's in days, minutes, or percent.
interval | The proposed service interval. |
ispercent | Whether the interval is a percent. |
Definition at line 1901 of file order_cmd.cpp.
VehicleOrderID ProcessConditionalOrder | ( | const Order * | order, |
const Vehicle * | v | ||
) |
Process a conditional order and determine the next order.
order | the order the vehicle currently has |
v | the vehicle to update |
Definition at line 1968 of file order_cmd.cpp.
References Order::GetType().
bool ProcessOrders | ( | Vehicle * | v | ) |
Handle the orders of a vehicle and determine the next place to go to if needed.
v | the vehicle to do this for. |
Reversing because of order change is allowed only just after leaving a station (and the difficulty setting to allowed, of course) this can be detected because only after OT_LEAVESTATION, current_order will be reset to nothing. (That also happens if no order, but in that case it won't hit the point in code where may_reverse is checked)
Definition at line 2127 of file order_cmd.cpp.
References Vehicle::current_order, and Order::GetType().
void RemoveOrderFromAllVehicles | ( | OrderType | type, |
DestinationID | destination, | ||
bool | hangar | ||
) |
Removes an order from all vehicles.
Triggers when, say, a station is removed.
type | The type of the order (OT_GOTO_[STATION|DEPOT|WAYPOINT]). |
destination | The destination. Can be a StationID, DepotID or WaypointID. |
hangar | Only used for airports in the destination. When false, remove airport and hangar orders. When true, remove either airport or hangar order. |
Definition at line 1787 of file order_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Iterate(), and VEH_AIRCRAFT.
Referenced by Depot::~Depot().
bool UpdateOrderDest | ( | Vehicle * | v, |
const Order * | order, | ||
int | conditional_depth, | ||
bool | pbs_look_ahead | ||
) |
Update the vehicle's destination tile from an order.
order | the order the vehicle currently has |
v | the vehicle to update |
conditional_depth | the depth (amount of steps) to go with conditional orders. This to prevent infinite loops. |
pbs_look_ahead | Whether we are forecasting orders for pbs reservations in advance. If true, the order indices must not be modified. |
Definition at line 1998 of file order_cmd.cpp.
References Vehicle::current_order, Order::Free(), Vehicle::GetNumOrders(), and Order::GetType().