summaryrefslogtreecommitdiff
path: root/src/resources/mapreader.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-03-16 14:28:45 +0200
committerAndrei Karas <akaras@inbox.ru>2011-03-16 14:28:45 +0200
commit59dc0bffc0f754de8daed29bce3a48e90ea6b4fb (patch)
tree7cd423679a60e25b29318d7a87f367729f8d5fdf /src/resources/mapreader.cpp
parentfbf665912933d10d9132b17802949149d9094fdd (diff)
downloadmanaplus-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.tar.gz
manaplus-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.tar.bz2
manaplus-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.tar.xz
manaplus-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.zip
Add checks and fix some code style.
Diffstat (limited to 'src/resources/mapreader.cpp')
-rw-r--r--src/resources/mapreader.cpp9
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);