Public Types | |
enum | AISettingSource { AISS_DEFAULT, AISS_FORCE_NEWGAME, AISS_FORCE_GAME } |
Public Member Functions | |
AIConfig (const AIConfig *config) | |
void | ChangeAI (const char *name, int version=-1, bool force_exact_match=false, bool is_random=false) |
Set another AI to be loaded in this slot. | |
bool | ResetInfo () |
When ever the AI Scanner is reloaded, all infos become invalid. | |
class AIInfo * | GetInfo () const |
Get the AIInfo linked to this AIConfig. | |
const AIConfigItemList * | GetConfigList () |
Get the config list for this AIConfig. | |
int | GetSetting (const char *name) const |
Get the value of a setting for this config. | |
void | SetSetting (const char *name, int value) |
Set the value of a setting for this config. | |
void | ResetSettings () |
Reset all settings to their default value. | |
void | AddRandomDeviation () |
Randomize all settings the AI requested to be randomized. | |
bool | HasAI () const |
Is this config attached to an AI? | |
bool | IsRandomAI () const |
Is the current AI a randomly chosen AI? | |
const char * | GetName () const |
Get the name of the AI. | |
int | GetVersion () const |
Get the version of the AI. | |
void | StringToSettings (const char *value) |
Convert a string which is stored in the config file or savegames to custom settings of this AI. | |
void | SettingsToString (char *string, size_t size) const |
Convert the custom settings to a string that can be stored in the config file or savegames. | |
Static Public Member Functions | |
static AIConfig * | GetConfig (CompanyID company, AISettingSource source=AISS_DEFAULT) |
Get the config of a company. | |
Private Types | |
typedef std::map< const char *, int, StringCompare > | SettingValueList |
Private Attributes | |
const char * | name |
int | version |
class AIInfo * | info |
SettingValueList | settings |
AIConfigItemList * | config_list |
bool | is_random_ai |
Definition at line 21 of file ai_config.hpp.
AISS_DEFAULT |
Get the AI config from the current game mode. |
AISS_FORCE_NEWGAME |
Get the newgame AI config. |
AISS_FORCE_GAME |
Get the AI config from the current game. |
Definition at line 66 of file ai_config.hpp.
void AIConfig::ChangeAI | ( | const char * | name, | |
int | version = -1 , |
|||
bool | force_exact_match = false , |
|||
bool | is_random = false | |||
) |
Set another AI to be loaded in this slot.
name | The name of the AI. | |
version | The version of the AI to load, or -1 of latest. | |
force_exact_match | If true try to find the exact same version as specified. If false any compatible version is ok. | |
is_random | Is the AI chosen randomly? |
Definition at line 19 of file ai_config.cpp.
References AddRandomDeviation(), AICONFIG_RANDOM, AIInfo::GetConfigList(), GetSetting(), ScriptFileInfo::GetVersion(), and SetSetting().
Referenced by AI::ResetConfig(), and AI::StartNew().
int AIConfig::GetSetting | ( | const char * | name | ) | const |
Get the value of a setting for this config.
It might fallback to his 'info' to find the default value (if not set or if not-custom difficulty level).
Definition at line 108 of file ai_config.cpp.
References _settings_game, _settings_newgame, DifficultySettings::diff_level, GameSettings::difficulty, and AIInfo::GetSettingDefaultValue().
Referenced by ChangeAI(), AISettingsWindow::DrawWidget(), AIController::GetSetting(), AI::GetStartNextTime(), and AISettingsWindow::OnClick().
bool AIConfig::ResetInfo | ( | ) |
When ever the AI Scanner is reloaded, all infos become invalid.
This function tells AIConfig about this.
Definition at line 80 of file ai_config.cpp.
Referenced by AI::ResetConfig().