diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-09-01 21:51:33 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-09-01 21:54:54 +0300 |
commit | 7778c082e9b15774a1e79ab77cb60edb5c3a2949 (patch) | |
tree | 4eeeabda71cb5f2f330d52ee93c8922eef054d9e /src/configuration.cpp | |
parent | f5e3f241af190e487c0499dae0efc12e9ae2d202 (diff) | |
download | manaverse-7778c082e9b15774a1e79ab77cb60edb5c3a2949.tar.gz manaverse-7778c082e9b15774a1e79ab77cb60edb5c3a2949.tar.bz2 manaverse-7778c082e9b15774a1e79ab77cb60edb5c3a2949.tar.xz manaverse-7778c082e9b15774a1e79ab77cb60edb5c3a2949.zip |
Add some checks after automatic check code by tools.
Diffstat (limited to 'src/configuration.cpp')
-rw-r--r-- | src/configuration.cpp | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp index 94fa433f5..d3c514c67 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -458,19 +458,28 @@ int Configuration::resetIntValue(const std::string &key) GETLOG(); int defaultValue = 0; const DefaultsData::const_iterator itdef = mDefaultsData.find(key); - const VariableData *const data = itdef->second; - if (itdef != mDefaultsData.end() && data != nullptr - && data->getType() == VariableData::DATA_INT) - { - defaultValue = (static_cast<const IntData*>( - data))->getData(); - } - else + if (itdef == mDefaultsData.end()) { reportAlways("%s: No integer value in registry for key %s", mConfigPath.c_str(), key.c_str()); } + else + { + const VariableData *const data = itdef->second; + if (data != nullptr && + data->getType() == VariableData::DATA_INT) + { + defaultValue = (static_cast<const IntData*>( + data))->getData(); + } + else + { + reportAlways("%s: No integer value in registry for key %s", + mConfigPath.c_str(), + key.c_str()); + } + } setValue(key, defaultValue); return defaultValue; } @@ -658,20 +667,28 @@ bool Configuration::resetBoolValue(const std::string &key) GETLOG(); bool defaultValue = false; const DefaultsData::const_iterator itdef = mDefaultsData.find(key); - const VariableData *const data = itdef->second; - if (itdef != mDefaultsData.end() && - (data != nullptr) && - data->getType() == VariableData::DATA_BOOL) - { - defaultValue = (static_cast<const BoolData*>(data))->getData(); - } - else + if (itdef == mDefaultsData.end()) { reportAlways("%s: No boolean value in registry for key %s", mConfigPath.c_str(), key.c_str()); } + else + { + const VariableData *const data = itdef->second; + if (data != nullptr && + data->getType() == VariableData::DATA_BOOL) + { + defaultValue = (static_cast<const BoolData*>(data))->getData(); + } + else + { + reportAlways("%s: No boolean value in registry for key %s", + mConfigPath.c_str(), + key.c_str()); + } + } setValue(key, defaultValue); return defaultValue; |