From 6c311f4a3d9a0c6bdc88371563962f4d2ea08a14 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Thu, 22 Oct 2020 21:38:22 +0100 Subject: [PATCH 01/10] Partially revert 3a912485 While it solved the bug it was supposed to, it caused a regression where the user config could no longer override the global config. --- components/files/configurationmanager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index 0ba2d15193..c74c399224 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -59,6 +59,10 @@ void ConfigurationManager::readConfiguration(boost::program_options::variables_m bool silent = mSilent; mSilent = quiet; + // User config has the highest priority. + loadConfig(mFixedPath.getUserConfigPath(), variables, description); + boost::program_options::notify(variables); + // read either local or global config depending on type of installation bool loaded = loadConfig(mFixedPath.getLocalPath(), variables, description); boost::program_options::notify(variables); @@ -68,10 +72,6 @@ void ConfigurationManager::readConfiguration(boost::program_options::variables_m boost::program_options::notify(variables); } - // User config has the highest priority. - loadConfig(mFixedPath.getUserConfigPath(), variables, description); - boost::program_options::notify(variables); - mSilent = silent; } From 651a5a27f6ca11fb34003bccaa2f6781d46a9e81 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Thu, 22 Oct 2020 21:44:47 +0100 Subject: [PATCH 02/10] Fix inconsistent indentation This has been irritating me for years. --- apps/openmw/main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index a39dd2e398..4e18ad95f5 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -63,16 +63,16 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("data", bpo::value()->default_value(Files::EscapePathContainer(), "data") ->multitoken()->composing(), "set data directories (later directories have higher priority)") - ("data-local", bpo::value()->default_value(""), + ("data-local", bpo::value()->default_value(""), "set local data directory (highest priority)") ("fallback-archive", bpo::value()->default_value(Files::EscapeStringVector(), "fallback-archive") ->multitoken(), "set fallback BSA archives (later archives have higher priority)") - ("resources", bpo::value()->default_value("resources"), + ("resources", bpo::value()->default_value("resources"), "set resources directory") - ("start", bpo::value()->default_value(""), + ("start", bpo::value()->default_value(""), "set initial cell") ("content", bpo::value()->default_value(Files::EscapeStringVector(), "") @@ -90,7 +90,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("script-console", bpo::value()->implicit_value(true) ->default_value(false), "enable console-only script functionality") - ("script-run", bpo::value()->default_value(""), + ("script-run", bpo::value()->default_value(""), "select a file containing a list of console commands that is executed on startup") ("script-warn", bpo::value()->implicit_value (1) @@ -106,7 +106,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("script-blacklist-use", bpo::value()->implicit_value(true) ->default_value(true), "enable script blacklisting") - ("load-savegame", bpo::value()->default_value(""), + ("load-savegame", bpo::value()->default_value(""), "load a save game file on game startup (specify an absolute filename or a filename relative to the current working directory)") ("skip-menu", bpo::value()->implicit_value(true) @@ -118,14 +118,14 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("fs-strict", bpo::value()->implicit_value(true) ->default_value(false), "strict file system handling (no case folding)") - ("encoding", bpo::value()-> + ("encoding", bpo::value()-> default_value("win1252"), "Character encoding used in OpenMW game messages:\n" "\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n" "\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n" "\n\twin1252 - Western European (Latin) alphabet, used by default") - ("fallback", bpo::value()->default_value(FallbackMap(), "") + ("fallback", bpo::value()->default_value(FallbackMap(), "") ->multitoken()->composing(), "fallback values") ("no-grab", bpo::value()->implicit_value(true)->default_value(false), "Don't grab mouse cursor") From cf81f1bbb72b511ac785822bc125a9543d457e01 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Fri, 23 Oct 2020 01:41:28 +0100 Subject: [PATCH 03/10] Make composing variables compose in the expected order --- apps/openmw/main.cpp | 2 + components/files/configurationmanager.cpp | 63 ++++++++++++++++++++++- components/files/configurationmanager.hpp | 4 ++ 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 4e18ad95f5..0c46903c91 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -164,7 +164,9 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat return false; } + bpo::variables_map composingVariables = cfgMgr.separateComposingVariables(variables, desc); cfgMgr.readConfiguration(variables, desc); + cfgMgr.mergeComposingVariables(variables, composingVariables, desc); Version::Version v = Version::getOpenmwVersion(variables["resources"].as().toStdString()); std::cout << v.describe() << std::endl; diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index c74c399224..42639d3e5d 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -2,6 +2,7 @@ #include #include +#include #include /** @@ -58,23 +59,83 @@ void ConfigurationManager::readConfiguration(boost::program_options::variables_m { bool silent = mSilent; mSilent = quiet; - + // User config has the highest priority. + auto composingVariables = separateComposingVariables(variables, description); + Log(Debug::Info) << composingVariables.size() << " composing variables were loaded before the user config"; loadConfig(mFixedPath.getUserConfigPath(), variables, description); + mergeComposingVariables(variables, composingVariables, description); boost::program_options::notify(variables); // read either local or global config depending on type of installation + composingVariables = separateComposingVariables(variables, description); + Log(Debug::Info) << composingVariables.size() << " composing variables were loaded before the local config"; bool loaded = loadConfig(mFixedPath.getLocalPath(), variables, description); + mergeComposingVariables(variables, composingVariables, description); boost::program_options::notify(variables); if (!loaded) { + composingVariables = separateComposingVariables(variables, description); + Log(Debug::Info) << composingVariables.size() << " composing variables were loaded before the global config"; loadConfig(mFixedPath.getGlobalConfigPath(), variables, description); + mergeComposingVariables(variables, composingVariables, description); boost::program_options::notify(variables); } mSilent = silent; } +boost::program_options::variables_map ConfigurationManager::separateComposingVariables(boost::program_options::variables_map & variables, boost::program_options::options_description& description) +{ + boost::program_options::variables_map composingVariables; + for (auto itr = variables.begin(); itr != variables.end();) + { + if (description.find((*itr).first, false).semantic()->is_composing()) + { + composingVariables.emplace(*itr); + itr = variables.erase(itr); + } + else + ++itr; + } + return composingVariables; +} + +void ConfigurationManager::mergeComposingVariables(boost::program_options::variables_map & first, boost::program_options::variables_map & second, boost::program_options::options_description& description) +{ + for (auto& [name, variableValue] : first) + { + if (description.find(name, false).semantic()->is_composing()) + { + if (second[name].defaulted() || second[name].empty()) + continue; + + boost::any& firstValue = variableValue.value(); + const boost::any& secondValue = second[name].value(); + + if (firstValue.type() == typeid(Files::EscapePathContainer)) + { + auto& firstPathContainer = boost::any_cast(firstValue); + const auto& secondPathContainer = boost::any_cast(secondValue); + + firstPathContainer.insert(firstPathContainer.end(), secondPathContainer.begin(), secondPathContainer.end()); + } + else if (firstValue.type() == typeid(Fallback::FallbackMap)) + { + auto& firstMap = boost::any_cast(firstValue); + const auto& secondMap = boost::any_cast(secondValue); + + std::map tempMap(secondMap.mMap); + tempMap.merge(firstMap.mMap); + firstMap.mMap.swap(tempMap); + } + else + Log(Debug::Error) << "Unexpected composing variable type. Curse boost and their blasted arcane templates."; + } + } + +} + void ConfigurationManager::processPaths(Files::PathContainer& dataDirs, bool create) { std::string path; diff --git a/components/files/configurationmanager.hpp b/components/files/configurationmanager.hpp index 446abd4dc5..0ec0a1f67d 100644 --- a/components/files/configurationmanager.hpp +++ b/components/files/configurationmanager.hpp @@ -25,6 +25,10 @@ struct ConfigurationManager void readConfiguration(boost::program_options::variables_map& variables, boost::program_options::options_description& description, bool quiet=false); + boost::program_options::variables_map separateComposingVariables(boost::program_options::variables_map& variables, boost::program_options::options_description& description); + + void mergeComposingVariables(boost::program_options::variables_map& first, boost::program_options::variables_map& second, boost::program_options::options_description& description); + void processPaths(Files::PathContainer& dataDirs, bool create = false); ///< \param create Try creating the directory, if it does not exist. From fca8634b74d19cb8faf6c20df3e5b4a2461cb239 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Fri, 23 Oct 2020 01:46:49 +0100 Subject: [PATCH 04/10] Remove debugging lines --- components/files/configurationmanager.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index 42639d3e5d..c50c7713e6 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -62,21 +62,18 @@ void ConfigurationManager::readConfiguration(boost::program_options::variables_m // User config has the highest priority. auto composingVariables = separateComposingVariables(variables, description); - Log(Debug::Info) << composingVariables.size() << " composing variables were loaded before the user config"; loadConfig(mFixedPath.getUserConfigPath(), variables, description); mergeComposingVariables(variables, composingVariables, description); boost::program_options::notify(variables); // read either local or global config depending on type of installation composingVariables = separateComposingVariables(variables, description); - Log(Debug::Info) << composingVariables.size() << " composing variables were loaded before the local config"; bool loaded = loadConfig(mFixedPath.getLocalPath(), variables, description); mergeComposingVariables(variables, composingVariables, description); boost::program_options::notify(variables); if (!loaded) { composingVariables = separateComposingVariables(variables, description); - Log(Debug::Info) << composingVariables.size() << " composing variables were loaded before the global config"; loadConfig(mFixedPath.getGlobalConfigPath(), variables, description); mergeComposingVariables(variables, composingVariables, description); boost::program_options::notify(variables); From 8b28b6e55e2eb2479f9e8ba7afd053fe718c80cf Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Fri, 23 Oct 2020 01:58:43 +0100 Subject: [PATCH 05/10] Compose BSA, context and script blacklist lists These would only take their value from the highest priority source, so specifying `openmw --content anExtraEsp.esp` would override all the content files in the user cfg file, and the user cfg file would override any in the global/local one. --- apps/openmw/main.cpp | 6 +++--- components/files/configurationmanager.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 0c46903c91..a860438ce4 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -67,7 +67,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat "set local data directory (highest priority)") ("fallback-archive", bpo::value()->default_value(Files::EscapeStringVector(), "fallback-archive") - ->multitoken(), "set fallback BSA archives (later archives have higher priority)") + ->multitoken()->composing(), "set fallback BSA archives (later archives have higher priority)") ("resources", bpo::value()->default_value("resources"), "set resources directory") @@ -76,7 +76,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat "set initial cell") ("content", bpo::value()->default_value(Files::EscapeStringVector(), "") - ->multitoken(), "content file(s): esm/esp, or omwgame/omwaddon") + ->multitoken()->composing(), "content file(s): esm/esp, or omwgame/omwaddon") ("no-sound", bpo::value()->implicit_value(true) ->default_value(false), "disable all sounds") @@ -101,7 +101,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat "\t2 - treat warnings as errors") ("script-blacklist", bpo::value()->default_value(Files::EscapeStringVector(), "") - ->multitoken(), "ignore the specified script (if the use of the blacklist is enabled)") + ->multitoken()->composing(), "ignore the specified script (if the use of the blacklist is enabled)") ("script-blacklist-use", bpo::value()->implicit_value(true) ->default_value(true), "enable script blacklisting") diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index c50c7713e6..c7847b1227 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -109,7 +109,7 @@ void ConfigurationManager::mergeComposingVariables(boost::program_options::varia boost::any& firstValue = variableValue.value(); const boost::any& secondValue = second[name].value(); - + if (firstValue.type() == typeid(Files::EscapePathContainer)) { auto& firstPathContainer = boost::any_cast(firstValue); @@ -117,6 +117,13 @@ void ConfigurationManager::mergeComposingVariables(boost::program_options::varia firstPathContainer.insert(firstPathContainer.end(), secondPathContainer.begin(), secondPathContainer.end()); } + else if (firstValue.type() == typeid(Files::EscapeStringVector)) + { + auto& firstVector = boost::any_cast(firstValue); + const auto& secondVector = boost::any_cast(secondValue); + + firstVector.mVector.insert(firstVector.mVector.end(), secondVector.mVector.begin(), secondVector.mVector.end()); + } else if (firstValue.type() == typeid(Fallback::FallbackMap)) { auto& firstMap = boost::any_cast(firstValue); From 350f6e61f760da7b9f4ac2f4e2eb5027cdbddd2e Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Fri, 23 Oct 2020 13:03:36 +0100 Subject: [PATCH 06/10] Move FallbackMap validator implementation to source file --- components/fallback/validate.cpp | 28 ++++++++++++++++++++++++++++ components/fallback/validate.hpp | 27 +-------------------------- 2 files changed, 29 insertions(+), 26 deletions(-) create mode 100644 components/fallback/validate.cpp diff --git a/components/fallback/validate.cpp b/components/fallback/validate.cpp new file mode 100644 index 0000000000..24865a0398 --- /dev/null +++ b/components/fallback/validate.cpp @@ -0,0 +1,28 @@ +#include "validate.hpp" + +void Fallback::validate(boost::any& v, std::vector const& tokens, FallbackMap*, int) +{ + if (v.empty()) + { + v = boost::any(FallbackMap()); + } + + FallbackMap *map = boost::any_cast(&v); + + for (std::vector::const_iterator it = tokens.begin(); it != tokens.end(); ++it) + { + std::string temp = Files::EscapeHashString::processString(*it); + int sep = temp.find(","); + if (sep < 1 || sep == (int)temp.length() - 1) +#if (BOOST_VERSION < 104200) + throw boost::program_options::validation_error("invalid value"); +#else + throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value); +#endif + + std::string key(temp.substr(0, sep)); + std::string value(temp.substr(sep + 1)); + + map->mMap[key] = value; + } +} diff --git a/components/fallback/validate.hpp b/components/fallback/validate.hpp index cef52e4624..96690f50a5 100644 --- a/components/fallback/validate.hpp +++ b/components/fallback/validate.hpp @@ -16,32 +16,7 @@ namespace Fallback std::map mMap; }; - void validate(boost::any &v, std::vector const &tokens, FallbackMap*, int) - { - if (v.empty()) - { - v = boost::any(FallbackMap()); - } - - FallbackMap *map = boost::any_cast(&v); - - for (std::vector::const_iterator it = tokens.begin(); it != tokens.end(); ++it) - { - std::string temp = Files::EscapeHashString::processString(*it); - int sep = temp.find(","); - if (sep < 1 || sep == (int)temp.length() - 1) -#if (BOOST_VERSION < 104200) - throw boost::program_options::validation_error("invalid value"); -#else - throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value); -#endif - - std::string key(temp.substr(0, sep)); - std::string value(temp.substr(sep + 1)); - - map->mMap[key] = value; - } - } + void validate(boost::any &v, std::vector const &tokens, FallbackMap*, int); } #endif From ce0966b9b7f11f8f6a899fc0bdf570ce6dd83b16 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Fri, 23 Oct 2020 13:13:47 +0100 Subject: [PATCH 07/10] Improve validate implementation --- components/fallback/validate.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/fallback/validate.cpp b/components/fallback/validate.cpp index 24865a0398..27f1f233e5 100644 --- a/components/fallback/validate.cpp +++ b/components/fallback/validate.cpp @@ -9,11 +9,11 @@ void Fallback::validate(boost::any& v, std::vector const& tokens, F FallbackMap *map = boost::any_cast(&v); - for (std::vector::const_iterator it = tokens.begin(); it != tokens.end(); ++it) + for (const auto& token : tokens) { - std::string temp = Files::EscapeHashString::processString(*it); - int sep = temp.find(","); - if (sep < 1 || sep == (int)temp.length() - 1) + std::string temp = Files::EscapeHashString::processString(token); + size_t sep = temp.find(","); + if (sep < 1 || sep == temp.length() - 1) #if (BOOST_VERSION < 104200) throw boost::program_options::validation_error("invalid value"); #else From f57851587dcf766843b2e9dc25ad2cb9c1e0ed6e Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Fri, 23 Oct 2020 13:16:51 +0100 Subject: [PATCH 08/10] Fix edge case where FallbackMap has no comma --- components/fallback/validate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/fallback/validate.cpp b/components/fallback/validate.cpp index 27f1f233e5..98c6c39fd5 100644 --- a/components/fallback/validate.cpp +++ b/components/fallback/validate.cpp @@ -13,7 +13,7 @@ void Fallback::validate(boost::any& v, std::vector const& tokens, F { std::string temp = Files::EscapeHashString::processString(token); size_t sep = temp.find(","); - if (sep < 1 || sep == temp.length() - 1) + if (sep < 1 || sep == temp.length() - 1 || sep == std::string::npos) #if (BOOST_VERSION < 104200) throw boost::program_options::validation_error("invalid value"); #else From 538314b03aad22d0f334bc0c18814eb1437a128b Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Fri, 23 Oct 2020 15:34:41 +0100 Subject: [PATCH 09/10] Make path settings have path type --- apps/opencs/editor.cpp | 15 +++------ apps/openmw/main.cpp | 23 ++++++-------- components/config/gamesettings.cpp | 50 ++++++++++++------------------ 3 files changed, 34 insertions(+), 54 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 0c3d006c4f..0dce198f8a 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -89,10 +89,10 @@ std::pair > CS::Editor::readConfi desc.add_options() ("data", boost::program_options::value()->default_value(Files::EscapePathContainer(), "data")->multitoken()->composing()) - ("data-local", boost::program_options::value()->default_value("")) + ("data-local", boost::program_options::value()->default_value(Files::EscapePath(), "")) ("fs-strict", boost::program_options::value()->implicit_value(true)->default_value(false)) ("encoding", boost::program_options::value()->default_value("win1252")) - ("resources", boost::program_options::value()->default_value("resources")) + ("resources", boost::program_options::value()->default_value(Files::EscapePath(), "resources")) ("fallback-archive", boost::program_options::value()-> default_value(Files::EscapeStringVector(), "fallback-archive")->multitoken()) ("fallback", boost::program_options::value()->default_value(FallbackMap(), "") @@ -112,7 +112,7 @@ std::pair > CS::Editor::readConfi mDocumentManager.setEncoding(ToUTF8::calculateEncoding(mEncodingName)); mFileDialog.setEncoding (QString::fromUtf8(mEncodingName.c_str())); - mDocumentManager.setResourceDir (mResources = variables["resources"].as().toStdString()); + mDocumentManager.setResourceDir (mResources = variables["resources"].as().mPath); if (variables["script-blacklist-use"].as()) mDocumentManager.setBlacklistedScripts ( @@ -125,14 +125,9 @@ std::pair > CS::Editor::readConfi dataDirs = Files::PathContainer(Files::EscapePath::toPathContainer(variables["data"].as())); } - std::string local = variables["data-local"].as().toStdString(); + Files::PathContainer::value_type local(variables["data-local"].as().mPath); if (!local.empty()) - { - if (local.front() == '\"') - local = local.substr(1, local.length() - 2); - - dataLocal.push_back(Files::PathContainer::value_type(local)); - } + dataLocal.push_back(local); mCfgMgr.processPaths (dataDirs); mCfgMgr.processPaths (dataLocal, true); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index a860438ce4..adf4bf18c2 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -63,13 +63,13 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("data", bpo::value()->default_value(Files::EscapePathContainer(), "data") ->multitoken()->composing(), "set data directories (later directories have higher priority)") - ("data-local", bpo::value()->default_value(""), + ("data-local", bpo::value()->default_value(Files::EscapePath(), ""), "set local data directory (highest priority)") ("fallback-archive", bpo::value()->default_value(Files::EscapeStringVector(), "fallback-archive") ->multitoken()->composing(), "set fallback BSA archives (later archives have higher priority)") - ("resources", bpo::value()->default_value("resources"), + ("resources", bpo::value()->default_value(Files::EscapePath(), "resources"), "set resources directory") ("start", bpo::value()->default_value(""), @@ -106,7 +106,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("script-blacklist-use", bpo::value()->implicit_value(true) ->default_value(true), "enable script blacklisting") - ("load-savegame", bpo::value()->default_value(""), + ("load-savegame", bpo::value()->default_value(Files::EscapePath(), ""), "load a save game file on game startup (specify an absolute filename or a filename relative to the current working directory)") ("skip-menu", bpo::value()->implicit_value(true) @@ -159,7 +159,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat { cfgMgr.readConfiguration(variables, desc, true); - Version::Version v = Version::getOpenmwVersion(variables["resources"].as().toStdString()); + Version::Version v = Version::getOpenmwVersion(variables["resources"].as().mPath.string()); std::cout << v.describe() << std::endl; return false; } @@ -168,7 +168,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat cfgMgr.readConfiguration(variables, desc); cfgMgr.mergeComposingVariables(variables, composingVariables, desc); - Version::Version v = Version::getOpenmwVersion(variables["resources"].as().toStdString()); + Version::Version v = Version::getOpenmwVersion(variables["resources"].as().mPath.string()); std::cout << v.describe() << std::endl; engine.setGrabMouse(!variables["no-grab"].as()); @@ -183,18 +183,13 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat Files::PathContainer dataDirs(Files::EscapePath::toPathContainer(variables["data"].as())); - std::string local(variables["data-local"].as().toStdString()); + Files::PathContainer::value_type local(variables["data-local"].as().mPath); if (!local.empty()) - { - if (local.front() == '\"') - local = local.substr(1, local.length() - 2); - - dataDirs.push_back(Files::PathContainer::value_type(local)); - } + dataDirs.push_back(local); cfgMgr.processPaths(dataDirs); - engine.setResourceDir(variables["resources"].as().toStdString()); + engine.setResourceDir(variables["resources"].as().mPath); engine.setDataDirs(dataDirs); // fallback archives @@ -232,7 +227,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setWarningsMode (variables["script-warn"].as()); engine.setScriptBlacklist (variables["script-blacklist"].as().toStdStringVector()); engine.setScriptBlacklistUse (variables["script-blacklist-use"].as()); - engine.setSaveGameFile (variables["load-savegame"].as().toStdString()); + engine.setSaveGameFile (variables["load-savegame"].as().mPath.string()); // other settings Fallback::Map::init(variables["fallback"].as().mMap); diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index b771b7fc8e..223045ab5f 100644 --- a/components/config/gamesettings.cpp +++ b/components/config/gamesettings.cpp @@ -118,12 +118,19 @@ bool Config::GameSettings::readFile(QTextStream &stream, QMultiMap