# ai_order.cpp File Reference

Implementation of AIOrder. More...

`#include "ai_vehicle.hpp"`
`#include "../ai_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, AIOrder::OrderPosition order_position)
| Get the current order the vehicle is executing.
static void | _DoCommandReturnSetOrderFlags (class AIInstance *instance)
| Callback handler as SetOrderFlags possibly needs multiple DoCommand calls to be able to set all order flags correctly.

## Detailed Description

Implementation of AIOrder.

Definition in file ai_order.cpp.

## Function Documentation

static void _DoCommandReturnSetOrderFlags | ( | class AIInstance * | 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.

Parameters:

  | instance | The AI we are doing the callback for.

Definition at line 456 of file ai_order.cpp.

References AIOrder::_SetOrderFlags(), AIInstance::DoCommandReturn(), and AIObject::SetLastCommandRes().

Referenced by AIOrder::_SetOrderFlags().

static OrderType GetOrderTypeByTile | ( | TileIndex | t | ) | `[static]`

Gets the order type given a tile.

Parameters:

  | t | the tile to get the order from

Returns:
  the order type, or OT_END when there is no order

Definition at line 26 of file ai_order.cpp.

References GetTileType(), IsBuoy(), IsHangar(), IsRailDepot(), IsRailWaypoint(), IsValidTile(), MP_RAILWAY, MP_ROAD, MP_STATION, and MP_WATER.

Referenced by AIOrder::AreOrderFlagsValid(), and AIOrder::InsertOrder().

static const Order* ResolveOrder | ( | VehicleID | vehicle_id,
|  | AIOrder::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 57 of file ai_order.cpp.

References Vehicle::current_order, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Order::GetDepotOrderType(), Vehicle::GetOrder(), Order::GetType(), ODTFB_PART_OF_ORDERS, AIOrder::ORDER_CURRENT, AIOrder::ORDER_INVALID, and AIOrder::ResolveOrderPosition().

Referenced by AIOrder::GetOrderDestination(), AIOrder::GetOrderFlags(), AIOrder::IsGotoDepotOrder(), AIOrder::IsGotoStationOrder(), and AIOrder::IsGotoWaypointOrder().