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 | |
parent | f5e3f241af190e487c0499dae0efc12e9ae2d202 (diff) | |
download | manaplus-7778c082e9b15774a1e79ab77cb60edb5c3a2949.tar.gz manaplus-7778c082e9b15774a1e79ab77cb60edb5c3a2949.tar.bz2 manaplus-7778c082e9b15774a1e79ab77cb60edb5c3a2949.tar.xz manaplus-7778c082e9b15774a1e79ab77cb60edb5c3a2949.zip |
Add some checks after automatic check code by tools.
-rw-r--r-- | src/configuration.cpp | 49 | ||||
-rw-r--r-- | src/gui/windows/mailwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/mailwindow.h | 2 | ||||
-rw-r--r-- | src/resources/sprite/spritedef.cpp | 12 | ||||
-rw-r--r-- | src/unittests/gui/windowmanager.cc | 2 | ||||
-rw-r--r-- | src/utils/xml/libxml.cpp | 2 |
6 files changed, 47 insertions, 22 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; diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp index 254aa2f73..9da69fb0a 100644 --- a/src/gui/windows/mailwindow.cpp +++ b/src/gui/windows/mailwindow.cpp @@ -189,7 +189,7 @@ void MailWindow::clear() mListBox->setSelected(-1); } -std::string MailWindow::getMailHeader(MailMessage *const message) const +std::string MailWindow::getMailHeader(const MailMessage *const message) const { if (mUseMail2) { diff --git a/src/gui/windows/mailwindow.h b/src/gui/windows/mailwindow.h index 6a310fb37..c99236499 100644 --- a/src/gui/windows/mailwindow.h +++ b/src/gui/windows/mailwindow.h @@ -85,7 +85,7 @@ class MailWindow final : public Window, private: void refreshMails(); - std::string getMailHeader(MailMessage *const message) const + std::string getMailHeader(const MailMessage *const message) const A_WARN_UNUSED A_NONNULL(2); STD_VECTOR<MailMessage*> mMessages; diff --git a/src/resources/sprite/spritedef.cpp b/src/resources/sprite/spritedef.cpp index 5fdb68584..aa79ef9f8 100644 --- a/src/resources/sprite/spritedef.cpp +++ b/src/resources/sprite/spritedef.cpp @@ -142,8 +142,12 @@ void SpriteDef::fixDeadAction() const ActionMap::iterator i = d->find(SpriteAction::DEAD); const ActionMap::iterator i2 = d->find(SpriteAction::STAND); // search dead action and check what it not same with stand action - if (i != d->end() && (i->second != nullptr) && i->second != i2->second) + if (i != d->end() && + i->second != nullptr && + (i2 == d->end() || i->second != i2->second)) + { (i->second)->setLastFrameDelay(0); + } } } @@ -300,9 +304,13 @@ void SpriteDef::loadAction(XmlNodeConstPtr node, // dirty hack to fix bad resources in tmw server if (actionName == "attack_stab") + { + reportAlways("Found legacy attribute attack_stab in animation"); addAction(hp, "attack", action); + } - // When first action set it as default direction + // When first action, set it as default direction. + // i here always correct, because hp was added above. const Actions::const_iterator i = mActions.find(hp); if ((*i).second->size() == 1) addAction(hp, SpriteAction::DEFAULT, action); diff --git a/src/unittests/gui/windowmanager.cc b/src/unittests/gui/windowmanager.cc index 41e2e755b..108ae18d0 100644 --- a/src/unittests/gui/windowmanager.cc +++ b/src/unittests/gui/windowmanager.cc @@ -506,7 +506,7 @@ TEST_CASE("Windows tests", "windowmanager") gui->draw(); mainGraphics->updateScreen(); delete2(mailViewWindow); - delete(message); + delete message; } SECTION("MailWindow") { diff --git a/src/utils/xml/libxml.cpp b/src/utils/xml/libxml.cpp index 46c3fbb76..6dd87b3f2 100644 --- a/src/utils/xml/libxml.cpp +++ b/src/utils/xml/libxml.cpp @@ -100,7 +100,7 @@ namespace XML if (useResman == UseVirtFs_true) { data = const_cast<char*>(VirtFs::loadFile( - filename.c_str(), + filename, size)); } else |