diff options
author | Treeston <treeston.mmoc@gmail.com> | 2020-08-26 23:31:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-26 23:31:45 +0200 |
commit | cd30e0b86ce6ee88386a91cebdf353fc55805c57 (patch) | |
tree | 1453f0e4dcbe2f2197913e916ab3e99116a29080 /src/common/Configuration/Config.cpp | |
parent | 7cc027401e4a2837872db54c835a4ed1a98e4a03 (diff) |
Common/Utilities: Centralize string -> T conversion in StringConvert.h (PR #25335)
Diffstat (limited to 'src/common/Configuration/Config.cpp')
-rw-r--r-- | src/common/Configuration/Config.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/common/Configuration/Config.cpp b/src/common/Configuration/Config.cpp index fa0e546ccc3..29508c7b4c2 100644 --- a/src/common/Configuration/Config.cpp +++ b/src/common/Configuration/Config.cpp @@ -17,6 +17,7 @@ #include "Config.h" #include "Log.h" +#include "StringConvert.h" #include "Util.h" #include <boost/property_tree/ini_parser.hpp> #include <algorithm> @@ -137,7 +138,15 @@ bool ConfigMgr::GetBoolDefault(std::string const& name, bool def, bool quiet) co { std::string val = GetValueDefault(name, std::string(def ? "1" : "0"), quiet); val.erase(std::remove(val.begin(), val.end(), '"'), val.end()); - return StringToBool(val); + Optional<bool> boolVal = Trinity::StringTo<bool>(val); + if (boolVal) + return *boolVal; + else + { + TC_LOG_ERROR("server.loading", "Bad value defined for name %s in config file %s, going to use '%s' instead", + name.c_str(), _filename.c_str(), def ? "true" : "false"); + return def; + } } int ConfigMgr::GetIntDefault(std::string const& name, int def, bool quiet) const |