diff options
author | Treeston <treeston.mmoc@gmail.com> | 2020-08-26 23:31:45 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-02-04 00:27:13 +0100 |
commit | be9dadc18949c6877f486eab9ee95237224a237e (patch) | |
tree | f34fcd28a0acf43d54c4bf853a24800090a2761b /src/common/Configuration/Config.cpp | |
parent | 7b88fd607e974843481d3055eb2eebc53c2a4b49 (diff) |
Common/Utilities: Centralize string -> T conversion in StringConvert.h (PR #25335)
(cherry picked from commit cd30e0b86ce6ee88386a91cebdf353fc55805c57)
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 4ac24715646..408e64ffdd7 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; + } } int32 ConfigMgr::GetIntDefault(std::string const& name, int32 def, bool quiet) const |