summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-26 00:41:35 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-26 00:41:35 +0300
commit5344dc6cd9156a9b67da834c9b5b4be00a62992a (patch)
treee71a20fbc231ccec6e53a718758eea447cfc7069 /src
parent02822f84a25b261f02f5928a6cbefe103cd9491e (diff)
downloadmv-5344dc6cd9156a9b67da834c9b5b4be00a62992a.tar.gz
mv-5344dc6cd9156a9b67da834c9b5b4be00a62992a.tar.bz2
mv-5344dc6cd9156a9b67da834c9b5b4be00a62992a.tar.xz
mv-5344dc6cd9156a9b67da834c9b5b4be00a62992a.zip
Add missing checks into other files.
Diffstat (limited to 'src')
-rw-r--r--src/actormanager.cpp2
-rw-r--r--src/configuration.cpp7
-rw-r--r--src/configuration.h2
-rw-r--r--src/gamemodifiers.h3
-rw-r--r--src/guild.cpp2
-rw-r--r--src/navigationmanager.cpp11
-rw-r--r--src/navigationmanager.h13
-rw-r--r--src/simpleanimation.cpp2
-rw-r--r--src/text.cpp4
-rw-r--r--src/textmanager.cpp16
-rw-r--r--src/touchmanager.cpp3
-rw-r--r--src/touchmanager.h11
12 files changed, 53 insertions, 23 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 0c460ba40..b5a683927 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -1794,6 +1794,8 @@ Being *ActorManager::cloneBeing(const Being *const srcBeing,
const int dx, const int dy,
const int id)
{
+ if (!srcBeing)
+ return nullptr;
Being *const dstBeing = actorManager->createBeing(fromInt(
toInt(srcBeing->getId(), int) + id, BeingId),
ActorType::Player,
diff --git a/src/configuration.cpp b/src/configuration.cpp
index d5af8c79f..b43dd88cf 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -673,11 +673,14 @@ bool Configuration::resetBoolValue(const std::string &key)
}
-void ConfigurationObject::initFromXML(const XmlNodePtrConst parent_node)
+void ConfigurationObject::initFromXML(const XmlNodePtrConst parentNode)
{
clear();
- for_each_xml_child_node(node, parent_node)
+ if (!parentNode)
+ return;
+
+ for_each_xml_child_node(node, parentNode)
{
if (xmlNameEqual(node, "list"))
{
diff --git a/src/configuration.h b/src/configuration.h
index c4ce39675..53b836795 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -204,7 +204,7 @@ class ConfigurationObject notfinal
protected:
ConfigurationObject();
- virtual void initFromXML(const XmlNodePtrConst parent_node);
+ virtual void initFromXML(const XmlNodePtrConst parentNode);
virtual void writeToXML(const XmlTextWriterPtr writer);
void deleteList(const std::string &name);
diff --git a/src/gamemodifiers.h b/src/gamemodifiers.h
index 6859018cc..cc9503987 100644
--- a/src/gamemodifiers.h
+++ b/src/gamemodifiers.h
@@ -69,7 +69,8 @@ class GameModifiers final
protected:
static const char *getVarItem(const char *const *const arr,
const unsigned index,
- const unsigned sz) A_WARN_UNUSED;
+ const unsigned sz)
+ A_WARN_UNUSED A_NONNULL(1);
};
#undef declModifier
diff --git a/src/guild.cpp b/src/guild.cpp
index 9dd83bb40..2d4633619 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -179,6 +179,8 @@ GuildMember *Guild::getMember(const std::string &name) const
void Guild::removeMember(const GuildMember *const member)
{
+ if (!member)
+ return;
MemberList::iterator itr = mMembers.begin();
const MemberList::iterator itr_end = mMembers.end();
while (itr != itr_end)
diff --git a/src/navigationmanager.cpp b/src/navigationmanager.cpp
index 5df18013f..cf078e06f 100644
--- a/src/navigationmanager.cpp
+++ b/src/navigationmanager.cpp
@@ -66,6 +66,8 @@ Resource *NavigationManager::loadWalkLayer(const Map *const map)
const MetaTile *const tiles = map->getMetaTiles();
int *const data = walkLayer->getData();
+ if (!tiles || !data)
+ return walkLayer;
int x = 0;
int y = 0;
@@ -81,7 +83,8 @@ Resource *NavigationManager::loadWalkLayer(const Map *const map)
#endif
bool NavigationManager::findWalkableTile(int &x1, int &y1,
- const int width, const int height,
+ const int width,
+ const int height,
const MetaTile *const tiles,
const int *const data)
{
@@ -103,8 +106,10 @@ bool NavigationManager::findWalkableTile(int &x1, int &y1,
}
void NavigationManager::fillNum(int x, int y,
- const int width, const int height,
- const int num, const MetaTile *const tiles,
+ const int width,
+ const int height,
+ const int num,
+ const MetaTile *const tiles,
int *const data)
{
std::vector<Cell> cells;
diff --git a/src/navigationmanager.h b/src/navigationmanager.h
index b009f340e..16b8b9fae 100644
--- a/src/navigationmanager.h
+++ b/src/navigationmanager.h
@@ -43,14 +43,17 @@ class NavigationManager final
private:
static bool findWalkableTile(int &x1, int &y1,
- const int width, const int height,
+ const int width,
+ const int height,
const MetaTile *const tiles,
- const int *const data);
+ const int *const data) A_NONNULL(5, 6);
static void fillNum(int x, int y,
- const int width, const int height,
- const int num, const MetaTile *const tiles,
- int *const data);
+ const int width,
+ const int height,
+ const int num,
+ const MetaTile *const tiles,
+ int *const data) A_NONNULL(6, 7);
};
#endif // NAVIGATIONMANAGER_H
diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp
index 6341f04e1..2943d5d92 100644
--- a/src/simpleanimation.cpp
+++ b/src/simpleanimation.cpp
@@ -39,7 +39,7 @@ SimpleAnimation::SimpleAnimation(Animation *const animation) :
mAnimation(animation),
mAnimationTime(0),
mAnimationPhase(0),
- mCurrentFrame(&mAnimation->mFrames[0]),
+ mCurrentFrame(mAnimation ? &mAnimation->mFrames[0] : nullptr),
mInitialized(true),
mImageSet(nullptr)
{
diff --git a/src/text.cpp b/src/text.cpp
index a665de641..c4540dd4c 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -56,8 +56,8 @@ Text::Text(const std::string &text,
mXOffset(0),
mText(text),
mColor(color),
- mOutlineColor(isSpeech == Speech_true ?
- *color : theme->getColor(ThemeColorId::OUTLINE, 255)),
+ mOutlineColor(color ? (isSpeech == Speech_true ?
+ *color : theme->getColor(ThemeColorId::OUTLINE, 255)) : Color()),
mIsSpeech(isSpeech),
mTextChanged(true)
{
diff --git a/src/textmanager.cpp b/src/textmanager.cpp
index 7bf973b89..bbb7685a3 100644
--- a/src/textmanager.cpp
+++ b/src/textmanager.cpp
@@ -36,12 +36,17 @@ TextManager::TextManager() :
void TextManager::addText(Text *const text)
{
+ if (!text)
+ return;
place(text, nullptr, text->mX, text->mY, text->mHeight);
mTextList.push_back(text);
}
-void TextManager::moveText(Text *const text, const int x, const int y) const
+void TextManager::moveText(Text *const text,
+ const int x, const int y) const
{
+ if (!text)
+ return;
text->mX = x;
text->mY = y;
place(text, text, text->mX, text->mY, text->mHeight);
@@ -72,9 +77,14 @@ void TextManager::draw(Graphics *const graphics,
BLOCK_END("TextManager::draw")
}
-void TextManager::place(const Text *const textObj, const Text *const omit,
- const int &x A_UNUSED, int &y, const int h) const
+void TextManager::place(const Text *const textObj,
+ const Text *const omit,
+ const int &x A_UNUSED,
+ int &y,
+ const int h) const
{
+ if (!textObj)
+ return;
const int xLeft = textObj->mX;
const int xRight1 = xLeft + textObj->mWidth;
const int TEST = 50; // Number of lines to test for text
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index 0b04ae511..11e514634 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -110,7 +110,8 @@ void TouchManager::init()
mHeight = mainGraphics->mHeight;
}
-void TouchManager::loadTouchItem(TouchItem **item, const std::string &name,
+void TouchManager::loadTouchItem(TouchItem **item,
+ const std::string &name,
const std::string &imageName,
const std::string &text,
int x, int y,
diff --git a/src/touchmanager.h b/src/touchmanager.h
index a281d8357..e044e625f 100644
--- a/src/touchmanager.h
+++ b/src/touchmanager.h
@@ -110,16 +110,19 @@ class TouchManager final : public ConfigListener
void init();
- void loadTouchItem(TouchItem **item, const std::string &name,
+ void loadTouchItem(TouchItem **item,
+ const std::string &name,
const std::string &imageName,
const std::string &text,
- int x, int y, const int width, const int height,
- const int type, const std::string &eventPressed,
+ int x, int y,
+ const int width, const int height,
+ const int type,
+ const std::string &eventPressed,
const std::string &eventReleased,
const TouchFuncPtr fAll = nullptr,
const TouchFuncPtr fPressed = nullptr,
const TouchFuncPtr fReleased = nullptr,
- const TouchFuncPtr fOut = nullptr);
+ const TouchFuncPtr fOut = nullptr) A_NONNULL(2);
void clear();