diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 14ab736dc..2d1f6e68b 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -65,6 +65,10 @@ SaveManager::SaveManager() { AddInitFunction(InitFileImpl); + GameInteractor::Instance->RegisterGameHook([this](uint32_t fileNum) { ThreadPoolWait(); }); + + smThreadPool = std::make_shared(1); + for (SaveFileMetaInfo& info : fileMetaInfo) { info.valid = false; info.deaths = 0; @@ -357,12 +361,14 @@ void SaveManager::SaveRandomizer(SaveContext* saveContext, int sectionID, bool f }); } +// Init() here is an extension of InitSram, and thus not truly an initializer for SaveManager itself. don't put any class initialization stuff here void SaveManager::Init() { + // Wait on saves that snuck through the Wait in OnExitGame + ThreadPoolWait(); const std::filesystem::path sSavePath(LUS::Context::GetPathRelativeToAppDirectory("Save")); const std::filesystem::path sGlobalPath = sSavePath / std::string("global.sav"); auto sOldSavePath = LUS::Context::GetPathRelativeToAppDirectory("oot_save.sav"); auto sOldBackupSavePath = LUS::Context::GetPathRelativeToAppDirectory("oot_save.bak"); - GameInteractor::Instance->RegisterGameHook([this](uint32_t fileNum) { ThreadPoolWait(); }); // If the save directory does not exist, create it if (!std::filesystem::exists(sSavePath)) { @@ -403,7 +409,6 @@ void SaveManager::Init() { } else { CreateDefaultGlobal(); } - smThreadPool = std::make_shared(1); // Load files to initialize metadata for (int fileNum = 0; fileNum < MaxFiles; fileNum++) {