From 806635b96c98fa9ad0d1d07f25ecc6f9b211afb7 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Fri, 10 Jan 2025 00:46:58 +0000 Subject: [PATCH 1/2] Don't unnecessarily overwrite openmw.cfg We don't need to risk reformatting the user's potentially-handwritten file if it parses to the same thing as we're about to write. --- components/config/gamesettings.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index a5e71326b25..f318cec4a44 100644 --- a/components/config/gamesettings.cpp +++ b/components/config/gamesettings.cpp @@ -301,6 +301,25 @@ bool Config::GameSettings::writeFileWithComments(QFile& file) if (fileCopy.empty()) return writeFile(stream); + QMultiMap existingSettings; + QString context = QFileInfo(file).absoluteDir().path(); + if (readFile(stream, existingSettings, context)) + { + // don't use QMultiMap operator== as mUserSettings may have blank context fields + // don't use one std::equal with custom predicate as (until Qt 6.4) there was no key-value iterator + if (std::equal(existingSettings.keyBegin(), existingSettings.keyEnd(), mUserSettings.keyBegin(), + mUserSettings.keyEnd()) + && std::equal(existingSettings.cbegin(), existingSettings.cend(), mUserSettings.cbegin(), + [](const SettingValue& l, const SettingValue& r) { + return l.originalRepresentation == r.originalRepresentation; + })) + { + // The existing file already contains what we need, don't risk scrambling comments and formatting + return true; + } + } + stream.seek(0); + // start // | // | +----------------------------------------------------------+ From 085c3b03a9d445bfcd65d23b943361b7c00aacd8 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Sat, 11 Jan 2025 17:24:35 +0000 Subject: [PATCH 2/2] c h a n g e l o g --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 511b2d5dbda..7e38f7381b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -311,6 +311,7 @@ Feature #8109: Expose commitCrime to Lua API Feature #8130: Launcher: Add the ability to open a selected data directory in the file browser Feature #8145: Starter spell flag is not exposed + Feature #8286: Launcher: Preserve semantically identical openmw.cfg Feature #8287: Launcher: Special handling for comma in openmw.cfg entries is unintuitive and should be removed Task #5859: User openmw-cs.cfg has comment talking about settings.cfg Task #5896: Do not use deprecated MyGUI properties