summaryrefslogtreecommitdiff
path: root/src/resources/spritedef.cpp
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2007-04-22 13:39:22 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2007-04-22 13:39:22 +0000
commit9398626764574fa536dca3806490f88970d2f056 (patch)
treeb8a5f938d6d6447846773a6270802c3595077222 /src/resources/spritedef.cpp
parentccf4dd308bcb8a592ece2d86102bbaa7080f0f7e (diff)
downloadmana-client-9398626764574fa536dca3806490f88970d2f056.tar.gz
mana-client-9398626764574fa536dca3806490f88970d2f056.tar.bz2
mana-client-9398626764574fa536dca3806490f88970d2f056.tar.xz
mana-client-9398626764574fa536dca3806490f88970d2f056.zip
Added a macro for XML child node iterations to make the code more terse and easier to read.
Diffstat (limited to 'src/resources/spritedef.cpp')
-rw-r--r--src/resources/spritedef.cpp18
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);