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 | |
parent | d49a520d19f28c613c68b574686b182a9c0621be (diff) | |
download | mv-7ee1d89a656c05b62fa3104b59504afed0037b69.tar.gz mv-7ee1d89a656c05b62fa3104b59504afed0037b69.tar.bz2 mv-7ee1d89a656c05b62fa3104b59504afed0037b69.tar.xz mv-7ee1d89a656c05b62fa3104b59504afed0037b69.zip |
Add missing checks into db directory.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/db/chardb.cpp | 6 | ||||
-rw-r--r-- | src/resources/db/itemdb.cpp | 26 | ||||
-rw-r--r-- | src/resources/db/mapdb.cpp | 4 |
3 files changed, 23 insertions, 13 deletions
diff --git a/src/resources/db/chardb.cpp b/src/resources/db/chardb.cpp index 9b6f24358..84cdd6327 100644 --- a/src/resources/db/chardb.cpp +++ b/src/resources/db/chardb.cpp @@ -102,8 +102,10 @@ void CharDB::loadMinMax(const XmlNodePtr node, unsigned *restrict const min, unsigned *restrict const max) { - *min = XML::getProperty(node, "min", 1); - *max = XML::getProperty(node, "max", 10); + if (min) + *min = XML::getProperty(node, "min", 1); + if (max) + *max = XML::getProperty(node, "max", 10); } void CharDB::unload() 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( diff --git a/src/resources/db/mapdb.cpp b/src/resources/db/mapdb.cpp index 1bd63af2f..44c37771b 100644 --- a/src/resources/db/mapdb.cpp +++ b/src/resources/db/mapdb.cpp @@ -98,6 +98,8 @@ void MapDB::loadRemapXmlFile(const std::string &fileName) void MapDB::readMap(XmlNodePtrConst node) { + if (!node) + return; const std::string map = XML::getProperty(node, "name", ""); if (map.empty()) return; @@ -116,6 +118,8 @@ void MapDB::readMap(XmlNodePtrConst node) void MapDB::readAtlas(XmlNodePtrConst node) { + if (!node) + return; const std::string atlas = XML::getProperty(node, "name", ""); if (atlas.empty()) return; |