[Fix] Fixed segmentation fault when system only has one planet with no factions.
This commit is contained in:
parent
25660ff7d1
commit
b7ddccd309
18
src/map.c
18
src/map.c
@ -186,29 +186,27 @@ static void map_update(void) {
|
|||||||
/* System is known. */
|
/* System is known. */
|
||||||
window_modifyText(map_wid, "txtSysname", sys->name);
|
window_modifyText(map_wid, "txtSysname", sys->name);
|
||||||
|
|
||||||
if(sys->nplanets == 0) { /* No planets -> no factions. */
|
|
||||||
window_modifyText(map_wid, "txtFaction", "NA");
|
|
||||||
window_moveWidget(map_wid, "txtSStanding", -20, -100);
|
|
||||||
window_moveWidget(map_wid, "txtStanding", -20, -100-gl_smallFont.h-5);
|
|
||||||
window_modifyText(map_wid, "txtStanding", "NA");
|
|
||||||
y = -100;
|
|
||||||
} else {
|
|
||||||
standing = 0;
|
standing = 0;
|
||||||
nstanding = 0;
|
nstanding = 0;
|
||||||
f = -1;
|
|
||||||
for(i = 0; i < sys->nplanets; i++) {
|
for(i = 0; i < sys->nplanets; i++) {
|
||||||
if((f == -1) && (sys->planets[i]->faction > 0)) {
|
if((f == -1) && (sys->planets[i]->faction > 0)) {
|
||||||
f = sys->planets[i]->faction;
|
f = sys->planets[i]->faction;
|
||||||
standing += faction_getPlayer(f);
|
standing += faction_getPlayer(f);
|
||||||
nstanding++;
|
nstanding++;
|
||||||
}
|
}
|
||||||
else if(f != sys->planets[i]->faction &&
|
else if(f != sys->planets[i]->faction && /* @todo More verbosity. */
|
||||||
(sys->planets[i]->faction > 0)) {
|
(sys->planets[i]->faction > 0)) {
|
||||||
/* @todo More verbosity. */
|
|
||||||
snprintf(buf, 100, "Multiple");
|
snprintf(buf, 100, "Multiple");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(f == -1) {
|
||||||
|
window_modifyText(map_wid, "txtFaction", "NA");
|
||||||
|
window_moveWidget(map_wid, "txtSStanding", -20, -100);
|
||||||
|
window_moveWidget(map_wid, "txtStanding", -20, -100-gl_smallFont.h-5);
|
||||||
|
window_modifyText(map_wid, "txtStanding", "NA");
|
||||||
|
y = -100;
|
||||||
|
} else {
|
||||||
if(i == sys->nplanets)
|
if(i == sys->nplanets)
|
||||||
/* Saw them all, and all the same. */
|
/* Saw them all, and all the same. */
|
||||||
snprintf(buf, 100, "%s", faction_longname(f));
|
snprintf(buf, 100, "%s", faction_longname(f));
|
||||||
|
@ -615,6 +615,7 @@ static int planet_parse(Planet* planet, const xmlNodePtr parent) {
|
|||||||
|
|
||||||
/* Clear up memory for sane defaults. */
|
/* Clear up memory for sane defaults. */
|
||||||
memset(planet, 0, sizeof(Planet));
|
memset(planet, 0, sizeof(Planet));
|
||||||
|
planet->faction = -1;
|
||||||
str[0] = '\0';
|
str[0] = '\0';
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user