From 676c3f0ff418d4eed27132b302a7b7476812d883 Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Fri, 7 Mar 2025 01:43:37 +0000 Subject: [PATCH] Prevent game from closing whilst autosaving (#967) --- UnleashedRecomp/app.h | 1 + UnleashedRecomp/patches/resident_patches.cpp | 2 ++ UnleashedRecomp/ui/game_window.cpp | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/UnleashedRecomp/app.h b/UnleashedRecomp/app.h index dccb251..9714d10 100644 --- a/UnleashedRecomp/app.h +++ b/UnleashedRecomp/app.h @@ -8,6 +8,7 @@ public: static inline bool s_isInit; static inline bool s_isMissingDLC; static inline bool s_isLoading; + static inline bool s_isSaving; static inline bool s_isWerehog; static inline bool s_isSaveDataCorrupt; diff --git a/UnleashedRecomp/patches/resident_patches.cpp b/UnleashedRecomp/patches/resident_patches.cpp index 791b415..64a220d 100644 --- a/UnleashedRecomp/patches/resident_patches.cpp +++ b/UnleashedRecomp/patches/resident_patches.cpp @@ -97,6 +97,8 @@ PPC_FUNC(sub_824E5170) __imp__sub_824E5170(ctx, base); + App::s_isSaving = pSaveIcon->m_IsVisible; + if (pSaveIcon->m_IsVisible) { App::s_isSaveDataCorrupt = false; diff --git a/UnleashedRecomp/ui/game_window.cpp b/UnleashedRecomp/ui/game_window.cpp index cc25ab6..2bd5ad1 100644 --- a/UnleashedRecomp/ui/game_window.cpp +++ b/UnleashedRecomp/ui/game_window.cpp @@ -34,8 +34,14 @@ int Window_OnSDLEvent(void*, SDL_Event* event) switch (event->type) { case SDL_QUIT: + { + if (App::s_isSaving) + break; + App::Exit(); + break; + } case SDL_KEYDOWN: {