diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-06-25 22:31:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-06-25 23:31:02 +0300 |
commit | 7ee1d89a656c05b62fa3104b59504afed0037b69 (patch) | |
tree | 7a20e371ba1035fc43135f069407b51d81d15527 /src/resources/db/itemdb.cpp | |
parent | d49a520d19f28c613c68b574686b182a9c0621be (diff) | |
download | ManaVerse-7ee1d89a656c05b62fa3104b59504afed0037b69.tar.gz ManaVerse-7ee1d89a656c05b62fa3104b59504afed0037b69.tar.bz2 ManaVerse-7ee1d89a656c05b62fa3104b59504afed0037b69.tar.xz ManaVerse-7ee1d89a656c05b62fa3104b59504afed0037b69.zip |
Add missing checks into db directory.
Diffstat (limited to 'src/resources/db/itemdb.cpp')
-rw-r--r-- | src/resources/db/itemdb.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp index d1ec2d00f..2b1601c76 100644 --- a/src/resources/db/itemdb.cpp +++ b/src/resources/db/itemdb.cpp @@ -57,16 +57,16 @@ namespace // Forward declarations static void loadSpriteRef(ItemInfo *const itemInfo, - const XmlNodePtr node); + const XmlNodePtr node) A_NONNULL(1); static void loadSoundRef(ItemInfo *const itemInfo, - const XmlNodePtr node); -static void loadFloorSprite(SpriteDisplay *const display, + const XmlNodePtr node) A_NONNULL(1); +static void loadFloorSprite(SpriteDisplay &display, const XmlNodePtrConst node); static void loadReplaceSprite(ItemInfo *const itemInfo, - const XmlNodePtr replaceNode); + const XmlNodePtr replaceNode) A_NONNULL(1); static void loadOrderSprite(ItemInfo *const itemInfo, const XmlNodePtr node, - const bool drawAfter); + const bool drawAfter) A_NONNULL(1); static int parseSpriteName(const std::string &name); static int parseDirectionName(const std::string &name); @@ -453,7 +453,7 @@ void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum) } else if (xmlNameEqual(itemChild, "floor")) { - loadFloorSprite(&display, itemChild); + loadFloorSprite(display, itemChild); } else if (xmlNameEqual(itemChild, "replace")) { @@ -741,7 +741,7 @@ static int parseDirectionName(const std::string &name) static void loadSpriteRef(ItemInfo *const itemInfo, const XmlNodePtr node) { const std::string gender = XML::getProperty(node, "gender", "unisex"); - if (!node->xmlChildrenNode) + if (!node || !node->xmlChildrenNode) return; const std::string filename = reinterpret_cast<const char*>( @@ -758,7 +758,7 @@ static void loadSpriteRef(ItemInfo *const itemInfo, const XmlNodePtr node) static void loadSoundRef(ItemInfo *const itemInfo, const XmlNodePtr node) { - if (!node->xmlChildrenNode) + if (!node || !node->xmlChildrenNode) return; const std::string event = XML::getProperty(node, "event", ""); const std::string filename = reinterpret_cast<const char*>( @@ -778,9 +778,11 @@ static void loadSoundRef(ItemInfo *const itemInfo, const XmlNodePtr node) } } -static void loadFloorSprite(SpriteDisplay *const display, +static void loadFloorSprite(SpriteDisplay &display, const XmlNodePtrConst floorNode) { + if (!floorNode) + return; for_each_xml_child_node(spriteNode, floorNode) { if (!spriteNode->xmlChildrenNode) @@ -792,11 +794,11 @@ static void loadFloorSprite(SpriteDisplay *const display, spriteNode->xmlChildrenNode->content); currentSprite->variant = XML::getProperty(spriteNode, "variant", 0); - display->sprites.push_back(currentSprite); + display.sprites.push_back(currentSprite); } else if (xmlNameEqual(spriteNode, "particlefx")) { - display->particles.push_back(reinterpret_cast<const char*>( + display.particles.push_back(reinterpret_cast<const char*>( spriteNode->xmlChildrenNode->content)); } } @@ -805,6 +807,8 @@ static void loadFloorSprite(SpriteDisplay *const display, static void loadReplaceSprite(ItemInfo *const itemInfo, const XmlNodePtr replaceNode) { + if (!replaceNode) + return; const std::string removeSprite = XML::getProperty( replaceNode, "sprite", ""); const int direction = parseDirectionName(XML::getProperty( |