[Change] Cleaned up a little XML parsing stuff.
This commit is contained in:
parent
32adddc8d0
commit
92c7d549f0
19
src/outfit.c
19
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));
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user