diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2007-04-23 00:48:37 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2007-04-23 00:48:37 +0000 |
commit | b3376bfe4e26591e1dc1066d8f2270baf4f9f759 (patch) | |
tree | 6cba270a59320bf7c77266fe736cfb68bc2521a0 /src/resources/spritedef.cpp | |
parent | 6d09c8f4667f75fece4a5549de237e17490398cf (diff) | |
download | mana-b3376bfe4e26591e1dc1066d8f2270baf4f9f759.tar.gz mana-b3376bfe4e26591e1dc1066d8f2270baf4f9f759.tar.bz2 mana-b3376bfe4e26591e1dc1066d8f2270baf4f9f759.tar.xz mana-b3376bfe4e26591e1dc1066d8f2270baf4f9f759.zip |
Merged Björn Steinbrinks improvements at the xml parsing from trunk version.
Diffstat (limited to 'src/resources/spritedef.cpp')
-rw-r--r-- | src/resources/spritedef.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index d29bd847..24156be1 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -76,22 +76,22 @@ SpriteDef::load(const std::string &animationFile, int variant) "Animation: Error while parsing animation definition file!"); } - xmlNodePtr node = xmlDocGetRootElement(doc); - if (!node || !xmlStrEqual(node->name, BAD_CAST "sprite")) { + xmlNodePtr rootNode = xmlDocGetRootElement(doc); + if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "sprite")) { logger->error( "Animation: this is not a valid animation definition file!"); } // Get the variant - int variant_num = XML::getProperty(node, "variants", 0); + int variant_num = XML::getProperty(rootNode, "variants", 0); int variant_offset = 0; if (variant_num > 0 && variant < variant_num) { - variant_offset = variant * XML::getProperty(node, "variant_offset", 0); + variant_offset = variant * XML::getProperty(rootNode, "variant_offset", 0); } - for (node = node->xmlChildrenNode; node != NULL; node = node->next) + for_each_xml_child_node(node, rootNode) { if (xmlStrEqual(node->name, BAD_CAST "imageset")) { @@ -177,9 +177,7 @@ SpriteDef::loadAction(xmlNodePtr node, int variant_offset) } // Load animations - for (xmlNodePtr animationNode = node->xmlChildrenNode; - animationNode != NULL; - animationNode = animationNode->next) + for_each_xml_child_node(animationNode, node) { if (xmlStrEqual(animationNode->name, BAD_CAST "animation")) { @@ -208,9 +206,7 @@ SpriteDef::loadAnimation(xmlNodePtr animationNode, action->setAnimation(directionType, animation); // Get animation frames - for (xmlNodePtr frameNode = animationNode->xmlChildrenNode; - frameNode != NULL; - frameNode = frameNode->next) + for_each_xml_child_node(frameNode, animationNode) { int delay = XML::getProperty(frameNode, "delay", 0); int offsetX = XML::getProperty(frameNode, "offsetX", 0); |