diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 645316f9c..d63d1f60c 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -69,7 +69,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat { // Create a local alias for brevity namespace bpo = boost::program_options; - typedef std::vector StringsVector; + typedef std::vector EscapeStringsVector; + typedef std::vector StringsVector; bpo::options_description desc("Syntax: openmw \nAllowed options"); @@ -82,7 +83,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("data-local", bpo::value()->default_value(""), "set local data directory (highest priority)") - ("fallback-archive", bpo::value()->default_value(StringsVector(), "fallback-archive") + ("fallback-archive", bpo::value()->default_value(EscapeStringsVector(), "fallback-archive") ->multitoken(), "set fallback BSA archives (later archives have higher priority)") ("resources", bpo::value()->default_value("resources"), @@ -91,7 +92,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("start", bpo::value()->default_value(""), "set initial cell") - ("content", bpo::value()->default_value(StringsVector(), "") + ("content", bpo::value()->default_value(EscapeStringsVector(), "") ->multitoken(), "content file(s): esm/esp, or omwgame/omwaddon") ("no-sound", bpo::value()->implicit_value(true) @@ -119,7 +120,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat "\t1 - show warning but consider script as correctly compiled anyway\n" "\t2 - treat warnings as errors") - ("script-blacklist", bpo::value()->default_value(StringsVector(), "") + ("script-blacklist", bpo::value()->default_value(EscapeStringsVector(), "") ->multitoken(), "ignore the specified script (if the use of the blacklist is enabled)") ("script-blacklist-use", bpo::value()->implicit_value(true) @@ -173,20 +174,20 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat { cfgMgr.readConfiguration(variables, desc, true); - Version::Version v = Version::getOpenmwVersion(variables["resources"].as()); + Version::Version v = Version::getOpenmwVersion(variables["resources"].as().toStdString()); std::cout << v.describe() << std::endl; return false; } cfgMgr.readConfiguration(variables, desc); - Version::Version v = Version::getOpenmwVersion(variables["resources"].as()); + Version::Version v = Version::getOpenmwVersion(variables["resources"].as().toStdString()); std::cout << v.describe() << std::endl; engine.setGrabMouse(!variables.count("no-grab")); // Font encoding settings - std::string encoding(variables["encoding"].as()); + std::string encoding(variables["encoding"].as().toStdString()); std::cout << ToUTF8::encodingUsingMessage(encoding) << std::endl; engine.setEncoding(ToUTF8::calculateEncoding(encoding)); @@ -195,7 +196,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat Files::PathContainer dataDirs(variables["data"].as()); - std::string local(variables["data-local"].as()); + std::string local(variables["data-local"].as().toStdString()); if (!local.empty()) { dataDirs.push_back(Files::PathContainer::value_type(local)); @@ -206,15 +207,15 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setDataDirs(dataDirs); // fallback archives - StringsVector archives = variables["fallback-archive"].as(); + StringsVector archives = Files::EscapeHashString::toStdStringVector(variables["fallback-archive"].as()); for (StringsVector::const_iterator it = archives.begin(); it != archives.end(); ++it) { engine.addArchive(*it); } - engine.setResourceDir(variables["resources"].as()); + engine.setResourceDir(variables["resources"].as().toStdString()); - StringsVector content = variables["content"].as(); + StringsVector content = Files::EscapeHashString::toStdStringVector(variables["content"].as()); if (content.empty()) { std::cout << "No content file given (esm/esp, nor omwgame/omwaddon). Aborting..." << std::endl; @@ -229,7 +230,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat } // startup-settings - engine.setCell(variables["start"].as()); + engine.setCell(variables["start"].as().toStdString()); engine.setSkipMenu (variables["skip-menu"].as(), variables["new-game"].as()); if (!variables["skip-menu"].as() && variables["new-game"].as()) std::cerr << "new-game used without skip-menu -> ignoring it" << std::endl; @@ -239,11 +240,11 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setCompileAllDialogue(variables["script-all-dialogue"].as()); engine.setScriptsVerbosity(variables["script-verbose"].as()); engine.setScriptConsoleMode (variables["script-console"].as()); - engine.setStartupScript (variables["script-run"].as()); + engine.setStartupScript (variables["script-run"].as().toStdString()); engine.setWarningsMode (variables["script-warn"].as()); - engine.setScriptBlacklist (Files::EscapeHashString::toStdStringVector(variables["script-blacklist"].as())); + engine.setScriptBlacklist (Files::EscapeHashString::toStdStringVector(variables["script-blacklist"].as())); engine.setScriptBlacklistUse (variables["script-blacklist-use"].as()); - engine.setSaveGameFile (variables["load-savegame"].as()); + engine.setSaveGameFile (variables["load-savegame"].as().toStdString()); // other settings engine.setSoundUsage(!variables["no-sound"].as()); diff --git a/components/fallback/validate.hpp b/components/fallback/validate.hpp index 4c4897c27..7683a1297 100644 --- a/components/fallback/validate.hpp +++ b/components/fallback/validate.hpp @@ -67,9 +67,14 @@ namespace Fallback namespace Files { void validate(boost::any &v, const std::vector &tokens, Files::EscapeHashString * eHS, int a) { - std::string * temp = eHS->toStdStringPtr(); - boost::program_options::validate(v, tokens, temp, a); - delete temp; + if (eHS == NULL) + boost::program_options::validate(v, tokens, (std::string *) NULL, a); + else + { + std::string * temp = eHS->toStdStringPtr(); + boost::program_options::validate(v, tokens, temp, a); + delete temp; + } } } diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index 78e49e23d..d8543738d 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -251,44 +251,43 @@ std::vector EscapeHashString::toStdStringVector(const std::vector -EscapeHashString::EscapeHashString(InputIterator first, InputIterator last) : std::string(EscapeHashString::processString(std::string(first, last))) +EscapeHashString::EscapeHashString(InputIterator first, InputIterator last) : mData(EscapeHashString::processString(std::string(first, last))) { } std::string EscapeHashString::toStdString() const { - return std::string(* this); + return std::string(mData); } std::string * EscapeHashString::toStdStringPtr() const { - std::string * ret = new std::string(*this); - return ret; + return new std::string(mData); } const boost::filesystem::path& ConfigurationManager::getGlobalPath() const diff --git a/components/files/configurationmanager.hpp b/components/files/configurationmanager.hpp index 0d3517d48..e6257eec4 100644 --- a/components/files/configurationmanager.hpp +++ b/components/files/configurationmanager.hpp @@ -93,6 +93,8 @@ struct escape_hash_filter : public boost::iostreams::input_filter */ class EscapeHashString : public std::string { + private: + std::string mData; public: static std::string processString(const std::string & str); static std::vector toStdStringVector(const std::vector & vec);