Update to 14.0-beta1
This commit is contained in:
+20
-32
@@ -48,6 +48,7 @@
|
||||
/* Load default data and store the name in the settings */
|
||||
config->Change(info->GetName(), -1, false, true);
|
||||
}
|
||||
if (rerandomise_ai) config->AddRandomDeviation();
|
||||
config->AnchorUnchangeableSettings();
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
@@ -62,7 +63,7 @@
|
||||
|
||||
cur_company.Restore();
|
||||
|
||||
InvalidateWindowData(WC_AI_DEBUG, 0, -1);
|
||||
InvalidateWindowClassesData(WC_SCRIPT_DEBUG, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,18 +83,16 @@
|
||||
PerformanceMeasurer framerate((PerformanceElement)(PFE_AI0 + c->index));
|
||||
cur_company.Change(c->index);
|
||||
c->ai_instance->GameLoop();
|
||||
/* Occasionally collect garbage; every 255 ticks do one company.
|
||||
* Effectively collecting garbage once every two months per AI. */
|
||||
if ((AI::frame_counter & 255) == 0 && (CompanyID)GB(AI::frame_counter, 8, 4) == c->index) {
|
||||
c->ai_instance->CollectGarbage();
|
||||
}
|
||||
} else {
|
||||
PerformanceMeasurer::SetInactive((PerformanceElement)(PFE_AI0 + c->index));
|
||||
}
|
||||
}
|
||||
cur_company.Restore();
|
||||
|
||||
/* Occasionally collect garbage; every 255 ticks do one company.
|
||||
* Effectively collecting garbage once every two months per AI. */
|
||||
if ((AI::frame_counter & 255) == 0) {
|
||||
CompanyID cid = (CompanyID)GB(AI::frame_counter, 8, 4);
|
||||
if (Company::IsValidAiID(cid)) Company::Get(cid)->ai_instance->CollectGarbage();
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ uint AI::GetTick()
|
||||
@@ -115,8 +114,8 @@
|
||||
|
||||
cur_company.Restore();
|
||||
|
||||
InvalidateWindowData(WC_AI_DEBUG, 0, -1);
|
||||
CloseWindowById(WC_AI_SETTINGS, company);
|
||||
InvalidateWindowClassesData(WC_SCRIPT_DEBUG, -1);
|
||||
CloseWindowById(WC_SCRIPT_SETTINGS, company);
|
||||
}
|
||||
|
||||
/* static */ void AI::Pause(CompanyID company)
|
||||
@@ -210,7 +209,7 @@
|
||||
if (_settings_game.ai_config[c] != nullptr && _settings_game.ai_config[c]->HasScript()) {
|
||||
if (!_settings_game.ai_config[c]->ResetInfo(true)) {
|
||||
Debug(script, 0, "After a reload, the AI by the name '{}' was no longer found, and removed from the list.", _settings_game.ai_config[c]->GetName());
|
||||
_settings_game.ai_config[c]->Change(nullptr);
|
||||
_settings_game.ai_config[c]->Change(std::nullopt);
|
||||
if (Company::IsValidAiID(c)) {
|
||||
/* The code belonging to an already running AI was deleted. We can only do
|
||||
* one thing here to keep everything sane and that is kill the AI. After
|
||||
@@ -227,7 +226,7 @@
|
||||
if (_settings_newgame.ai_config[c] != nullptr && _settings_newgame.ai_config[c]->HasScript()) {
|
||||
if (!_settings_newgame.ai_config[c]->ResetInfo(false)) {
|
||||
Debug(script, 0, "After a reload, the AI by the name '{}' was no longer found, and removed from the list.", _settings_newgame.ai_config[c]->GetName());
|
||||
_settings_newgame.ai_config[c]->Change(nullptr);
|
||||
_settings_newgame.ai_config[c]->Change(std::nullopt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,25 +290,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ int AI::GetStartNextTime()
|
||||
/* static */ void AI::GetConsoleList(std::back_insert_iterator<std::string> &output_iterator, bool newest_only)
|
||||
{
|
||||
/* Find the first company which doesn't exist yet */
|
||||
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
||||
if (!Company::IsValidID(c)) return AIConfig::GetConfig(c, AIConfig::SSS_FORCE_GAME)->GetSetting("start_date");
|
||||
}
|
||||
|
||||
/* Currently no AI can be started, check again in a year. */
|
||||
return DAYS_IN_YEAR;
|
||||
AI::scanner_info->GetConsoleList(output_iterator, newest_only);
|
||||
}
|
||||
|
||||
/* static */ std::string AI::GetConsoleList(bool newest_only)
|
||||
/* static */ void AI::GetConsoleLibraryList(std::back_insert_iterator<std::string> &output_iterator)
|
||||
{
|
||||
return AI::scanner_info->GetConsoleList(newest_only);
|
||||
}
|
||||
|
||||
/* static */ std::string AI::GetConsoleLibraryList()
|
||||
{
|
||||
return AI::scanner_library->GetConsoleList(true);
|
||||
AI::scanner_library->GetConsoleList(output_iterator, true);
|
||||
}
|
||||
|
||||
/* static */ const ScriptInfoList *AI::GetInfoList()
|
||||
@@ -322,12 +310,12 @@
|
||||
return AI::scanner_info->GetUniqueInfoList();
|
||||
}
|
||||
|
||||
/* static */ AIInfo *AI::FindInfo(const char *name, int version, bool force_exact_match)
|
||||
/* static */ AIInfo *AI::FindInfo(const std::string &name, int version, bool force_exact_match)
|
||||
{
|
||||
return AI::scanner_info->FindInfo(name, version, force_exact_match);
|
||||
}
|
||||
|
||||
/* static */ AILibrary *AI::FindLibrary(const char *library, int version)
|
||||
/* static */ AILibrary *AI::FindLibrary(const std::string &library, int version)
|
||||
{
|
||||
return AI::scanner_library->FindLibrary(library, version);
|
||||
}
|
||||
@@ -340,9 +328,9 @@
|
||||
AI::scanner_library->RescanDir();
|
||||
ResetConfig();
|
||||
|
||||
InvalidateWindowData(WC_AI_LIST, 0, 1);
|
||||
SetWindowClassesDirty(WC_AI_DEBUG);
|
||||
InvalidateWindowClassesData(WC_AI_SETTINGS);
|
||||
InvalidateWindowData(WC_SCRIPT_LIST, 0, 1);
|
||||
SetWindowClassesDirty(WC_SCRIPT_DEBUG);
|
||||
InvalidateWindowClassesData(WC_SCRIPT_SETTINGS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user