Reduce delays with company bankrupcty/sale processing at high day lengths

This commit is contained in:
Jonathan G Rennison
2022-09-02 18:14:35 +01:00
parent 23fa7cd239
commit 3d857333c8
3 changed files with 13 additions and 8 deletions

View File

@@ -737,14 +737,20 @@ static void HandleBankruptcyTakeover(Company *c)
}
/** Called every tick for updating some company info. */
void OnTick_Companies()
void OnTick_Companies(bool main_tick)
{
if (_game_mode == GM_EDITOR) return;
Company *c = Company::GetIfValid(_cur_company_tick_index);
if (c != nullptr) {
if (main_tick) {
Company *c = Company::GetIfValid(_cur_company_tick_index);
if (c != nullptr) {
if (c->bankrupt_asked != 0) HandleBankruptcyTakeover(c);
}
_cur_company_tick_index = (_cur_company_tick_index + 1) % MAX_COMPANIES;
}
for (Company *c : Company::Iterate()) {
if (c->name_1 != 0) GenerateCompanyName(c);
if (c->bankrupt_asked != 0) HandleBankruptcyTakeover(c);
if (c->bankrupt_asked != 0 && c->bankrupt_timeout == 0) HandleBankruptcyTakeover(c);
}
if (_next_competitor_start == 0) {
@@ -762,8 +768,6 @@ void OnTick_Companies()
if (_networking) break;
} while (AI::GetStartNextTime() == 0);
}
_cur_company_tick_index = (_cur_company_tick_index + 1) % MAX_COMPANIES;
}
/**