From 90966ecc477bd14661a862e2bd9915f94bbf59dd Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Tue, 27 Feb 2024 01:39:49 +0000 Subject: [PATCH] Handle replace= lines properly in the launcher --- components/config/gamesettings.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index ad7c73d3d9..339acd01fe 100644 --- a/components/config/gamesettings.cpp +++ b/components/config/gamesettings.cpp @@ -98,8 +98,32 @@ bool Config::GameSettings::readUserFile(QTextStream& stream, bool ignoreContent) bool Config::GameSettings::readFile(QTextStream& stream, QMultiMap& settings, bool ignoreContent) { QMultiMap cache; + QRegularExpression replaceRe("^\\s*replace\\s*=\\s*(.+)$"); QRegularExpression keyRe("^([^=]+)\\s*=\\s*(.+)$"); + auto initialPos = stream.pos(); + + while (!stream.atEnd()) + { + QString line = stream.readLine(); + + if (line.isEmpty() || line.startsWith("#")) + continue; + + QRegularExpressionMatch match = keyRe.match(line); + if (match.hasMatch()) + { + QString key = match.captured(1).trimmed(); + // Replace composing entries with a replace= line + if (key == QLatin1String("data") || key == QLatin1String("fallback-archive") + || key == QLatin1String("content") || key == QLatin1String("groundcover") + || key == QLatin1String("script-blacklist")) + settings.remove(key); + } + } + + stream.seek(initialPos); + while (!stream.atEnd()) { QString line = stream.readLine();