From 2bc4db34a1eb3797602480d4511a09d984bdb362 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Tue, 12 Jan 2021 13:29:32 +1100 Subject: [PATCH] launcher: fix config not saving when new ini file needs to be created for it (regression created when switching to simpleini) --- source-code/source/plugins/Launcher/IniReader.h | 9 +++++++++ source-code/source/plugins/Launcher/ui.h | 2 -- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source-code/source/plugins/Launcher/IniReader.h b/source-code/source/plugins/Launcher/IniReader.h index 01ebc40..8fa2401 100644 --- a/source-code/source/plugins/Launcher/IniReader.h +++ b/source-code/source/plugins/Launcher/IniReader.h @@ -19,6 +19,15 @@ bool LoadIni(const wchar_t* filename, bool use_utf8=false) if (ini_reader.LoadFile(filename) != 0) { + // if the path doesn't exist, this isn't an error so we can still save filename and return true + // (writing config will create the file) + DWORD dwAttrib = GetFileAttributesW(filename); + if (dwAttrib == INVALID_FILE_ATTRIBUTES) + { + loaded_ini_file = filename; + return true; + } + loaded_ini_file = L""; return false; } diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index 8c21bb0..e273df7 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -37,14 +37,12 @@ namespace Launcher { if (!IsLineInFile("[components]", COMPONENTS_FILE)) { PrependFile("[components]\n", COMPONENTS_FILE); - *ComponentsConfigChanged = true; } // if playerdata.ini has no section name, add one if (!IsLineInFile("[playerdata]", PLAYERDATA_FILE)) { PrependFile("[playerdata]\n", PLAYERDATA_FILE); - *PlayerdataConfigChanged = true; } // if keyconfig.ini has no section name, add one