[Change] Cleaned up XML loading somewhat.

This commit is contained in:
Allanis 2013-07-27 15:14:55 +01:00
parent 4f6c5fb93f
commit 10ea68c5c3
2 changed files with 15 additions and 10 deletions

View File

@ -221,6 +221,10 @@ static int mission_meetReq(int mission, int faction, char* planet, char* sysname
!mission_meetCond(misn))
return 0;
if((misn->avail.done != NULL) && /* Mission does not meet previous mission requirements. */
(player_missionAlreadyDone(mission_getID(misn->avail.done))==0))
return 0;
return 1;
}
@ -424,22 +428,22 @@ static MissionData* mission_parse(const xmlNodePtr parent) {
else if(xml_isNode(node, "avail")) { /* Mission availability. */
cur = node->children;
do {
if(xml_isNode(cur, "location"))
if(xml_isNode(cur, "location")) {
tmp->avail.loc = mission_location(xml_get(cur));
else if(xml_isNode(cur, "chance"))
tmp->avail.chance = xml_getInt(cur);
else if(xml_isNode(cur, "planet"))
tmp->avail.planet = strdup(xml_get(cur));
else if(xml_isNode(cur, "system"))
tmp->avail.system = strdup(xml_get(cur));
else if(xml_isNode(cur, "faction")) {
continue;
}
xmlr_int(cur, "chance", tmp->avail.chance);
xmlr_strd(cur, "planet", tmp->avail.planet);
xmlr_strd(cur, "system", tmp->avail.system);
if(xml_isNode(cur, "faction")) {
tmp->avail.factions = realloc(tmp->avail.factions,
sizeof(int) * ++tmp->avail.nfactions);
tmp->avail.factions[tmp->avail.nfactions-1] =
faction_get(xml_get(cur));
continue;
}
else if(xml_isNode(cur, "cond"))
tmp->avail.cond = strdup(xml_get(cur));
xmlr_strd(cur, "cond", tmp->avail.cond);
xmlr_strd(cur, "done", tmp->avail.done);
} while(xml_nextNode(cur));
}
} while(xml_nextNode(node));

View File

@ -34,6 +34,7 @@ typedef struct MissionData_ {
int nfactions;
char* cond; /* Conditional that must be met. */
char* done; /* Previous mission that must have been done. */
} avail;
unsigned int flags; /* Flags to store binary properties. */