Initialize OTRGlobals' Context early to prevent non-portable crash during asset archive lookup. (#5605)

This commit is contained in:
Malkierian 2025-06-22 16:32:37 -07:00 committed by GitHub
parent cf0ea3033e
commit e0ebc115ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View file

@ -261,6 +261,10 @@ const char* constCameraStrings[] = {
};
OTRGlobals::OTRGlobals() {
context = Ship::Context::CreateUninitializedInstance("Ship of Harkinian", appShortName, "shipofharkinian.json");
}
void OTRGlobals::Initialize() {
std::vector<std::string> OTRFiles;
std::string mqPath = Ship::Context::LocateFileAcrossAppDirs("oot-mq.otr", appShortName);
if (std::filesystem::exists(mqPath)) {
@ -300,8 +304,6 @@ OTRGlobals::OTRGlobals() {
OOT_NTSC_JP_GC, OOT_NTSC_US_GC, OOT_PAL_GC, OOT_PAL_GC_DBG1, OOT_PAL_GC_DBG2,
};
context = Ship::Context::CreateUninitializedInstance("Ship of Harkinian", appShortName, "shipofharkinian.json");
context->InitLogging();
context->InitGfxDebugger();
context->InitConfiguration();
@ -1100,7 +1102,7 @@ void CheckAndCreateModFolder() {
}
extern "C" void InitOTR() {
OTRGlobals::Instance = new OTRGlobals();
#ifdef __SWITCH__
Ship::Switch::Init(Ship::PreInitPhase);
#elif defined(__WIIU__)
@ -1207,7 +1209,7 @@ extern "C" void InitOTR() {
DetectOTRVersion("oot.otr", false);
DetectOTRVersion("oot-mq.otr", true);
OTRGlobals::Instance = new OTRGlobals();
OTRGlobals::Instance->Initialize();
CustomMessageManager::Instance = new CustomMessageManager();
ItemTableManager::Instance = new ItemTableManager();
GameInteractor::Instance = new GameInteractor();

View file

@ -71,7 +71,7 @@ class OTRGlobals {
~OTRGlobals();
void ScaleImGui();
void Initialize();
bool HasMasterQuest();
bool HasOriginal();
uint32_t GetInterpolationFPS();