diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-03-16 14:28:45 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-03-16 14:28:45 +0200 |
commit | 59dc0bffc0f754de8daed29bce3a48e90ea6b4fb (patch) | |
tree | 7cd423679a60e25b29318d7a87f367729f8d5fdf /src/resources/mapreader.cpp | |
parent | fbf665912933d10d9132b17802949149d9094fdd (diff) | |
download | manaverse-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.tar.gz manaverse-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.tar.bz2 manaverse-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.tar.xz manaverse-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.zip |
Add checks and fix some code style.
Diffstat (limited to 'src/resources/mapreader.cpp')
-rw-r--r-- | src/resources/mapreader.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index d3cd22988..7bcb08a0f 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -246,6 +246,9 @@ Map *MapReader::readMap(const std::string &filename, Map *MapReader::readMap(xmlNodePtr node, const std::string &path) { + if (!node) + return 0; + // Take the filename off the path const std::string pathDir = path.substr(0, path.rfind("/") + 1); @@ -274,9 +277,7 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path) { Tileset *tileset = readTileset(childNode, pathDir, map); if (tileset) - { map->addTileset(tileset); - } } else if (xmlStrEqual(childNode->name, BAD_CAST "layer")) { @@ -368,7 +369,7 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path) void MapReader::readProperties(xmlNodePtr node, Properties *props) { - if (!props) + if (!node || !props) return; for_each_xml_child_node(childNode, node) @@ -620,6 +621,8 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path, doc = new XML::Document(filename); node = doc->rootNode(); + if (!node) + return 0; // Reset path to be realtive to the tsx file pathDir = filename.substr(0, filename.rfind("/") + 1); |