diff --git a/soh/soh/Enhancements/QoL/Autosave.cpp b/soh/soh/Enhancements/QoL/Autosave.cpp index 8cd5e6f80..fd595007b 100644 --- a/soh/soh/Enhancements/QoL/Autosave.cpp +++ b/soh/soh/Enhancements/QoL/Autosave.cpp @@ -11,7 +11,7 @@ extern PlayState* gPlayState; #include "variables.h" } -static uint64_t lastSaveTimestamp = GetUnixTimestamp(); +static uint64_t lastSaveTimestamp; #define CVAR_AUTOSAVE_NAME CVAR_ENHANCEMENT("Autosave") #define CVAR_AUTOSAVE_DEFAULT AUTOSAVE_OFF @@ -24,13 +24,12 @@ typedef enum { } AutosaveOptions; static bool Autosave_CanSave() { - // Don't save when in title screen or debug file // Don't save a file that doesn't exist (e.g. it was deleted on death by user option) // Don't save the first 60 frames to not save the magic meter when it's still in the animation of filling it. // Don't save in Chamber of Sages and the Cutscene map because of remember save location and cutscene item gives. // Don't save between obtaining Ocarina of Time and Song of Time because the latter would become unobtainable. - if (!SaveManager::Instance->SaveFile_Exist(gSaveContext.fileNum) || !GameInteractor::IsSaveLoaded(false) || + if (!GameInteractor::IsSaveLoaded(false) || !SaveManager::Instance->SaveFile_Exist(gSaveContext.fileNum) || gPlayState->gameplayFrames < 60 || gPlayState->sceneNum == SCENE_CHAMBER_OF_THE_SAGES || gPlayState->sceneNum == SCENE_CUTSCENE_MAP || (!CHECK_QUEST_ITEM(QUEST_SONG_TIME) && (INV_CONTENT(ITEM_OCARINA_TIME) == ITEM_OCARINA_TIME))) { @@ -63,7 +62,6 @@ static void Autosave_IntervalSave() { // rupees draining after buying an item. Since the interval can just retry until it // passes, it can use more conditions without hampering the player experience. if (Autosave_CanSave() && !GameInteractor::IsGameplayPaused()) { - // Reset timestamp, set icon timer to show autosave icon for 5 seconds (100 frames) lastSaveTimestamp = currentTimestamp; @@ -78,6 +76,8 @@ static void Autosave_SoftResetSave() { } static void RegisterAutosave() { + COND_HOOK(GameInteractor::OnLoadGame, CVAR_AUTOSAVE_VALUE, + [](uint32_t fileNme) { lastSaveTimestamp = GetUnixTimestamp(); }); COND_HOOK(GameInteractor::OnGameFrameUpdate, CVAR_AUTOSAVE_VALUE, Autosave_IntervalSave); COND_HOOK(GameInteractor::OnExitGame, CVAR_AUTOSAVE_VALUE, [](int32_t fileNum) { Autosave_SoftResetSave(); }); } diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index ec7d9ee43..89224c0ab 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -1334,9 +1334,7 @@ void SaveManager::ThreadPoolWait() { bool SaveManager::SaveFile_Exist(int fileNum) { try { - bool exists = std::filesystem::exists(GetFileName(fileNum)); - SPDLOG_INFO("File[{}] - {}", fileNum, exists ? "exists" : "does not exist"); - return exists; + return std::filesystem::exists(GetFileName(fileNum)); } catch (std::filesystem::filesystem_error const& ex) { SPDLOG_ERROR("Filesystem error"); return false;