mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-08 15:30:00 +00:00
This commit is contained in:
parent
760a194d31
commit
a979d9cdda
@ -617,14 +617,6 @@ void StartupCompanies()
|
||||
{
|
||||
/* Ensure the timeout is aborted, so it doesn't fire based on information of the last game. */
|
||||
_new_competitor_timeout.Abort();
|
||||
|
||||
/* If there is no delay till the start of the next competitor, start all competitors at the start of the game. */
|
||||
if (_settings_game.difficulty.competitors_interval == 0 && _game_mode != GM_MENU && AI::CanStartNew()) {
|
||||
for (auto i = 0; i < _settings_game.difficulty.max_no_competitors; i++) {
|
||||
if (_networking && Company::GetNumItems() >= _settings_client.network.max_companies) break;
|
||||
Command<CMD_COMPANY_CTRL>::Post(CCA_NEW_AI, INVALID_COMPANY, CRR_NONE, INVALID_CLIENT_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Initialize the pool of companies. */
|
||||
@ -726,9 +718,14 @@ void OnTick_Companies()
|
||||
|
||||
if (_new_competitor_timeout.HasFired() && _game_mode != GM_MENU && AI::CanStartNew()) {
|
||||
int32_t timeout = _settings_game.difficulty.competitors_interval * 60 * TICKS_PER_SECOND;
|
||||
/* If the interval is zero, check every ~10 minutes if a company went bankrupt and needs replacing. */
|
||||
if (timeout == 0) timeout = 10 * 60 * TICKS_PER_SECOND;
|
||||
|
||||
/* If the interval is zero, start as many competitors as needed then check every ~10 minutes if a company went bankrupt and needs replacing. */
|
||||
if (timeout == 0) {
|
||||
for (auto i = 0; i < _settings_game.difficulty.max_no_competitors; i++) {
|
||||
if (_networking && Company::GetNumItems() >= _settings_client.network.max_companies) break;
|
||||
Command<CMD_COMPANY_CTRL>::Post(CCA_NEW_AI, INVALID_COMPANY, CRR_NONE, INVALID_CLIENT_ID);
|
||||
}
|
||||
timeout = 10 * 60 * TICKS_PER_SECOND;
|
||||
}
|
||||
/* Randomize a bit when the AI is actually going to start; ranges from 87.5% .. 112.5% of indicated value. */
|
||||
timeout += ScriptObject::GetRandomizer(OWNER_NONE).Next(timeout / 4) - timeout / 8;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user