Change: replace per-AI "start_date" with a global "competitors_interval" (#10653)

The per-AI "start_date" is a lot of custom code, and was rarely
used in the way it was meant.

While at it, also ported this part over to the new timer system.
This commit is contained in:
Patric Stout
2023-04-16 20:14:22 +02:00
committed by GitHub
parent 43a7e54067
commit ed83c4b0da
26 changed files with 370 additions and 348 deletions

View File

@@ -26,7 +26,6 @@ void ScriptConfig::Change(const char *name, int version, bool force_exact_match,
this->is_random = is_random;
if (this->config_list != nullptr) delete this->config_list;
this->config_list = (info == nullptr) ? nullptr : new ScriptConfigItemList();
if (this->config_list != nullptr) this->PushExtraConfigList();
this->to_load_data.reset();
this->ClearConfigList();
@@ -79,7 +78,6 @@ const ScriptConfigItemList *ScriptConfig::GetConfigList()
if (this->info != nullptr) return this->info->GetConfigList();
if (this->config_list == nullptr) {
this->config_list = new ScriptConfigItemList();
this->PushExtraConfigList();
}
return this->config_list;
}

View File

@@ -51,8 +51,6 @@ struct ScriptConfigItem {
typedef std::list<ScriptConfigItem> ScriptConfigItemList; ///< List of ScriptConfig items.
extern ScriptConfigItem _start_date_config;
/**
* Script settings.
*/
@@ -127,12 +125,12 @@ public:
* @return The (default) value of the setting, or -1 if the setting was not
* found.
*/
virtual int GetSetting(const char *name) const;
int GetSetting(const char *name) const;
/**
* Set the value of a setting for this config.
*/
virtual void SetSetting(const char *name, int value);
void SetSetting(const char *name, int value);
/**
* Reset all settings to their default value.
@@ -147,7 +145,7 @@ public:
/**
* Randomize all settings the Script requested to be randomized.
*/
virtual void AddRandomDeviation();
void AddRandomDeviation();
/**
* Is this config attached to an Script? In other words, is there a Script
@@ -202,16 +200,10 @@ protected:
bool is_random; ///< True if the AI in this slot was randomly chosen.
std::unique_ptr<ScriptInstance::ScriptData> to_load_data; ///< Data to load after the Script start.
/**
* In case you have mandatory non-Script-definable config entries in your
* list, add them to this function.
*/
virtual void PushExtraConfigList() {};
/**
* Routine that clears the config list.
*/
virtual void ClearConfigList();
void ClearConfigList();
/**
* This function should call back to the Scanner in charge of this Config,

View File

@@ -379,14 +379,8 @@ struct ScriptSettingsWindow : public Window {
TextColour colour;
uint idx = 0;
if (StrEmpty(config_item.description)) {
if (this->slot != OWNER_DEITY && !strcmp(config_item.name, "start_date")) {
/* Build-in translation */
str = STR_AI_SETTINGS_START_DELAY;
colour = TC_LIGHT_BLUE;
} else {
str = STR_JUST_STRING;
colour = TC_ORANGE;
}
str = STR_JUST_STRING;
colour = TC_ORANGE;
} else {
str = STR_AI_SETTINGS_SETTING;
colour = TC_LIGHT_BLUE;