Class that handles all order related functions. More...
#include <script_order.hpp>
Public Types | |
enum | ErrorMessages { ERR_ORDER_BASE = ScriptError::ERR_CAT_ORDER << ScriptError::ERR_CAT_BIT_SIZE, ERR_ORDER_TOO_MANY, ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION, ERR_ORDER_AIRCRAFT_NOT_ENOUGH_RANGE } |
All order related error messages. More... | |
enum | ScriptOrderFlags { AIOF_NONE = 0, AIOF_NON_STOP_INTERMEDIATE = 1 << 0, AIOF_NON_STOP_DESTINATION = 1 << 1, AIOF_UNLOAD = 1 << 2, AIOF_TRANSFER = 1 << 3, AIOF_NO_UNLOAD = 1 << 4, AIOF_FULL_LOAD = 2 << 5, AIOF_FULL_LOAD_ANY = 3 << 5, AIOF_NO_LOAD = 1 << 7, AIOF_SERVICE_IF_NEEDED = 1 << 2, AIOF_STOP_IN_DEPOT = 1 << 3, AIOF_GOTO_NEAREST_DEPOT = 1 << 8, AIOF_NON_STOP_FLAGS = AIOF_NON_STOP_INTERMEDIATE | AIOF_NON_STOP_DESTINATION, AIOF_UNLOAD_FLAGS = AIOF_TRANSFER | AIOF_UNLOAD | AIOF_NO_UNLOAD, AIOF_LOAD_FLAGS = AIOF_FULL_LOAD | AIOF_FULL_LOAD_ANY | AIOF_NO_LOAD, AIOF_DEPOT_FLAGS = AIOF_SERVICE_IF_NEEDED | AIOF_STOP_IN_DEPOT | AIOF_GOTO_NEAREST_DEPOT, AIOF_INVALID = 0xFFFF } |
Flags that can be used to modify the behaviour of orders. More... | |
enum | OrderCondition { OC_LOAD_PERCENTAGE, OC_RELIABILITY, OC_MAX_SPEED, OC_AGE, OC_REQUIRES_SERVICE, OC_UNCONDITIONALLY, OC_REMAINING_LIFETIME, OC_INVALID = -1 } |
All conditions a conditional order can depend on. More... | |
enum | CompareFunction { CF_EQUALS, CF_NOT_EQUALS, CF_LESS_THAN, CF_LESS_EQUALS, CF_MORE_THAN, CF_MORE_EQUALS, CF_IS_TRUE, CF_IS_FALSE, CF_INVALID = -1 } |
Comparators for conditional orders. More... | |
enum | OrderPosition { ORDER_CURRENT = 0xFF, ORDER_INVALID = -1 } |
Index in the list of orders for a vehicle. More... | |
enum | StopLocation { STOPLOCATION_NEAR, STOPLOCATION_MIDDLE, STOPLOCATION_FAR, STOPLOCATION_INVALID = -1 } |
Where to stop trains in a station that's longer than the train. More... | |
Static Public Member Functions | |
static bool | IsValidVehicleOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order id is valid for the given vehicle. | |
static bool | IsGotoStationOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order is a goto-station order. | |
static bool | IsGotoDepotOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order is a goto-depot order. | |
static bool | IsGotoWaypointOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order is a goto-waypoint order. | |
static bool | IsConditionalOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order is a conditional order. | |
static bool | IsVoidOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order is a void order. | |
static bool | IsRefitOrder (VehicleID vehicle_id, OrderPosition order_position) |
Checks whether the given order has a valid refit cargo. | |
static bool | IsCurrentOrderPartOfOrderList (VehicleID vehicle_id) |
Checks whether the current order is part of the orderlist. | |
static OrderPosition | ResolveOrderPosition (VehicleID vehicle_id, OrderPosition order_position) |
Resolves the given order index to the correct index for the given vehicle. | |
static bool | AreOrderFlagsValid (TileIndex destination, ScriptOrderFlags order_flags) |
Checks whether the given order flags are valid for the given destination. | |
static bool | IsValidConditionalOrder (OrderCondition condition, CompareFunction compare) |
Checks whether the given combination of condition and compare function is valid. | |
static int32 | GetOrderCount (VehicleID vehicle_id) |
Returns the number of orders for the given vehicle. | |
static TileIndex | GetOrderDestination (VehicleID vehicle_id, OrderPosition order_position) |
Gets the destination of the given order for the given vehicle. | |
static ScriptOrderFlags | GetOrderFlags (VehicleID vehicle_id, OrderPosition order_position) |
Gets the ScriptOrderFlags of the given order for the given vehicle. | |
static OrderPosition | GetOrderJumpTo (VehicleID vehicle_id, OrderPosition order_position) |
Gets the OrderPosition to jump to if the check succeeds of the given order for the given vehicle. | |
static OrderCondition | GetOrderCondition (VehicleID vehicle_id, OrderPosition order_position) |
Gets the OrderCondition of the given order for the given vehicle. | |
static CompareFunction | GetOrderCompareFunction (VehicleID vehicle_id, OrderPosition order_position) |
Gets the CompareFunction of the given order for the given vehicle. | |
static int32 | GetOrderCompareValue (VehicleID vehicle_id, OrderPosition order_position) |
Gets the value to compare against of the given order for the given vehicle. | |
static StopLocation | GetStopLocation (VehicleID vehicle_id, OrderPosition order_position) |
Gets the stoplocation of the given order for the given train. | |
static CargoID | GetOrderRefit (VehicleID vehicle_id, OrderPosition order_position) |
Gets the refit cargo type of the given order for the given vehicle. | |
static bool | SetOrderJumpTo (VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to) |
Sets the OrderPosition to jump to if the check succeeds of the given order for the given vehicle. | |
static bool | SetOrderCondition (VehicleID vehicle_id, OrderPosition order_position, OrderCondition condition) |
Sets the OrderCondition of the given order for the given vehicle. | |
static bool | SetOrderCompareFunction (VehicleID vehicle_id, OrderPosition order_position, CompareFunction compare) |
Sets the CompareFunction of the given order for the given vehicle. | |
static bool | SetOrderCompareValue (VehicleID vehicle_id, OrderPosition order_position, int32 value) |
Sets the value to compare against of the given order for the given vehicle. | |
static bool | SetStopLocation (VehicleID vehicle_id, OrderPosition order_position, StopLocation stop_location) |
Sets the stoplocation of the given order for the given train. | |
static bool | SetOrderRefit (VehicleID vehicle_id, OrderPosition order_position, CargoID refit_cargo) |
Sets the refit cargo type of the given order for the given vehicle. | |
static bool | AppendOrder (VehicleID vehicle_id, TileIndex destination, ScriptOrderFlags order_flags) |
Appends an order to the end of the vehicle's order list. | |
static bool | AppendConditionalOrder (VehicleID vehicle_id, OrderPosition jump_to) |
Appends a conditional order to the end of the vehicle's order list. | |
static bool | InsertOrder (VehicleID vehicle_id, OrderPosition order_position, TileIndex destination, ScriptOrderFlags order_flags) |
Inserts an order before the given order_position into the vehicle's order list. | |
static bool | InsertConditionalOrder (VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to) |
Appends a conditional order before the given order_position into the vehicle's order list. | |
static bool | RemoveOrder (VehicleID vehicle_id, OrderPosition order_position) |
Removes an order from the vehicle's order list. | |
static bool | _SetOrderFlags () |
Internal function to help SetOrderFlags. | |
static bool | SetOrderFlags (VehicleID vehicle_id, OrderPosition order_position, ScriptOrderFlags order_flags) |
Changes the order flags of the given order. | |
static bool | MoveOrder (VehicleID vehicle_id, OrderPosition order_position_move, OrderPosition order_position_target) |
Move an order inside the orderlist. | |
static bool | SkipToOrder (VehicleID vehicle_id, OrderPosition next_order) |
Make a vehicle execute next_order instead of its current order. | |
static bool | CopyOrders (VehicleID vehicle_id, VehicleID main_vehicle_id) |
Copies the orders from another vehicle. | |
static bool | ShareOrders (VehicleID vehicle_id, VehicleID main_vehicle_id) |
Shares the orders between two vehicles. | |
static bool | UnshareOrders (VehicleID vehicle_id) |
Removes the given vehicle from a shared orders list. | |
static uint | GetOrderDistance (ScriptVehicle::VehicleType vehicle_type, TileIndex origin_tile, TileIndex dest_tile) |
Get the distance between two points for a vehicle type. |
Class that handles all order related functions.
ai
Definition at line 22 of file script_order.hpp.
Comparators for conditional orders.
Definition at line 105 of file script_order.hpp.
All order related error messages.
Definition at line 27 of file script_order.hpp.
All conditions a conditional order can depend on.
OC_LOAD_PERCENTAGE |
Skip based on the amount of load, value is in tons. |
OC_RELIABILITY |
Skip based on the reliability, value is percent (0..100). |
OC_MAX_SPEED |
Skip based on the maximum speed, value is in OpenTTD's internal speed unit, see ScriptEngine::GetMaxSpeed. |
OC_AGE |
Skip based on the age, value is in years. |
OC_REQUIRES_SERVICE |
Skip when the vehicle requires service, no value. |
OC_UNCONDITIONALLY |
Always skip, no compare function, no value. |
OC_REMAINING_LIFETIME |
Skip based on the remaining lifetime. |
OC_INVALID |
An invalid condition, do not use. |
Definition at line 90 of file script_order.hpp.
Index in the list of orders for a vehicle.
The first order has index 0, the second order index 1, etc. The current order can be queried by using ORDER_CURRENT. Do not use ORDER_INVALID yourself, it's used as return value by for example ResolveOrderPosition.
ORDER_CURRENT |
Constant that gets resolved to the current order. |
ORDER_INVALID |
An invalid order. |
Definition at line 125 of file script_order.hpp.
Flags that can be used to modify the behaviour of orders.
Definition at line 44 of file script_order.hpp.
Where to stop trains in a station that's longer than the train.
Definition at line 131 of file script_order.hpp.
bool ScriptOrder::_SetOrderFlags | ( | ) | [static] |
Internal function to help SetOrderFlags.
-all
Definition at line 556 of file script_order.cpp.
References _DoCommandReturnSetOrderFlags(), AIOF_DEPOT_FLAGS, AIOF_GOTO_NEAREST_DEPOT, AIOF_LOAD_FLAGS, AIOF_NON_STOP_FLAGS, AIOF_SERVICE_IF_NEEDED, AIOF_STOP_IN_DEPOT, AIOF_UNLOAD_FLAGS, AreOrderFlagsValid(), CMD_MODIFY_ORDER, DEBUG, ScriptObject::DoCommand(), EnforcePrecondition, ScriptObject::GetCallbackVariable(), GetOrderDestination(), GetOrderFlags(), Order::GetType(), IsValidVehicleOrder(), MOF_DEPOT_ACTION, MOF_LOAD, MOF_NON_STOP, MOF_UNLOAD, ResolveOrder(), ResolveOrderPosition(), ScriptOrderPositionToRealOrderPosition(), and ScriptObject::SetCallbackVariable().
Referenced by _DoCommandReturnSetOrderFlags(), and SetOrderFlags().
bool ScriptOrder::AppendConditionalOrder | ( | VehicleID | vehicle_id, | |
OrderPosition | jump_to | |||
) | [static] |
Appends a conditional order to the end of the vehicle's order list.
vehicle_id | The vehicle to append the order to. | |
jump_to | The OrderPosition to jump to if the condition is true. |
Definition at line 444 of file script_order.cpp.
References EnforcePrecondition, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), InsertConditionalOrder(), ScriptVehicle::IsValidVehicle(), and IsValidVehicleOrder().
bool ScriptOrder::AppendOrder | ( | VehicleID | vehicle_id, | |
TileIndex | destination, | |||
ScriptOrderFlags | order_flags | |||
) | [static] |
Appends an order to the end of the vehicle's order list.
vehicle_id | The vehicle to append the order to. | |
destination | The destination of the order. | |
order_flags | The flags given to the order. |
ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY | ||
ScriptOrder::ERR_ORDER_TOO_MANY | ||
ScriptOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION |
Definition at line 436 of file script_order.cpp.
References AreOrderFlagsValid(), EnforcePrecondition, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), InsertOrder(), and ScriptVehicle::IsValidVehicle().
bool ScriptOrder::AreOrderFlagsValid | ( | TileIndex | destination, | |
ScriptOrderFlags | order_flags | |||
) | [static] |
Checks whether the given order flags are valid for the given destination.
destination | The destination of the order. | |
order_flags | The flags given to the order. |
Definition at line 184 of file script_order.cpp.
References AIOF_DEPOT_FLAGS, AIOF_LOAD_FLAGS, AIOF_NO_LOAD, AIOF_NO_UNLOAD, AIOF_NON_STOP_FLAGS, AIOF_SERVICE_IF_NEEDED, AIOF_TRANSFER, AIOF_UNLOAD, AIOF_UNLOAD_FLAGS, and GetOrderTypeByTile().
Referenced by _SetOrderFlags(), AppendOrder(), and InsertOrder().
Copies the orders from another vehicle.
The orders of the main vehicle are going to be the orders of the changed vehicle.
vehicle_id | The vehicle to copy the orders to. | |
main_vehicle_id | The vehicle to copy the orders from. |
ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY | ||
ScriptOrder::ERR_ORDER_TOO_MANY | ||
ScriptOrder::ERR_ORDER_AIRCRAFT_NOT_ENOUGH_RANGE |
Definition at line 637 of file script_order.cpp.
References CMD_CLONE_ORDER, ScriptObject::DoCommand(), EnforcePrecondition, and ScriptVehicle::IsValidVehicle().
ScriptOrder::CompareFunction ScriptOrder::GetOrderCompareFunction | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Gets the CompareFunction of the given order for the given vehicle.
vehicle_id | The vehicle to get the compare function for. | |
order_position | The order to get the compare function for. |
Definition at line 331 of file script_order.cpp.
References Order::GetConditionComparator(), IsConditionalOrder(), IsValidVehicleOrder(), ORDER_CURRENT, and ResolveOrder().
int32 ScriptOrder::GetOrderCompareValue | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Gets the value to compare against of the given order for the given vehicle.
vehicle_id | The vehicle to get the value for. | |
order_position | The order to get the value for. |
Definition at line 340 of file script_order.cpp.
References Order::GetConditionValue(), Order::GetConditionVariable(), IsConditionalOrder(), IsValidVehicleOrder(), ORDER_CURRENT, and ResolveOrder().
ScriptOrder::OrderCondition ScriptOrder::GetOrderCondition | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Gets the OrderCondition of the given order for the given vehicle.
vehicle_id | The vehicle to get the condition type for. | |
order_position | The order to get the condition type for. |
Definition at line 322 of file script_order.cpp.
References Order::GetConditionVariable(), IsConditionalOrder(), IsValidVehicleOrder(), ORDER_CURRENT, and ResolveOrder().
Referenced by SetOrderCompareValue().
int32 ScriptOrder::GetOrderCount | ( | VehicleID | vehicle_id | ) | [static] |
Returns the number of orders for the given vehicle.
vehicle_id | The vehicle to get the order count of. |
Definition at line 227 of file script_order.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), and ScriptVehicle::IsValidVehicle().
Referenced by IsCurrentOrderPartOfOrderList().
TileIndex ScriptOrder::GetOrderDestination | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Gets the destination of the given order for the given vehicle.
vehicle_id | The vehicle to get the destination for. | |
order_position | The order to get the destination for. |
Definition at line 232 of file script_order.cpp.
References Station::airport, Station::bus_stops, Station::dock_tile, SpecializedStation< Waypoint, true >::Get(), SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Order::GetDepotActionType(), Order::GetDestination(), Order::GetType(), INVALID_TILE, IsHangar(), IsValidVehicleOrder(), ResolveOrder(), TileArea::tile, TILE_AREA_LOOP, Waypoint::TileBelongsToRailStation(), Station::TileBelongsToRailStation(), BaseStation::train_station, Station::truck_stops, BaseVehicle::type, VEH_AIRCRAFT, BaseStation::xy, and RoadStop::xy.
Referenced by _SetOrderFlags().
uint ScriptOrder::GetOrderDistance | ( | ScriptVehicle::VehicleType | vehicle_type, | |
TileIndex | origin_tile, | |||
TileIndex | dest_tile | |||
) | [static] |
Get the distance between two points for a vehicle type.
vehicle_type | The vehicle type to get the distance for. | |
origin_tile | Origin, can be any tile or a tile of a specific station. | |
dest_tile | Destination, ca be any tile or a tile of a specific station. |
Definition at line 660 of file script_order.cpp.
References DistanceManhattan(), ScriptMap::DistanceSquare(), SpecializedStation< Station, false >::Get(), INVALID_TILE, ScriptTile::IsStationTile(), and ScriptVehicle::VT_AIR.
ScriptOrder::ScriptOrderFlags ScriptOrder::GetOrderFlags | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Gets the ScriptOrderFlags of the given order for the given vehicle.
vehicle_id | The vehicle to get the destination for. | |
order_position | The order to get the destination for. |
Definition at line 286 of file script_order.cpp.
References AIOF_GOTO_NEAREST_DEPOT, AIOF_INVALID, AIOF_SERVICE_IF_NEEDED, AIOF_STOP_IN_DEPOT, Order::GetDepotActionType(), Order::GetDepotOrderType(), Order::GetLoadType(), Order::GetNonStopType(), Order::GetType(), Order::GetUnloadType(), IsValidVehicleOrder(), and ResolveOrder().
Referenced by _SetOrderFlags().
ScriptOrder::OrderPosition ScriptOrder::GetOrderJumpTo | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Gets the OrderPosition to jump to if the check succeeds of the given order for the given vehicle.
vehicle_id | The vehicle to get the OrderPosition for. | |
order_position | The order to get the OrderPosition for. |
Definition at line 313 of file script_order.cpp.
References Order::GetConditionSkipToOrder(), IsConditionalOrder(), IsValidVehicleOrder(), ORDER_CURRENT, and ResolveOrder().
CargoID ScriptOrder::GetOrderRefit | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Gets the refit cargo type of the given order for the given vehicle.
vehicle_id | The vehicle to get the refit cargo for. | |
order_position | The order to get the refit cargo for. |
Definition at line 361 of file script_order.cpp.
References CT_NO_REFIT, Order::GetRefitCargo(), IsGotoDepotOrder(), IsGotoStationOrder(), Order::IsRefit(), IsValidVehicleOrder(), ORDER_CURRENT, and ResolveOrder().
ScriptOrder::StopLocation ScriptOrder::GetStopLocation | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Gets the stoplocation of the given order for the given train.
vehicle_id | The vehicle to get the value for. | |
order_position | The order to get the value for. |
Definition at line 351 of file script_order.cpp.
References Order::GetStopLocation(), ScriptVehicle::GetVehicleType(), IsGotoStationOrder(), IsValidVehicleOrder(), ResolveOrder(), and ScriptVehicle::VT_RAIL.
bool ScriptOrder::InsertConditionalOrder | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position, | |||
OrderPosition | jump_to | |||
) | [static] |
Appends a conditional order before the given order_position into the vehicle's order list.
vehicle_id | The vehicle to add the order to. | |
order_position | The order to place the new order before. | |
jump_to | The OrderPosition to jump to if the condition is true. |
Definition at line 506 of file script_order.cpp.
References ScriptObject::DoCommand(), EnforcePrecondition, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), ScriptVehicle::IsValidVehicle(), IsValidVehicleOrder(), Order::MakeConditional(), ORDER_CURRENT, Order::Pack(), ResolveOrderPosition(), and ScriptOrderPositionToRealOrderPosition().
Referenced by AppendConditionalOrder().
bool ScriptOrder::InsertOrder | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position, | |||
TileIndex | destination, | |||
ScriptOrder::ScriptOrderFlags | order_flags | |||
) | [static] |
Inserts an order before the given order_position into the vehicle's order list.
vehicle_id | The vehicle to add the order to. | |
order_position | The order to place the new order before. | |
destination | The destination of the order. | |
order_flags | The flags given to the order. |
ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY | ||
ScriptOrder::ERR_ORDER_TOO_MANY | ||
ScriptOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION |
Definition at line 452 of file script_order.cpp.
References AIOF_GOTO_NEAREST_DEPOT, AIOF_NON_STOP_INTERMEDIATE, AIOF_SERVICE_IF_NEEDED, AIOF_STOP_IN_DEPOT, AreOrderFlagsValid(), ScriptObject::DoCommand(), EnforcePrecondition, GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetDepotIndex(), GetOrderTypeByTile(), GetStationIndex(), IsTileType(), ScriptVehicle::IsValidVehicle(), Order::MakeGoToDepot(), Order::MakeGoToStation(), Order::MakeGoToWaypoint(), MP_STATION, ODATF_SERVICE_ONLY, ODATFB_HALT, ODTFB_PART_OF_ORDERS, ODTFB_SERVICE, ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, ORDER_CURRENT, OSL_PLATFORM_FAR_END, Order::Pack(), ResolveOrderPosition(), ScriptOrderPositionToRealOrderPosition(), Order::SetLoadType(), Order::SetNonStopType(), Order::SetStopLocation(), Order::SetUnloadType(), and VEH_AIRCRAFT.
Referenced by AppendOrder().
bool ScriptOrder::IsConditionalOrder | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Checks whether the given order is a conditional order.
vehicle_id | The vehicle to check. | |
order_position | The order index to check. |
Definition at line 129 of file script_order.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Order::GetType(), IsValidVehicleOrder(), ORDER_CURRENT, and ScriptOrderPositionToRealOrderPosition().
Referenced by GetOrderCompareFunction(), GetOrderCompareValue(), GetOrderCondition(), GetOrderJumpTo(), SetOrderCompareFunction(), SetOrderCompareValue(), SetOrderCondition(), and SetOrderJumpTo().
bool ScriptOrder::IsCurrentOrderPartOfOrderList | ( | VehicleID | vehicle_id | ) | [static] |
Checks whether the current order is part of the orderlist.
vehicle_id | The vehicle to check. |
Definition at line 155 of file script_order.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Order::GetDepotOrderType(), GetOrderCount(), Order::GetType(), and ScriptVehicle::IsValidVehicle().
bool ScriptOrder::IsGotoDepotOrder | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Checks whether the given order is a goto-depot order.
vehicle_id | The vehicle to check. | |
order_position | The order index to check. |
Definition at line 113 of file script_order.cpp.
References Order::GetType(), IsValidVehicleOrder(), and ResolveOrder().
Referenced by GetOrderRefit(), and SetOrderRefit().
bool ScriptOrder::IsGotoStationOrder | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Checks whether the given order is a goto-station order.
vehicle_id | The vehicle to check. | |
order_position | The order index to check. |
Definition at line 105 of file script_order.cpp.
References Order::GetType(), IsValidVehicleOrder(), and ResolveOrder().
Referenced by GetOrderRefit(), GetStopLocation(), SetOrderRefit(), and SetStopLocation().
bool ScriptOrder::IsGotoWaypointOrder | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Checks whether the given order is a goto-waypoint order.
vehicle_id | The vehicle to check. | |
order_position | The order index to check. |
Definition at line 121 of file script_order.cpp.
References Order::GetType(), IsValidVehicleOrder(), and ResolveOrder().
bool ScriptOrder::IsRefitOrder | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Checks whether the given order has a valid refit cargo.
vehicle_id | The vehicle to check. | |
order_position | The order index to check. |
Definition at line 147 of file script_order.cpp.
References Order::IsRefit(), IsValidVehicleOrder(), and ResolveOrder().
bool ScriptOrder::IsValidConditionalOrder | ( | OrderCondition | condition, | |
CompareFunction | compare | |||
) | [static] |
Checks whether the given combination of condition and compare function is valid.
condition | The condition to check. | |
compare | The compare function to check. |
Definition at line 207 of file script_order.cpp.
References CF_EQUALS, CF_IS_TRUE, OC_AGE, OC_LOAD_PERCENTAGE, OC_MAX_SPEED, OC_RELIABILITY, OC_REMAINING_LIFETIME, OC_REQUIRES_SERVICE, and OC_UNCONDITIONALLY.
bool ScriptOrder::IsValidVehicleOrder | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Checks whether the given order id is valid for the given vehicle.
vehicle_id | The vehicle to check the order index for. | |
order_position | The order index to check. |
Definition at line 51 of file script_order.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), and ScriptVehicle::IsValidVehicle().
Referenced by _SetOrderFlags(), AppendConditionalOrder(), GetOrderCompareFunction(), GetOrderCompareValue(), GetOrderCondition(), GetOrderDestination(), GetOrderFlags(), GetOrderJumpTo(), GetOrderRefit(), GetStopLocation(), InsertConditionalOrder(), IsConditionalOrder(), IsGotoDepotOrder(), IsGotoStationOrder(), IsGotoWaypointOrder(), IsRefitOrder(), IsVoidOrder(), MoveOrder(), RemoveOrder(), ScriptOrderPositionToRealOrderPosition(), SetOrderCompareFunction(), SetOrderCompareValue(), SetOrderCondition(), SetOrderJumpTo(), SetOrderRefit(), SetStopLocation(), and SkipToOrder().
bool ScriptOrder::IsVoidOrder | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Checks whether the given order is a void order.
A void order is an order that used to be a goto station, depot or waypoint order but its destination got removed. In OpenTTD these orders as shown as "(Invalid Order)" in the order list of a vehicle.
vehicle_id | The vehicle to check. | |
order_position | The order index to check. |
Definition at line 138 of file script_order.cpp.
References Order::GetType(), IsValidVehicleOrder(), ORDER_CURRENT, and ResolveOrder().
bool ScriptOrder::MoveOrder | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position_move, | |||
OrderPosition | order_position_target | |||
) | [static] |
Move an order inside the orderlist.
vehicle_id | The vehicle to move the orders. | |
order_position_move | The order to move. | |
order_position_target | The target order |
ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY |
Definition at line 624 of file script_order.cpp.
References CMD_MOVE_ORDER, ScriptObject::DoCommand(), EnforcePrecondition, IsValidVehicleOrder(), ResolveOrderPosition(), and ScriptOrderPositionToRealOrderPosition().
bool ScriptOrder::RemoveOrder | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Removes an order from the vehicle's order list.
vehicle_id | The vehicle to remove the order from. | |
order_position | The order to remove from the order list. |
ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY |
Definition at line 522 of file script_order.cpp.
References CMD_DELETE_ORDER, ScriptObject::DoCommand(), EnforcePrecondition, IsValidVehicleOrder(), ResolveOrderPosition(), and ScriptOrderPositionToRealOrderPosition().
ScriptOrder::OrderPosition ScriptOrder::ResolveOrderPosition | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position | |||
) | [static] |
Resolves the given order index to the correct index for the given vehicle.
If the order index was ORDER_CURRENT it will be resolved to the index of the current order (as shown in the order list). If the order with the given index does not exist it will return ORDER_INVALID.
vehicle_id | The vehicle to check the order index for. | |
order_position | The order index to resolve. |
Definition at line 165 of file script_order.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), ScriptVehicle::IsValidVehicle(), ORDER_CURRENT, and ORDER_INVALID.
Referenced by _SetOrderFlags(), InsertConditionalOrder(), InsertOrder(), MoveOrder(), RemoveOrder(), ResolveOrder(), SetOrderRefit(), SetStopLocation(), and SkipToOrder().
bool ScriptOrder::SetOrderCompareFunction | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position, | |||
CompareFunction | compare | |||
) | [static] |
Sets the CompareFunction of the given order for the given vehicle.
vehicle_id | The vehicle to set the compare function for. | |
order_position | The order to set the compare function for. | |
compare | The new compare function of the order. |
Definition at line 389 of file script_order.cpp.
References CF_EQUALS, CF_IS_FALSE, CMD_MODIFY_ORDER, ScriptObject::DoCommand(), EnforcePrecondition, IsConditionalOrder(), IsValidVehicleOrder(), MOF_COND_COMPARATOR, ORDER_CURRENT, and ScriptOrderPositionToRealOrderPosition().
bool ScriptOrder::SetOrderCompareValue | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position, | |||
int32 | value | |||
) | [static] |
Sets the value to compare against of the given order for the given vehicle.
vehicle_id | The vehicle to set the value for. | |
order_position | The order to set the value for. | |
value | The value to compare against. |
Definition at line 399 of file script_order.cpp.
References CMD_MODIFY_ORDER, ScriptObject::DoCommand(), EnforcePrecondition, GetOrderCondition(), IsConditionalOrder(), IsValidVehicleOrder(), MOF_COND_VALUE, OC_MAX_SPEED, ORDER_CURRENT, and ScriptOrderPositionToRealOrderPosition().
bool ScriptOrder::SetOrderCondition | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position, | |||
OrderCondition | condition | |||
) | [static] |
Sets the OrderCondition of the given order for the given vehicle.
vehicle_id | The vehicle to set the condition type for. | |
order_position | The order to set the condition type for. | |
condition | The condition to compare on. |
Definition at line 379 of file script_order.cpp.
References CMD_MODIFY_ORDER, ScriptObject::DoCommand(), EnforcePrecondition, IsConditionalOrder(), IsValidVehicleOrder(), MOF_COND_VARIABLE, OC_LOAD_PERCENTAGE, OC_REMAINING_LIFETIME, ORDER_CURRENT, and ScriptOrderPositionToRealOrderPosition().
bool ScriptOrder::SetOrderFlags | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position, | |||
ScriptOrder::ScriptOrderFlags | order_flags | |||
) | [static] |
Changes the order flags of the given order.
vehicle_id | The vehicle to change the order of. | |
order_position | The order to change. | |
order_flags | The new flags given to the order. |
ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY |
Definition at line 613 of file script_order.cpp.
References _SetOrderFlags(), and ScriptObject::SetCallbackVariable().
bool ScriptOrder::SetOrderJumpTo | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position, | |||
OrderPosition | jump_to | |||
) | [static] |
Sets the OrderPosition to jump to if the check succeeds of the given order for the given vehicle.
vehicle_id | The vehicle to set the OrderPosition for. | |
order_position | The order to set the OrderPosition for. | |
jump_to | The order to jump to if the check succeeds. |
Definition at line 370 of file script_order.cpp.
References CMD_MODIFY_ORDER, ScriptObject::DoCommand(), EnforcePrecondition, IsConditionalOrder(), IsValidVehicleOrder(), MOF_COND_DESTINATION, and ORDER_CURRENT.
bool ScriptOrder::SetOrderRefit | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position, | |||
CargoID | refit_cargo | |||
) | [static] |
Sets the refit cargo type of the given order for the given vehicle.
vehicle_id | The vehicle to set the refit cargo for. | |
order_position | The order to set the refit cargo for. | |
refit_cargo | The cargo to refit to. The refit can be cleared by passing CT_NO_REFIT. |
Definition at line 425 of file script_order.cpp.
References CMD_ORDER_REFIT, CT_AUTO_REFIT, CT_NO_REFIT, ScriptObject::DoCommand(), EnforcePrecondition, IsGotoDepotOrder(), IsGotoStationOrder(), ScriptCargo::IsValidCargo(), IsValidVehicleOrder(), ResolveOrderPosition(), and ScriptOrderPositionToRealOrderPosition().
bool ScriptOrder::SetStopLocation | ( | VehicleID | vehicle_id, | |
OrderPosition | order_position, | |||
StopLocation | stop_location | |||
) | [static] |
Sets the stoplocation of the given order for the given train.
vehicle_id | The vehicle to get the value for. | |
order_position | The order to get the value for. | |
stop_location | The relative position where a train will stop inside a station. |
Definition at line 410 of file script_order.cpp.
References CMD_MODIFY_ORDER, ScriptObject::DoCommand(), EnforcePrecondition, ScriptVehicle::GetVehicleType(), IsGotoStationOrder(), IsValidVehicleOrder(), MOF_STOP_LOCATION, ResolveOrderPosition(), ScriptOrderPositionToRealOrderPosition(), STOPLOCATION_FAR, STOPLOCATION_NEAR, and ScriptVehicle::VT_RAIL.
Shares the orders between two vehicles.
The orders of the main vehicle are going to be the orders of the changed vehicle.
vehicle_id | The vehicle to add to the shared order list. | |
main_vehicle_id | The vehicle to share the orders with. |
ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY | ||
ScriptOrder::ERR_ORDER_AIRCRAFT_NOT_ENOUGH_RANGE |
Definition at line 645 of file script_order.cpp.
References CMD_CLONE_ORDER, ScriptObject::DoCommand(), EnforcePrecondition, and ScriptVehicle::IsValidVehicle().
bool ScriptOrder::SkipToOrder | ( | VehicleID | vehicle_id, | |
OrderPosition | next_order | |||
) | [static] |
Make a vehicle execute next_order instead of its current order.
vehicle_id | The vehicle that should skip some orders. | |
next_order | The order the vehicle should skip to. |
ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY |
Definition at line 532 of file script_order.cpp.
References CMD_SKIP_TO_ORDER, ScriptObject::DoCommand(), EnforcePrecondition, IsValidVehicleOrder(), ResolveOrderPosition(), and ScriptOrderPositionToRealOrderPosition().
bool ScriptOrder::UnshareOrders | ( | VehicleID | vehicle_id | ) | [static] |
Removes the given vehicle from a shared orders list.
vehicle_id | The vehicle to remove from the shared order list. |
Definition at line 653 of file script_order.cpp.
References CMD_CLONE_ORDER, ScriptObject::DoCommand(), EnforcePrecondition, and ScriptVehicle::IsValidVehicle().