summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorSamu <dj_samu@hotmail.com>2019-01-31 14:35:13 +0000
committerPeterN <peter@fuzzle.org>2019-02-02 16:37:11 +0000
commit011257dc8804175dd7d1e839e97e796c0a88aee6 (patch)
tree97f0da59d87fda8935d741722b76ea64819160a8 /src/ai
parentfa53abe864a6939dc4dac8a6c61443e486e0eb04 (diff)
downloadopenttd-011257dc8804175dd7d1e839e97e796c0a88aee6.tar.xz
Change: Allow AI companies to start immediately.
Allow multiple AIs to possibly start in the same tick. start_date = 0 becomes a special case, where random deviation does not occur. If start_date was not already 0, then a minimum value of 1 must apply.
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/ai.hpp2
-rw-r--r--src/ai/ai_config.cpp11
-rw-r--r--src/ai/ai_config.hpp1
3 files changed, 13 insertions, 1 deletions
diff --git a/src/ai/ai.hpp b/src/ai/ai.hpp
index 065367d03..1b5b6c07d 100644
--- a/src/ai/ai.hpp
+++ b/src/ai/ai.hpp
@@ -32,7 +32,7 @@ public:
START_NEXT_EASY = DAYS_IN_YEAR * 2,
START_NEXT_MEDIUM = DAYS_IN_YEAR,
START_NEXT_HARD = DAYS_IN_YEAR / 2,
- START_NEXT_MIN = 1,
+ START_NEXT_MIN = 0,
START_NEXT_MAX = 3600,
START_NEXT_DEVIATION = 60,
};
diff --git a/src/ai/ai_config.cpp b/src/ai/ai_config.cpp
index f920d3101..20e913c2e 100644
--- a/src/ai/ai_config.cpp
+++ b/src/ai/ai_config.cpp
@@ -118,3 +118,14 @@ void AIConfig::SetSetting(const char *name, int value)
ScriptConfig::SetSetting(name, value);
}
+
+void AIConfig::AddRandomDeviation()
+{
+ int start_date = this->GetSetting("start_date");
+
+ ScriptConfig::AddRandomDeviation();
+
+ /* start_date = 0 is a special case, where random deviation does not occur.
+ * If start_date was not already 0, then a minimum value of 1 must apply. */
+ this->SetSetting("start_date", start_date != 0 ? max(1, this->GetSetting("start_date")) : 0);
+}
diff --git a/src/ai/ai_config.hpp b/src/ai/ai_config.hpp
index b02935902..600ae1af9 100644
--- a/src/ai/ai_config.hpp
+++ b/src/ai/ai_config.hpp
@@ -34,6 +34,7 @@ public:
/* virtual */ int GetSetting(const char *name) const;
/* virtual */ void SetSetting(const char *name, int value);
+ /* virtual */ void AddRandomDeviation();
/**
* When ever the AI Scanner is reloaded, all infos become invalid. This