diff options
author | PeterN <peter@fuzzle.org> | 2019-02-11 18:59:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-11 18:59:55 +0000 |
commit | aa737715ddef17f448e4121199bd10c0e70fcaaa (patch) | |
tree | 6f32c119f56f42c5afe41047ae7c7915eb18c687 /src/ai | |
parent | 75d3054ae41251741620c2759a1bf3501570b481 (diff) | |
download | openttd-aa737715ddef17f448e4121199bd10c0e70fcaaa.tar.xz |
Fix #7151: AI start date deviation was still applied when not set to a random AI. (#7223)
Diffstat (limited to 'src/ai')
-rw-r--r-- | src/ai/ai_config.cpp | 9 | ||||
-rw-r--r-- | src/ai/ai_config.hpp | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/ai/ai_config.cpp b/src/ai/ai_config.cpp index 20e913c2e..a78281478 100644 --- a/src/ai/ai_config.cpp +++ b/src/ai/ai_config.cpp @@ -35,6 +35,15 @@ ScriptConfigItem _start_date_config = { false }; +AIConfig::AIConfig(const AIConfig *config) : ScriptConfig(config) +{ + /* Override start_date as per AIConfig::AddRandomDeviation(). + * This is necessary because the ScriptConfig constructor will instead call + * ScriptConfig::AddRandomDeviation(). */ + int start_date = config->GetSetting("start_date"); + this->SetSetting("start_date", start_date != 0 ? max(1, this->GetSetting("start_date")) : 0); +} + /* static */ AIConfig *AIConfig::GetConfig(CompanyID company, ScriptSettingSource source) { AIConfig **config; diff --git a/src/ai/ai_config.hpp b/src/ai/ai_config.hpp index 600ae1af9..30c6f84bb 100644 --- a/src/ai/ai_config.hpp +++ b/src/ai/ai_config.hpp @@ -26,9 +26,7 @@ public: ScriptConfig() {} - AIConfig(const AIConfig *config) : - ScriptConfig(config) - {} + AIConfig(const AIConfig *config); class AIInfo *GetInfo() const; |