OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
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 ? std::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");
137 this->
SetSetting(
"start_date", start_date != 0 ? std::max(1, this->
GetSetting(
"start_date")) : 0);
class AIConfig * ai_config[MAX_COMPANIES]
settings per company
ScriptConfigItem _start_date_config
Configuration for AI start date, every AI has this setting.
@ SP_HARD
Hard difficulty.
static class AIInfo * FindInfo(const char *name, int version, bool force_exact_match)
Wrapper function for AIScanner::FindInfo.
Owner
Enum for all companies/owners.
void AddRandomDeviation() override
Randomize all settings the Script requested to be randomized.
void ClearConfigList() override
Routine that clears the config list.
int version
Version of the script.
@ SP_MEDIUM
Medium difficulty.
static GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
void PushExtraConfigList() override
In case you have mandatory non-Script-definable config entries in your list, add them to this functio...
virtual void AddRandomDeviation()
Randomize all settings the Script requested to be randomized.
@ SSS_DEFAULT
Get the Script config from the current game mode.
class ScriptInfo * GetInfo() const
Get the ScriptInfo linked to this ScriptConfig.
@ SCRIPTCONFIG_NONE
No flags set.
static AIConfig * GetConfig(CompanyID company, ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
@ SP_CUSTOM
No profile, special "custom" highscore.
virtual void SetSetting(const char *name, int value)
Set the value of a setting for this config.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
int version
Version of the Script.
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...
ScriptConfigItemList * config_list
List with all settings defined by this Script.
@ SP_EASY
Easy difficulty.
class ScriptInfo * info
ScriptInfo object for related to this Script version.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
virtual int GetSetting(const char *name) const
Get the value of a setting for this config.
void SetSetting(const char *name, int value) override
Set the value of a setting for this config.
@ SSS_FORCE_NEWGAME
Get the newgame Script config.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
All static information from an AI like name, version, etc.
const char * name
Name of the Script.
virtual void ClearConfigList()
Routine that clears the config list.
const char * name
Full name of the script.
All static information from an Script like name, version, etc.
Info about a single Script setting.
int GetSetting(const char *name) const override
Get the value of a setting for this config.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
bool ResetInfo(bool force_exact_match)
When ever the AI Scanner is reloaded, all infos become invalid.
SettingValueList settings
List with all setting=>value pairs that are configure for this Script.
ScriptSettingSource
Where to get the config from, either default (depends on current game mode) or force either newgame o...