10 #include "../stdafx.h" 11 #include "../settings_type.h" 12 #include "../string_func.h" 17 #include "../safeguards.h" 25 AI::START_NEXT_MEDIUM,
27 AI::START_NEXT_MEDIUM,
29 AI::START_NEXT_DEVIATION,
41 int start_date = config->
GetSetting(
"start_date");
42 this->SetSetting(
"start_date", start_date != 0 ?
max(1, this->GetSetting(
"start_date")) : 0);
53 if (*config ==
nullptr) *config =
new AIConfig();
57 class AIInfo *AIConfig::GetInfo()
const 70 return this->
info !=
nullptr;
82 int start_date = this->
GetSetting(
"start_date");
91 if (this->
info ==
nullptr) {
92 SettingValueList::const_iterator it = this->
settings.find(name);
94 assert(strcmp(
"start_date", name) == 0);
96 case SP_EASY:
return AI::START_NEXT_EASY;
97 case SP_MEDIUM:
return AI::START_NEXT_MEDIUM;
98 case SP_HARD:
return AI::START_NEXT_HARD;
99 case SP_CUSTOM:
return AI::START_NEXT_MEDIUM;
100 default: NOT_REACHED();
112 if (this->
info ==
nullptr) {
113 if (strcmp(
"start_date", name) != 0)
return;
114 value =
Clamp(value, AI::START_NEXT_MIN, AI::START_NEXT_MAX);
116 SettingValueList::iterator it = this->
settings.find(name);
118 (*it).second = value;
131 int start_date = this->
GetSetting(
"start_date");
Owner
Enum for all companies/owners.
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.
virtual void AddRandomDeviation()
Randomize all settings the Script requested to be randomized.
static T max(const T a, const T b)
Returns the maximum of two values.
static class AIInfo * FindInfo(const char *name, int version, bool force_exact_match)
Wrapper function for AIScanner::FindInfo.
void PushExtraConfigList() override
In case you have mandatory non-Script-definable config entries in your list, add them to this functio...
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.
All static information from an Script like name, version, etc.
void SetSetting(const char *name, int value) override
Set the value of a setting for this config.
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.
void ClearConfigList() override
Routine that clears the config list.
int GetSetting(const char *name) const override
Get the value of a setting for this config.
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.
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.
AIInfo keeps track of all information of an AI, like Author, Description, ...
ScriptInfo * FindInfo(const char *name, int version, bool force_exact_match) override
This function should call back to the Scanner in charge of this Config, to find the ScriptInfo belong...
void AddRandomDeviation() override
Randomize all settings the Script requested to be randomized.