From 696c95d612694567bce4d6c278e1bad2e8d1945f Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 10 Aug 2018 12:51:51 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20passing=20=E2=80=94-config=20files=20via?= =?UTF-8?q?=20the=20launcher?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Curt found this, allow using --config from the launcher additional settings box. --- src/Main/options.cxx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 41e563428..2f861b0a2 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -2168,7 +2168,7 @@ void Options::init(int argc, char **argv, const SGPath& appDataPath) void Options::initPaths() { - BOOST_FOREACH(const string& pathOpt, valuesForOption("fg-aircraft")) { + for (const string& pathOpt : valuesForOption("fg-aircraft")) { PathList paths = SGPath::pathsFromLocal8Bit(pathOpt); globals->append_aircraft_paths(paths); } @@ -2367,6 +2367,23 @@ int Options::parseOption(const string& s, bool fromConfigFile) int Options::addOption(const string &key, const string &value) { + if (key == "config") { + // occurs when the launcher adds --config options + SGPath path(value); + if (!path.exists()) { + return FG_OPTIONS_ERROR; + } + + if (path.extension() == "xml") { + p->propertyFiles.push_back(path); + } else { + p->insertGroupMarker(); // begin a group for the config file + readConfig(path); + } + + return FG_OPTIONS_OK; + } + OptionDesc* desc = p->findOption(key); if (!desc) { flightgear::modalMessageBox("Unknown option", "Unknown command-line option: " + key); @@ -2507,7 +2524,7 @@ OptionResult Options::processOptions() groupEnd = groupBegin; } - BOOST_FOREACH(const SGPath& file, p->propertyFiles) { + for (const SGPath& file : p->propertyFiles) { SG_LOG(SG_GENERAL, SG_INFO, "Reading command-line property file " << file); readProperties(file, globals->get_props());