Skip to content

Commit

Permalink
Don't use preloader scene when in headless mode to fix replay tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronVanGeffen committed Apr 25, 2024
1 parent 32efc22 commit e1d0e06
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 23 deletions.
62 changes: 39 additions & 23 deletions src/openrct2/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,31 +504,20 @@ 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.
_preloaderScene->SetCompletionScene(GetTitleScene());
SetActiveScene(_preloaderScene.get());
}
else
{
InitialiseRepositories();
}

#ifdef ENABLE_SCRIPTING
_scriptEngine.Initialise();
Expand All @@ -539,6 +528,33 @@ namespace OpenRCT2
return true;
}

void InitialiseRepositories() final override

Check failure on line 531 in src/openrct2/Context.cpp

View workflow job for this annotation

GitHub Actions / clang-tidy-check

clang-tidy: error

'override' is redundant since the function is already declared 'final' [modernize-use-override,-warnings-as-errors]
{
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);
}

void InitialiseDrawingEngine() final override
{
assert(_drawingEngine == nullptr);
Expand Down
1 change: 1 addition & 0 deletions src/openrct2/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ namespace OpenRCT2
virtual int32_t RunOpenRCT2(int argc, const char** argv) abstract;

virtual bool Initialise() abstract;
virtual void InitialiseRepositories() abstract;
virtual void InitialiseDrawingEngine() abstract;
virtual void DisposeDrawingEngine() abstract;
virtual bool LoadParkFromFile(
Expand Down

0 comments on commit e1d0e06

Please sign in to comment.