12 #include "../stdafx.h" 13 #include "../settings_type.h" 14 #include "../string_func.h" 19 #include "../safeguards.h" 27 AI::START_NEXT_MEDIUM,
29 AI::START_NEXT_MEDIUM,
31 AI::START_NEXT_DEVIATION,
46 if (*config == NULL) *config =
new AIConfig();
50 class AIInfo *AIConfig::GetInfo()
const 63 return this->
info != NULL;
75 int start_date = this->
GetSetting(
"start_date");
84 if (this->
info == NULL) {
85 SettingValueList::const_iterator it = this->
settings.find(name);
87 assert(strcmp(
"start_date", name) == 0);
89 case SP_EASY:
return AI::START_NEXT_EASY;
90 case SP_MEDIUM:
return AI::START_NEXT_MEDIUM;
91 case SP_HARD:
return AI::START_NEXT_HARD;
92 case SP_CUSTOM:
return AI::START_NEXT_MEDIUM;
93 default: NOT_REACHED();
105 if (this->
info == NULL) {
106 if (strcmp(
"start_date", name) != 0)
return;
107 value =
Clamp(value, AI::START_NEXT_MIN, AI::START_NEXT_MAX);
109 SettingValueList::iterator it = this->
settings.find(name);
111 (*it).second = value;
GameSettings _settings_game
Game settings of a running game or the scenario editor.
No profile, special "custom" highscore.
SettingValueList settings
List with all setting=>value pairs that are configure for this Script.
ScriptConfigItem _start_date_config
Configuration for AI start date, every AI has this setting.
static class AIInfo * FindInfo(const char *name, int version, bool force_exact_match)
Wrapper function for AIScanner::FindInfo.
ScriptConfigItemList * config_list
List with all settings defined by this Script.
Get the Script config from the current game mode.
bool ResetInfo(bool force_exact_match)
When ever the AI Scanner is reloaded, all infos become invalid.
virtual void ClearConfigList()
Routine that clears the config list.
class ScriptInfo * GetInfo() const
Get the ScriptInfo linked to this ScriptConfig.
void ClearConfigList()
Routine that clears the config list.
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.
All static information from an Script like name, version, etc.
ScriptSettingSource
Where to get the config from, either default (depends on current game mode) or force either newgame o...
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
static AIConfig * GetConfig(CompanyID company, ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
ScriptInfo * FindInfo(const char *name, int version, bool force_exact_match)
This function should call back to the Scanner in charge of this Config, to find the ScriptInfo belong...
virtual void SetSetting(const char *name, int value)
Set the value of a setting for this config.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
All static information from an AI like name, version, etc.
Info about a single Script setting.
int version
Version of the Script.
void PushExtraConfigList()
In case you have mandatory non-Script-definable config entries in your list, add them to this functio...
static GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
Get the newgame Script config.
class ScriptInfo * info
ScriptInfo object for related to this Script version.
class AIConfig * ai_config[MAX_COMPANIES]
settings per company
virtual int GetSetting(const char *name) const
Get the value of a setting for this config.
Base functions for all AIs.
const char * name
Name of the Script.
AIConfig stores the configuration settings of every AI.
Owner
Enum for all companies/owners.
AIInfo keeps track of all information of an AI, like Author, Description, ...