Update to 1.9.0-RC2

--HG--
branch : openttd
This commit is contained in:
Pavel Stupnikov
2019-03-26 14:17:10 +03:00
parent 301de29d29
commit fa72fd57a1
60 changed files with 985 additions and 651 deletions

View File

@@ -595,10 +595,10 @@ void StartupCompanies()
}
/** Start a new competitor company if possible. */
static bool MaybeStartNewCompany()
static void MaybeStartNewCompany()
{
#ifdef ENABLE_NETWORK
if (_networking && Company::GetNumItems() >= _settings_client.network.max_companies) return false;
if (_networking && Company::GetNumItems() >= _settings_client.network.max_companies) return;
#endif /* ENABLE_NETWORK */
Company *c;
@@ -612,10 +612,8 @@ static bool MaybeStartNewCompany()
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 */
return DoCommandP(0, CCA_NEW_AI | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL);
DoCommandP(0, CCA_NEW_AI | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL);
}
return false;
}
/** Initialize the pool of companies. */
@@ -716,19 +714,11 @@ void OnTick_Companies()
}
if (_next_competitor_start == 0) {
/* AI::GetStartNextTime() can return 0. */
_next_competitor_start = max(1, AI::GetStartNextTime() * DAY_TICKS);
_next_competitor_start = AI::GetStartNextTime() * DAY_TICKS;
}
if (_game_mode != GM_MENU && AI::CanStartNew() && --_next_competitor_start == 0) {
/* Allow multiple AIs to possibly start in the same tick. */
do {
if (!MaybeStartNewCompany()) break;
/* In networking mode, we can only send a command to start but it
* didn't execute yet, so we cannot loop. */
if (_networking) break;
} while (AI::GetStartNextTime() == 0);
if (AI::CanStartNew() && _game_mode != GM_MENU && --_next_competitor_start == 0) {
MaybeStartNewCompany();
}
_cur_company_tick_index = (_cur_company_tick_index + 1) % MAX_COMPANIES;