summaryrefslogtreecommitdiff
path: root/src/company_cmd.cpp
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2009-01-13 16:53:03 +0000
committertruebrain <truebrain@openttd.org>2009-01-13 16:53:03 +0000
commit890074a03ee0c6b10aff40e4b64de7437c06f368 (patch)
treea7e2f1687e36828d0479f321da377f4a273f568c /src/company_cmd.cpp
parent0a357c0ac10601b6172610dbd46498ff44b978c1 (diff)
downloadopenttd-890074a03ee0c6b10aff40e4b64de7437c06f368.tar.xz
(svn r15063) -Fix [NoAI]: starting companies now listen correctly to 'start_date' set to the AI slot (Yexo)
-Add [NoAI]: add a 'deviation' value for all settings, giving a slight deviation of the value of a setting (Yexo)
Diffstat (limited to 'src/company_cmd.cpp')
-rw-r--r--src/company_cmd.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index be18fb279..6526de585 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -468,8 +468,7 @@ Company *DoStartupNewCompany(bool is_ai)
void StartupCompanies()
{
- /* The AI starts like in the setting with +2 month max */
- _next_competitor_start = _settings_game.difficulty.competitor_start_time * 90 * DAY_TICKS + RandomRange(60 * DAY_TICKS) + 1;
+ _next_competitor_start = 0;
}
static void MaybeStartNewCompany()
@@ -483,12 +482,7 @@ static void MaybeStartNewCompany()
if (c->is_ai) n++;
}
- /* when there's a lot of computers in game, the probability that a new one starts is lower */
- if (n < (uint)_settings_game.difficulty.max_no_competitors &&
- n < (_network_server ?
- InteractiveRandomRange(_settings_game.difficulty.max_no_competitors + 2) :
- RandomRange(_settings_game.difficulty.max_no_competitors + 2)
- )) {
+ if (n < (uint)_settings_game.difficulty.max_no_competitors) {
/* Send a command to all clients to start up a new AI.
* Works fine for Multiplayer and Singleplayer */
DoCommandP(0, 1, 0, CMD_COMPANY_CTRL);
@@ -511,10 +505,14 @@ void OnTick_Companies()
if (IsValidCompanyID((CompanyID)_cur_company_tick_index)) {
Company *c = GetCompany((CompanyID)_cur_company_tick_index);
if (c->name_1 != 0) GenerateCompanyName(c);
+ }
- if (AI::CanStartNew() && _game_mode != GM_MENU && !--_next_competitor_start) {
- MaybeStartNewCompany();
- }
+ if (_next_competitor_start == 0) {
+ _next_competitor_start = AI::GetStartNextTime() * 30 * DAY_TICKS;
+ }
+
+ if (AI::CanStartNew() && _game_mode != GM_MENU && --_next_competitor_start == 0) {
+ MaybeStartNewCompany();
}
_cur_company_tick_index = (_cur_company_tick_index + 1) % MAX_COMPANIES;