mirror of https://github.com/OpenRCT2/OpenRCT2.git
Don't use preloader scene when in headless mode to fix replay tests
This splits off the initialisation calls to a new InitialiseRepositories function. The SetCompletionScene invocation is moved to the Launch method. When the game is running in headless mode, the preloader is not used. Instead, InitialiseRepositories is called in-thread, and the transition to the 'completion scene' happens immediately after.
This commit is contained in:
parent
fe7152fc72
commit
3cda6e367b
|
@ -504,31 +504,19 @@ namespace OpenRCT2
|
|||
|
||||
ContextInit();
|
||||
|
||||
_preloaderScene->AddJob([&]() {
|
||||
auto currentLanguage = _localisationService->GetCurrentLanguage();
|
||||
|
||||
_preloaderScene->UpdateCaption(STR_CHECKING_OBJECT_FILES);
|
||||
_objectRepository->LoadOrConstruct(currentLanguage);
|
||||
|
||||
if (!gOpenRCT2Headless)
|
||||
{
|
||||
_preloaderScene->UpdateCaption(STR_CHECKING_ASSET_PACKS);
|
||||
_assetPackManager->Scan();
|
||||
_assetPackManager->LoadEnabledAssetPacks();
|
||||
_assetPackManager->Reload();
|
||||
}
|
||||
|
||||
_preloaderScene->UpdateCaption(STR_CHECKING_TRACK_DESIGN_FILES);
|
||||
_trackDesignRepository->Scan(currentLanguage);
|
||||
|
||||
_preloaderScene->UpdateCaption(STR_CHECKING_SCENARIO_FILES);
|
||||
_scenarioRepository->Scan(currentLanguage);
|
||||
});
|
||||
|
||||
TitleSequenceManager::Scan();
|
||||
|
||||
_preloaderScene->SetCompletionScene(GetTitleScene());
|
||||
SetActiveScene(_preloaderScene.get());
|
||||
if (!gOpenRCT2Headless)
|
||||
{
|
||||
_preloaderScene->AddJob([this]() { InitialiseRepositories(); });
|
||||
|
||||
// TODO: preload the title scene in another (parallel) job.
|
||||
SetActiveScene(_preloaderScene.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
InitialiseRepositories();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
_scriptEngine.Initialise();
|
||||
|
@ -539,6 +527,37 @@ namespace OpenRCT2
|
|||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
void InitialiseRepositories()
|
||||
{
|
||||
if (!_initialised)
|
||||
{
|
||||
throw std::runtime_error("Context needs to be initialised first.");
|
||||
}
|
||||
|
||||
auto currentLanguage = _localisationService->GetCurrentLanguage();
|
||||
|
||||
_preloaderScene->UpdateCaption(STR_CHECKING_OBJECT_FILES);
|
||||
_objectRepository->LoadOrConstruct(currentLanguage);
|
||||
|
||||
if (!gOpenRCT2Headless)
|
||||
{
|
||||
_preloaderScene->UpdateCaption(STR_CHECKING_ASSET_PACKS);
|
||||
_assetPackManager->Scan();
|
||||
_assetPackManager->LoadEnabledAssetPacks();
|
||||
_assetPackManager->Reload();
|
||||
}
|
||||
|
||||
_preloaderScene->UpdateCaption(STR_CHECKING_TRACK_DESIGN_FILES);
|
||||
_trackDesignRepository->Scan(currentLanguage);
|
||||
|
||||
_preloaderScene->UpdateCaption(STR_CHECKING_SCENARIO_FILES);
|
||||
_scenarioRepository->Scan(currentLanguage);
|
||||
|
||||
_preloaderScene->UpdateCaption(STR_LOADING_GENERIC);
|
||||
}
|
||||
|
||||
public:
|
||||
void InitialiseDrawingEngine() final override
|
||||
{
|
||||
assert(_drawingEngine == nullptr);
|
||||
|
@ -1020,7 +1039,14 @@ namespace OpenRCT2
|
|||
}
|
||||
|
||||
auto* scene = DetermineStartUpScene();
|
||||
SetActiveScene(scene);
|
||||
if (!gOpenRCT2Headless)
|
||||
{
|
||||
_preloaderScene->SetCompletionScene(scene);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetActiveScene(scene);
|
||||
}
|
||||
|
||||
if (scene == GetGameScene())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue