diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 9be1e8a7f..645316f9c 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -69,8 +69,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat { // Create a local alias for brevity namespace bpo = boost::program_options; - typedef Files::EscapeHashString string; - typedef std::vector StringsVector; + typedef std::vector StringsVector; bpo::options_description desc("Syntax: openmw \nAllowed options"); @@ -80,16 +79,16 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("data", bpo::value()->default_value(Files::PathContainer(), "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(StringsVector(), "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(StringsVector(), "") @@ -110,7 +109,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) @@ -126,7 +125,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) @@ -138,7 +137,7 @@ 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" @@ -242,7 +241,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setScriptConsoleMode (variables["script-console"].as()); engine.setStartupScript (variables["script-run"].as()); engine.setWarningsMode (variables["script-warn"].as()); - engine.setScriptBlacklist (string::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()); diff --git a/components/fallback/validate.hpp b/components/fallback/validate.hpp index 4df7da6e7..4c4897c27 100644 --- a/components/fallback/validate.hpp +++ b/components/fallback/validate.hpp @@ -12,11 +12,11 @@ namespace Fallback { - struct FallbackMap { - std::map mMap; - }; + struct FallbackMap { + std::map mMap; + }; - struct EscapeFallbackMap : FallbackMap + struct EscapeFallbackMap : FallbackMap { std::map mMap; @@ -29,34 +29,34 @@ namespace Fallback } }; - void validate(boost::any &v, std::vector const &tokens, FallbackMap*, int) - { - if(v.empty()) - { - v = boost::any(FallbackMap()); - } + void validate(boost::any &v, std::vector const &tokens, FallbackMap*, int) + { + if (v.empty()) + { + v = boost::any(FallbackMap()); + } - FallbackMap *map = boost::any_cast(&v); + FallbackMap *map = boost::any_cast(&v); - for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); ++it) - { - int sep = it->find(","); - if(sep < 1 || sep == (int)it->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 + for (std::vector::const_iterator it = tokens.begin(); it != tokens.end(); ++it) + { + int sep = it->find(","); + if (sep < 1 || sep == (int)it->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(it->substr(0,sep)); - std::string value(it->substr(sep+1)); + std::string key(it->substr(0, sep)); + std::string value(it->substr(sep + 1)); - if(map->mMap.find(key) == map->mMap.end()) - { - map->mMap.insert(std::make_pair (key,value)); - } - } - } + if (map->mMap.find(key) == map->mMap.end()) + { + map->mMap.insert(std::make_pair(key, value)); + } + } + } void validate(boost::any &v, std::vector const &tokens, EscapeFallbackMap* eFM, int a) { @@ -64,4 +64,13 @@ 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; + } +} + #endif diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index c7ac976d6..78e49e23d 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -285,6 +285,12 @@ std::string EscapeHashString::toStdString() const return std::string(* this); } +std::string * EscapeHashString::toStdStringPtr() const +{ + std::string * ret = new std::string(*this); + return ret; +} + const boost::filesystem::path& ConfigurationManager::getGlobalPath() const { return mFixedPath.getGlobalConfigPath(); diff --git a/components/files/configurationmanager.hpp b/components/files/configurationmanager.hpp index 47ecc9eb2..0d3517d48 100644 --- a/components/files/configurationmanager.hpp +++ b/components/files/configurationmanager.hpp @@ -107,6 +107,7 @@ class EscapeHashString : public std::string EscapeHashString(InputIterator first, InputIterator last); std::string toStdString() const; + std::string * toStdStringPtr() const; }; } /* namespace Cfg */