# AIObject Class Reference

Uper-parent object of all API classes. More...

`#include <ai_object.hpp>`

Inheritance diagram for AIObject:

## Static Public Member Functions
static void | SetLastCommandRes (bool res)
| Store the latest result of a DoCommand per company.
static void | SetNewVehicleID (VehicleID vehicle_id)
| Store a new_vehicle_id per company.
static void | SetNewSignID (SignID sign_id)
| Store a new_sign_id per company.
static void | SetNewTunnelEndtile (TileIndex tile)
| Store a new_tunnel_endtile per company.
static void | SetNewGroupID (GroupID group_id)
| Store a new_group_id per company.
static void | SetAllowDoCommand (bool allow)
| Store a allow_do_command per company.
static void *& | GetLogPointer ()
| Get the pointer to store log message in.
## Static Protected Member Functions
static bool | DoCommand (TileIndex tile, uint32 p1, uint32 p2, uint cmd, const char *text=NULL, AISuspendCallbackProc *callback=NULL)
| Executes a raw DoCommand for the AI.
static void | SetDoCommandCosts (Money value)
| Sets the DoCommand costs counter to a value.
static void | IncreaseDoCommandCosts (Money value)
| Increase the current value of the DoCommand costs counter.
static Money | GetDoCommandCosts ()
| Get the current DoCommand costs counter.
static void | SetLastError (AIErrorType last_error)
| Set the DoCommand last error.
static AIErrorType | GetLastError ()
| Get the DoCommand last error.
static void | SetRoadType (RoadType road_type)
| Set the road type.
static RoadType | GetRoadType ()
| Get the road type.
static void | SetRailType (RailType rail_type)
| Set the rail type.
static RailType | GetRailType ()
| Get the rail type.
static void | SetDoCommandMode (AIModeProc *proc, AIObject *instance)
| Set the current mode of your AI to this proc.
static AIModeProc * | GetDoCommandMode ()
| Get the current mode your AI is currently under.
static AIObject * | GetDoCommandModeInstance ()
| Get the instance of the current mode your AI is currently under.
static void | SetDoCommandDelay (uint ticks)
| Set the delay of the DoCommand.
static uint | GetDoCommandDelay ()
| Get the delay of the DoCommand.
static bool | GetLastCommandRes ()
| Get the latest result of a DoCommand.
static VehicleID | GetNewVehicleID ()
| Get the latest stored new_vehicle_id.
static SignID | GetNewSignID ()
| Get the latest stored new_sign_id.
static TileIndex | GetNewTunnelEndtile ()
| Get the latest stored new_tunnel_endtile.
static GroupID | GetNewGroupID ()
| Get the latest stored new_group_id.
static bool | GetAllowDoCommand ()
| Get the latest stored allow_do_command.
static void *& | GetEventPointer ()
| Get the pointer to store event data in.
static void | SetLastCost (Money last_cost)
| Set the cost of the last command.
static Money | GetLastCost ()
| Get the cost of the last command.
static void | SetCallbackVariable (int index, int value)
| Set a variable that can be used by callback functions to pass information.
static int | GetCallbackVariable (int index)
| Get the variable that is used by callback functions to pass information.
## Friends
class | AIInstance
void | CcAI (bool success, TileIndex tile, uint32 p1, uint32 p2)

## Detailed Description

Uper-parent object of all API classes.

You should never use this class in your AI, as it doesn't publish any public functions. It is used internally to have a common place to handle general things, like internal command processing, and command-validation checks.

Definition at line 31 of file ai_object.hpp.

## Member Function Documentation

bool AIObject::GetAllowDoCommand | ( |  | ) | `[static, protected]`

Get the latest stored allow_do_command.

If this is false, you are not allowed to do any DoCommands.

Definition at line 163 of file ai_object.cpp.

References AIStorage::allow_do_command.

Referenced by DoCommand(), AIController::Sleep(), and AIAbstractList::Valuate().

void AIObject::SetLastCommandRes | ( | bool | res | ) | `[static]`

Store the latest result of a DoCommand per company.

Note:
  NEVER use this yourself in your AI!

Parameters:

  | res | The result of the last command.

Definition at line 103 of file ai_object.cpp.

References AIStorage::last_command_res, SetNewGroupID(), SetNewSignID(), SetNewTunnelEndtile(), and SetNewVehicleID().

Referenced by _DoCommandReturnSetOrderFlags(), and DoCommand().

void AIObject::SetNewVehicleID | ( | VehicleID | vehicle_id | ) | `[static]`

Store a new_vehicle_id per company.

Note:
  NEVER use this yourself in your AI!

Parameters:

  | vehicle_id | The new VehicleID.

Definition at line 118 of file ai_object.cpp.

References AIStorage::new_vehicle_id.

Referenced by SetLastCommandRes().

void AIObject::SetNewSignID | ( | SignID | sign_id | ) | `[static]`

Store a new_sign_id per company.

Note:
  NEVER use this yourself in your AI!

Parameters:

  | sign_id | The new SignID.

Definition at line 128 of file ai_object.cpp.

References AIStorage::new_sign_id.

Referenced by SetLastCommandRes().

void AIObject::SetNewTunnelEndtile | ( | TileIndex | tile | ) | `[static]`

Store a new_tunnel_endtile per company.

Note:
  NEVER use this yourself in your AI!

Parameters:

  | tile | The new TileIndex.

Definition at line 138 of file ai_object.cpp.

References AIStorage::new_tunnel_endtile.

Referenced by SetLastCommandRes().

void AIObject::SetNewGroupID | ( | GroupID | group_id | ) | `[static]`

Store a new_group_id per company.

Note:
  NEVER use this yourself in your AI!

Parameters:

  | group_id | The new GroupID.

Definition at line 148 of file ai_object.cpp.

References AIStorage::new_group_id.

Referenced by SetLastCommandRes().

void AIObject::SetAllowDoCommand | ( | bool | allow | ) | `[static]`

Store a allow_do_command per company.

Note:
  NEVER use this yourself in your AI!

Parameters:

  | allow | The new allow.

Definition at line 158 of file ai_object.cpp.

References AIStorage::allow_do_command.

Referenced by AIAbstractList::Valuate().

void *& AIObject::GetLogPointer | ( |  | ) | `[static]`

Get the pointer to store log message in.

Note:
  NEVER use this yourself in your AI!

Definition at line 174 of file ai_object.cpp.

References AIStorage::log_data.

Referenced by AILog::FreeLogPointer(), and AILog::Log().

The documentation for this class was generated from the following files:

- src/ai/api/ai_object.hpp
- src/ai/api/ai_object.cpp