From 43f58f04f335bb29d44ac5c1dde94bf7dda2223a Mon Sep 17 00:00:00 2001 From: AllMeatball <181806857+AllMeatball@users.noreply.github.com> Date: Mon, 12 May 2025 15:29:05 -0500 Subject: [PATCH] isleapp: Use boolean return in LoadConfig This to check if the config loaded correctly or not. Seems to be a good solution to the file loading issue. Maybe there's a better solution SetupWindow failing because of a config erroring seems a bit odd. --- ISLE/isleapp.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 3879f8bf..ed815352 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -447,7 +447,10 @@ MxU8 IsleApp::MapMouseButtonFlagsToModifier(SDL_MouseButtonFlags p_flags) // FUNCTION: ISLE 0x4023e0 MxResult IsleApp::SetupWindow() { - LoadConfig(); + if (!LoadConfig()) { + return FAILURE; + } + SetupVideoFlags( m_fullScreen, m_flipSurfaces, @@ -522,7 +525,7 @@ MxResult IsleApp::SetupWindow() } // FUNCTION: ISLE 0x4028d0 -void IsleApp::LoadConfig() +bool IsleApp::LoadConfig() { char* prefPath = SDL_GetPrefPath("isledecomp", "isle"); char* iniConfig; @@ -549,9 +552,11 @@ void IsleApp::LoadConfig() SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Loading sane defaults"); FILE* iniFP = fopen(iniConfig, "wb"); - if (!iniFP) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to write config at '%s': %s", iniConfig, strerror(errno)); + if (iniFP) { fclose(iniFP); + } else { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to write config at '%s': %s", iniConfig, strerror(errno)); + return false; } dict = iniparser_load(iniConfig); @@ -639,6 +644,8 @@ void IsleApp::LoadConfig() iniparser_freedict(dict); delete[] iniConfig; SDL_free(prefPath); + + return true; } // FUNCTION: ISLE 0x402c20