diff --git a/src/core/kernel/init/CxbxKrnl.cpp b/src/core/kernel/init/CxbxKrnl.cpp index e8a163fd2..b35a4a645 100644 --- a/src/core/kernel/init/CxbxKrnl.cpp +++ b/src/core/kernel/init/CxbxKrnl.cpp @@ -872,6 +872,22 @@ void ImportLibraries(XbeImportEntry *pImportDirectory) } } +bool CreateSettings() +{ + g_Settings = new Settings(); + if (g_Settings == nullptr) { + MessageBox(nullptr, szSettings_alloc_error, "Cxbx-Reloaded", MB_OK); + return false; + } + + if (!g_Settings->Init()) { + return false; + } + + log_get_settings(); + return true; +} + bool HandleFirstLaunch() { bool bFirstLaunch; @@ -879,18 +895,10 @@ bool HandleFirstLaunch() /* check if process is launch with elevated access then prompt for continue on or not. */ if (!bFirstLaunch) { - g_Settings = new Settings(); - if (g_Settings == nullptr) { - MessageBox(nullptr, szSettings_alloc_error, "Cxbx-Reloaded", MB_OK); + if (!CreateSettings()) { return false; } - if (!g_Settings->Init()) { - return false; - } - - log_get_settings(); - bool bElevated = CxbxIsElevated(); if (bElevated && !g_Settings->m_core.allowAdminPrivilege) { int ret = MessageBox(NULL, "Cxbx-Reloaded has detected that it has been launched with Administrator rights.\n" diff --git a/src/core/kernel/init/CxbxKrnl.h b/src/core/kernel/init/CxbxKrnl.h index 5ab55cc5c..1d29a90aa 100644 --- a/src/core/kernel/init/CxbxKrnl.h +++ b/src/core/kernel/init/CxbxKrnl.h @@ -224,6 +224,8 @@ bool CxbxKrnlVerifyVersion(const char *szVersion); extern bool g_bIsDebugKernel; +bool CreateSettings(); + bool HandleFirstLaunch(); /*! Cxbx Kernel Entry Point */ diff --git a/src/gui/WinMain.cpp b/src/gui/WinMain.cpp index 0c56949e7..31035f6a1 100644 --- a/src/gui/WinMain.cpp +++ b/src/gui/WinMain.cpp @@ -99,19 +99,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine // If 2nd GUI executable is launched, load settings file for GUI for editable support. if (g_Settings == nullptr) { - g_Settings = new Settings(); - if (g_Settings == nullptr) { - MessageBox(nullptr, szSettings_alloc_error, "Cxbx-Reloaded", MB_OK); + if (!CreateSettings()) { EmuShared::Cleanup(); return EXIT_FAILURE; } - - if (!g_Settings->Init()) { - EmuShared::Cleanup(); - return EXIT_FAILURE; - } - - log_get_settings(); } // Possible optional output for GUI