From 92c7d549f0f8e041ee574207f3667ba346455d51 Mon Sep 17 00:00:00 2001 From: Allanis <allanis@saracraft.net> Date: Sat, 11 May 2013 16:33:29 +0100 Subject: [PATCH] [Change] Cleaned up a little XML parsing stuff. --- src/outfit.c | 19 +++++++++---------- src/pilot.c | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/outfit.c b/src/outfit.c index 766f6de..b551726 100644 --- a/src/outfit.c +++ b/src/outfit.c @@ -201,12 +201,13 @@ static void outfit_parseSWeapon(Outfit* tmp, const xmlNodePtr parent) { do { // Load all the things. - if(xml_isNode(node, "speed")) tmp->u.blt.speed = xml_getFloat(node); - else if(xml_isNode(node, "delay")) tmp->u.blt.delay = xml_getInt(node); - else if(xml_isNode(node, "range")) tmp->u.blt.range = xml_getFloat(node); - else if(xml_isNode(node, "accuracy")) tmp->u.blt.accuracy = xml_getFloat(node); - else if(xml_isNode(node, "energy")) tmp->u.blt.energy = xml_getFloat(node); - else if(xml_isNode(node, "gfx")) { + xmlr_float(node, "speed", tmp->u.blt.speed); + xmlr_float(node, "delay", tmp->u.blt.delay); + xmlr_float(node, "range", tmp->u.blt.range); + xmlr_float(node, "accuracy", tmp->u.blt.accuracy); + xmlr_float(node, "energy", tmp->u.blt.energy); + + if(xml_isNode(node, "gfx")) { snprintf(str, strlen(xml_get(node))+sizeof(OUTFIT_GFX)+10, OUTFIT_GFX"space/%s.png", xml_get(node)); tmp->u.blt.gfx_space = gl_newSprite(str, 6, 6); @@ -218,10 +219,8 @@ static void outfit_parseSWeapon(Outfit* tmp, const xmlNodePtr parent) { else if(xml_isNode(node, "damage")) { cur = node->children; do { - if(xml_isNode(cur, "armour")) - tmp->u.blt.damage_armour = xml_getFloat(cur); - else if(xml_isNode(cur, "shield")) - tmp->u.blt.damage_shield = xml_getFloat(cur); + xmlr_float(cur, "armour", tmp->u.blt.damage_armour); + xmlr_float(cur, "shield", tmp->u.blt.damage_shield); } while((cur = cur->next)); } } while((node = node->next)); diff --git a/src/pilot.c b/src/pilot.c index 9bca452..4fe3217 100644 --- a/src/pilot.c +++ b/src/pilot.c @@ -1047,7 +1047,7 @@ int fleet_load(void) { } do { - if(node->type == XML_NODE_START && strcmp((char*)node->name,XML_FLEET)==0) { + if(xml_isNode(node, XML_FLEET)) { tmp = fleet_parse(node); fleet_stack = realloc(fleet_stack, sizeof(Fleet)*(++nfleets)); memcpy(fleet_stack+nfleets-1, tmp, sizeof(Fleet));