Implementation of ScriptOrder. More...
#include "../../stdafx.h"
#include "script_order.hpp"
#include "script_vehicle.hpp"
#include "script_cargo.hpp"
#include "script_map.hpp"
#include "../script_instance.hpp"
#include "../../debug.h"
#include "../../vehicle_base.h"
#include "../../roadstop_base.h"
#include "../../depot_base.h"
#include "../../station_base.h"
#include "../../waypoint_base.h"
Go to the source code of this file.
Functions | |
static OrderType | GetOrderTypeByTile (TileIndex t) |
Gets the order type given a tile. | |
static const Order * | ResolveOrder (VehicleID vehicle_id, ScriptOrder::OrderPosition order_position) |
Get the current order the vehicle is executing. | |
static int | ScriptOrderPositionToRealOrderPosition (VehicleID vehicle_id, ScriptOrder::OrderPosition order_position) |
Convert an ScriptOrder::OrderPosition (which is the manual order index) to an order index as expected by the OpenTTD commands. | |
static void | _DoCommandReturnSetOrderFlags (class ScriptInstance *instance) |
Callback handler as SetOrderFlags possibly needs multiple DoCommand calls to be able to set all order flags correctly. |
Implementation of ScriptOrder.
Definition in file script_order.cpp.
static void _DoCommandReturnSetOrderFlags | ( | class ScriptInstance * | instance | ) | [static] |
Callback handler as SetOrderFlags possibly needs multiple DoCommand calls to be able to set all order flags correctly.
As we need to wait till the command has completed before we know the next bits to change we need to call the function multiple times. Each time it'll reduce the difference between the wanted and the current order.
instance | The AI we are doing the callback for. |
Definition at line 550 of file script_order.cpp.
References ScriptOrder::_SetOrderFlags(), ScriptInstance::DoCommandReturn(), and ScriptObject::SetLastCommandRes().
Referenced by ScriptOrder::_SetOrderFlags().
Gets the order type given a tile.
t | the tile to get the order from |
Definition at line 30 of file script_order.cpp.
References GetRoadTileType(), GetTileType(), IsBuoy(), IsHangar(), IsRailDepot(), IsRailWaypoint(), IsShipDepot(), IsValidTile(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_WATER, and ROAD_TILE_DEPOT.
Referenced by ScriptOrder::AreOrderFlagsValid(), and ScriptOrder::InsertOrder().
static const Order* ResolveOrder | ( | VehicleID | vehicle_id, | |
ScriptOrder::OrderPosition | order_position | |||
) | [static] |
Get the current order the vehicle is executing.
If the current order is in the order list, return the order from the orderlist. If the current order was a manual order, return the current order.
Definition at line 61 of file script_order.cpp.
References Vehicle::current_order, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Order::GetDepotOrderType(), OrderList::GetFirstOrder(), Order::GetType(), Vehicle::list, Order::next, ScriptOrder::ORDER_CURRENT, ScriptOrder::ORDER_INVALID, Vehicle::orders, and ScriptOrder::ResolveOrderPosition().
Referenced by ScriptOrder::_SetOrderFlags(), ScriptOrder::GetOrderCompareFunction(), ScriptOrder::GetOrderCompareValue(), ScriptOrder::GetOrderCondition(), ScriptOrder::GetOrderDestination(), ScriptOrder::GetOrderFlags(), ScriptOrder::GetOrderJumpTo(), ScriptOrder::GetOrderRefit(), ScriptOrder::GetStopLocation(), ScriptOrder::IsGotoDepotOrder(), ScriptOrder::IsGotoStationOrder(), ScriptOrder::IsGotoWaypointOrder(), ScriptOrder::IsRefitOrder(), and ScriptOrder::IsVoidOrder().
static int ScriptOrderPositionToRealOrderPosition | ( | VehicleID | vehicle_id, | |
ScriptOrder::OrderPosition | order_position | |||
) | [static] |
Convert an ScriptOrder::OrderPosition (which is the manual order index) to an order index as expected by the OpenTTD commands.
order_position | The OrderPosition to convert. |
Definition at line 86 of file script_order.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), OrderList::GetFirstOrder(), Vehicle::GetNumManualOrders(), Vehicle::GetNumOrders(), Order::GetType(), ScriptOrder::IsValidVehicleOrder(), Vehicle::list, Order::next, and Vehicle::orders.
Referenced by ScriptOrder::_SetOrderFlags(), ScriptOrder::InsertConditionalOrder(), ScriptOrder::InsertOrder(), ScriptOrder::IsConditionalOrder(), ScriptOrder::MoveOrder(), ScriptOrder::RemoveOrder(), ScriptOrder::SetOrderCompareFunction(), ScriptOrder::SetOrderCompareValue(), ScriptOrder::SetOrderCondition(), ScriptOrder::SetOrderRefit(), ScriptOrder::SetStopLocation(), and ScriptOrder::SkipToOrder().