# AIGameSettings Class Reference

Class that handles all game settings related functions. More...

`#include <ai_gamesettings.hpp>`

Inheritance diagram for AIGameSettings:

## Static Public Member Functions
static const char * | GetClassName ()
static bool | IsValid (const char *setting)
| Is the given game setting a valid setting for this instance of OpenTTD?
static int32 | GetValue (const char *setting)
| Gets the value of the game setting.
static bool | IsDisabledVehicleType (AIVehicle::VehicleType vehicle_type)
| Checks whether the given vehicle-type is disabled for AIs.

## Detailed Description

Class that handles all game settings related functions.

Note:
  AIGameSettings::IsValid and AIGameSettings::GetValue are functions that rely on the settings as OpenTTD stores them in savegame and openttd.cfg. No guarantees can be given on the long term validity, consistency and stability of the names, values and value ranges. Using these settings can be dangerous and could cause issues in future versions. To make sure that a setting still exists in the current version you have to run AIGameSettings::IsValid before accessing it.
  The names of the setting for AIGameSettings::IsValid and AIGameSettings::GetValue are the same ones as those that are shown by the list_settings command in the in-game console. Settings that are string based are NOT supported and AIGAmeSettings::IsValid will return false for them. These settings will not be supported either because they have no relevance for the AI (default client names, server IPs, etc.).

Definition at line 38 of file ai_gamesettings.hpp.

## Member Function Documentation

int32 AIGameSettings::GetValue | ( | const char * | setting | ) | `[static]`

Gets the value of the game setting.

Parameters:

  | setting | The setting to get the value of.

Precondition:
  IsValid(setting).

Warning:
  Results of this function are not governed by the API. This means that the value of settings may be out of the expected range. It also means that a setting that previously existed can be gone or has changed it's name/characteristics.

Note:
  Results achieved in the past offer no gurantee for the future.

Returns:
  The value for the setting.

Definition at line 23 of file ai_gamesettings.cpp.

References _settings_game, SettingDescBase::cmd, SaveLoad::conv, SettingDesc::desc, GetSettingFromName(), GetVariableAddress(), IsValid(), ReadValue(), SettingDesc::save, and SDT_BOOLX.

bool AIGameSettings::IsDisabledVehicleType | ( | AIVehicle::VehicleType | vehicle_type | ) | `[static]`

Checks whether the given vehicle-type is disabled for AIs.

Parameters:

  | vehicle_type | The vehicle-type to check.

Returns:
  True if the vehicle-type is disabled.

Definition at line 36 of file ai_gamesettings.cpp.

References _settings_game, GameSettings::ai, AISettings::ai_disable_veh_aircraft, AISettings::ai_disable_veh_roadveh, AISettings::ai_disable_veh_ship, AISettings::ai_disable_veh_train, AIVehicle::VT_AIR, AIVehicle::VT_RAIL, AIVehicle::VT_ROAD, and AIVehicle::VT_WATER.

Referenced by AIVehicle::BuildVehicle().

bool AIGameSettings::IsValid | ( | const char * | setting | ) | `[static]`

Is the given game setting a valid setting for this instance of OpenTTD?

Parameters:

  | setting | The setting to check for existence.

Warning:
  Results of this function are not governed by the API. This means that a setting that previously existed can be gone or has changed it's name.

Note:
  Results achieved in the past offer no gurantee for the future.

Returns:
  True if and only if the setting is valid.

Definition at line 16 of file ai_gamesettings.cpp.

References SettingDescBase::cmd, SettingDesc::desc, GetSettingFromName(), and SDT_STRING.

Referenced by GetValue().

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

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