From 6526f9f6cb891036cfbbc0eda0102b46bef845aa Mon Sep 17 00:00:00 2001 From: Ted John Date: Thu, 19 Apr 2018 13:26:19 +0100 Subject: [PATCH] Fix scan-objects CLI action Ensure a context is available when objects are loaded. --- src/openrct2/cmdline/RootCommands.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/openrct2/cmdline/RootCommands.cpp b/src/openrct2/cmdline/RootCommands.cpp index 77d4f6f45c..080350ec54 100644 --- a/src/openrct2/cmdline/RootCommands.cpp +++ b/src/openrct2/cmdline/RootCommands.cpp @@ -15,12 +15,13 @@ #pragma endregion #include +#include #include "../config/Config.h" +#include "../Context.h" #include "../platform/Crash.h" #include "../platform/platform.h" #include "../localisation/Language.h" - #include "../core/Console.hpp" #include "../core/Memory.hpp" #include "../core/Path.hpp" @@ -394,12 +395,14 @@ static exitcode_t HandleCommandScanObjects(CommandLineArgEnumerator * enumerator return result; } - auto env = OpenRCT2::CreatePlatformEnvironment(); + gOpenRCT2Headless = true; // HACK: set gCurrentLanguage otherwise it be wrong for the index file gCurrentLanguage = gConfigGeneral.language; - auto objectRepository = CreateObjectRepository(env); + auto context = std::unique_ptr(OpenRCT2::CreateContext()); + auto env = context->GetPlatformEnvironment(); + auto objectRepository = std::unique_ptr(CreateObjectRepository(env)); objectRepository->Construct(); return EXITCODE_OK; }