summaryrefslogtreecommitdiff
path: root/src/resources/mapreader.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-04-07 08:37:23 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-04-07 08:37:23 +0000
commit64d58b9a7e057e6d829107678b1570082be1093f (patch)
treef95a940521150e8f5bbab1bba520c956c8b2aed9 /src/resources/mapreader.cpp
parent36a53a1d5e3b558dafe200a6929948e7730c94f0 (diff)
downloadmana-64d58b9a7e057e6d829107678b1570082be1093f.tar.gz
mana-64d58b9a7e057e6d829107678b1570082be1093f.tar.bz2
mana-64d58b9a7e057e6d829107678b1570082be1093f.tar.xz
mana-64d58b9a7e057e6d829107678b1570082be1093f.zip
Added XML::Document class which simplifies parsing an XML document and
automatically cleans it up again.
Diffstat (limited to 'src/resources/mapreader.cpp')
-rw-r--r--src/resources/mapreader.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index a07fc18d..3864580b 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -183,21 +183,19 @@ MapReader::readMap(const std::string &filename)
inflatedSize = fileSize;
}
- xmlDocPtr doc = xmlParseMemory((char*) inflated, inflatedSize);
+ XML::Document doc((char*) inflated, inflatedSize);
free(inflated);
- // Parse the inflated map data
- if (doc) {
- xmlNodePtr node = xmlDocGetRootElement(doc);
+ xmlNodePtr node = doc.rootNode();
- if (!node || !xmlStrEqual(node->name, BAD_CAST "map")) {
+ // Parse the inflated map data
+ if (node) {
+ if (!xmlStrEqual(node->name, BAD_CAST "map")) {
logger->log("Error: Not a map file (%s)!", filename.c_str());
}
- else
- {
+ else {
map = readMap(node, filename);
}
- xmlFreeDoc(doc);
} else {
logger->log("Error while parsing map file (%s)!", filename.c_str());
}