# ai_instance.cpp File Reference

Implementation of AIInstance. More...

`#include "../stdafx.h"`
`#include "../debug.h"`
`#include "../saveload/saveload.h"`
`#include "../gui.h"`
`#include "../script/squirrel_class.hpp"`
`#include "ai_config.hpp"`
`#include "ai_storage.hpp"`
`#include "ai_instance.hpp"`
`#include "ai_gui.hpp"`
`#include "api/ai_accounting.hpp.sq"`
`#include "api/ai_airport.hpp.sq"`
`#include "api/ai_base.hpp.sq"`
`#include "api/ai_basestation.hpp.sq"`
`#include "api/ai_bridge.hpp.sq"`
`#include "api/ai_bridgelist.hpp.sq"`
`#include "api/ai_cargo.hpp.sq"`
`#include "api/ai_cargolist.hpp.sq"`
`#include "api/ai_company.hpp.sq"`
`#include "api/ai_controller.hpp.sq"`
`#include "api/ai_date.hpp.sq"`
`#include "api/ai_depotlist.hpp.sq"`
`#include "api/ai_engine.hpp.sq"`
`#include "api/ai_enginelist.hpp.sq"`
`#include "api/ai_error.hpp.sq"`
`#include "api/ai_event.hpp.sq"`
`#include "api/ai_event_types.hpp.sq"`
`#include "api/ai_execmode.hpp.sq"`
`#include "api/ai_gamesettings.hpp.sq"`
`#include "api/ai_group.hpp.sq"`
`#include "api/ai_grouplist.hpp.sq"`
`#include "api/ai_industry.hpp.sq"`
`#include "api/ai_industrylist.hpp.sq"`
`#include "api/ai_industrytype.hpp.sq"`
`#include "api/ai_industrytypelist.hpp.sq"`
`#include "api/ai_list.hpp.sq"`
`#include "api/ai_log.hpp.sq"`
`#include "api/ai_map.hpp.sq"`
`#include "api/ai_marine.hpp.sq"`
`#include "api/ai_order.hpp.sq"`
`#include "api/ai_rail.hpp.sq"`
`#include "api/ai_railtypelist.hpp.sq"`
`#include "api/ai_road.hpp.sq"`
`#include "api/ai_sign.hpp.sq"`
`#include "api/ai_signlist.hpp.sq"`
`#include "api/ai_station.hpp.sq"`
`#include "api/ai_stationlist.hpp.sq"`
`#include "api/ai_subsidy.hpp.sq"`
`#include "api/ai_subsidylist.hpp.sq"`
`#include "api/ai_testmode.hpp.sq"`
`#include "api/ai_tile.hpp.sq"`
`#include "api/ai_tilelist.hpp.sq"`
`#include "api/ai_town.hpp.sq"`
`#include "api/ai_townlist.hpp.sq"`
`#include "api/ai_tunnel.hpp.sq"`
`#include "api/ai_vehicle.hpp.sq"`
`#include "api/ai_vehiclelist.hpp.sq"`
`#include "api/ai_waypoint.hpp.sq"`
`#include "api/ai_waypointlist.hpp.sq"`
`#include "../company_base.h"`
`#include "../company_func.h"`
`#include "../fileio_func.h"`

Go to the source code of this file.

## Enumerations
enum | SQSaveLoadType { SQSL_INT = 0x00, SQSL_STRING = 0x01, SQSL_ARRAY = 0x02, SQSL_TABLE = 0x03, SQSL_BOOL = 0x04, SQSL_NULL = 0x05, SQSL_ARRAY_TABLE_END = 0xFF }
| The type of the data that follows in the savegame. More...
## Functions
static void | PrintFunc (bool error_msg, const SQChar *message)
| Callback called by squirrel when an AI uses "print" and for error messages.
## Variables
static const int | MAX_SL_OPS = 100000
| The maximum number of operations for saving or loading the data of an AI.
static const int | MAX_CONSTRUCTOR_OPS = 100000
| The maximum number of operations for initial start of an AI.
static byte | _ai_sl_byte
| Used as source/target by the AI saveload code to store/load a single byte.
static const SaveLoad | _ai_byte []
| SaveLoad array that saves/loads exactly one byte.
static const uint | AISAVE_MAX_DEPTH = 25
| The maximum recursive depth for items stored in the savegame.

## Detailed Description

Implementation of AIInstance.

Definition in file ai_instance.cpp.

## Enumeration Type Documentation

enum SQSaveLoadType

The type of the data that follows in the savegame.

Enumerator:

  SQSL_INT | The following data is an integer.
  SQSL_STRING | The following data is an string.
  SQSL_ARRAY | The following data is an array.
  SQSL_TABLE | The following data is an table.
  SQSL_BOOL | The following data is a boolean.
  SQSL_NULL | A null variable.
  SQSL_ARRAY_TABLE_END | Marks the end of an array or table, no data follows.

Definition at line 453 of file ai_instance.cpp.

## Function Documentation

static void PrintFunc | ( | bool | error_msg,
|  | const SQChar * | message |
| ) |  |  | `[static]`

Callback called by squirrel when an AI uses "print" and for error messages.

Parameters:

  | error_msg | Is this an error message?
  | message | The actual message text.

Definition at line 97 of file ai_instance.cpp.

References AIController::Print().

## Variable Documentation

const SaveLoad _ai_byte[]`[static]`

Initial value:

     {
      SLEG_VAR(_ai_sl_byte, SLE_UINT8),

    }

SaveLoad array that saves/loads exactly one byte.

Definition at line 466 of file ai_instance.cpp.

const int MAX_CONSTRUCTOR_OPS = 100000`[static]`

The maximum number of operations for initial start of an AI.

Definition at line 83 of file ai_instance.cpp.

Referenced by AIInstance::GameLoop().

const int MAX_SL_OPS = 100000`[static]`

The maximum number of operations for saving or loading the data of an AI.

Definition at line 81 of file ai_instance.cpp.

Referenced by AIInstance::CallLoad(), and AIInstance::Save().