Reduce delays with company bankrupcty/sale processing at high day lengths
This commit is contained in:
@@ -737,15 +737,21 @@ 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;
|
||||
|
||||
if (main_tick) {
|
||||
Company *c = Company::GetIfValid(_cur_company_tick_index);
|
||||
if (c != nullptr) {
|
||||
if (c->name_1 != 0) GenerateCompanyName(c);
|
||||
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 && c->bankrupt_timeout == 0) HandleBankruptcyTakeover(c);
|
||||
}
|
||||
|
||||
if (_next_competitor_start == 0) {
|
||||
/* AI::GetStartNextTime() can return 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1660,7 +1660,6 @@ void OnTick_Trees();
|
||||
void OnTick_Station();
|
||||
void OnTick_Industry();
|
||||
|
||||
void OnTick_Companies();
|
||||
void OnTick_LinkGraph();
|
||||
|
||||
void CallLandscapeTick()
|
||||
@@ -1674,6 +1673,5 @@ void CallLandscapeTick()
|
||||
OnTick_Industry();
|
||||
}
|
||||
|
||||
OnTick_Companies();
|
||||
OnTick_LinkGraph();
|
||||
}
|
||||
|
@@ -109,6 +109,7 @@ void MusicLoop();
|
||||
void ResetMusic();
|
||||
void CallWindowGameTickEvent();
|
||||
bool HandleBootstrap();
|
||||
void OnTick_Companies(bool main_tick);
|
||||
|
||||
extern void ShowOSErrorBox(const char *buf, bool system);
|
||||
extern std::string _config_file;
|
||||
@@ -1938,6 +1939,7 @@ void StateGameLoop()
|
||||
if (_tick_skip_counter < _settings_game.economy.day_length_factor) {
|
||||
AnimateAnimatedTiles();
|
||||
CallVehicleTicks();
|
||||
OnTick_Companies(false);
|
||||
} else {
|
||||
_tick_skip_counter = 0;
|
||||
IncreaseDate();
|
||||
@@ -1945,6 +1947,7 @@ void StateGameLoop()
|
||||
RunTileLoop();
|
||||
CallVehicleTicks();
|
||||
CallLandscapeTick();
|
||||
OnTick_Companies(true);
|
||||
}
|
||||
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP);
|
||||
|
||||
|
Reference in New Issue
Block a user