[Fix] Planets with 0 tech won't segfault anymore. :/
This commit is contained in:
parent
b387cf0da7
commit
e4b72c0302
24
src/land.c
24
src/land.c
@ -567,6 +567,13 @@ static void shipyard_open(void) {
|
||||
|
||||
/* Setup the ships to buy/sell. */
|
||||
ships = ship_getTech(&nships, land_planet->tech, PLANET_TECH_MAX);
|
||||
|
||||
if(nships <= 0) {
|
||||
ships = malloc(sizeof(char*));
|
||||
ships[0] = strdup("None");
|
||||
nships = 1;
|
||||
}
|
||||
|
||||
window_addList(secondary_wid, 20, 40,
|
||||
200, SHIPYARD_HEIGHT-80, "lstShipyard",
|
||||
ships, nships, 0, shipyard_update);
|
||||
@ -593,6 +600,23 @@ static void shipyard_update(char* str) {
|
||||
char buf[80], buf2[16], buf3[16];
|
||||
|
||||
shipname = toolkit_getList(secondary_wid, "lstShipyard");
|
||||
|
||||
/* No ships. */
|
||||
if(strcmp(shipname, "None")==0) {
|
||||
window_modifyImage(secondary_wid, "imgTarget", NULL);
|
||||
window_disableButton(secondary_wid, "btnBuyShip");
|
||||
window_disableButton(secondary_wid, "btnInfoShip");
|
||||
snprintf(buf, 80,
|
||||
"None\n"
|
||||
"NA\n"
|
||||
"NA\n"
|
||||
"\n"
|
||||
"NA\n"
|
||||
"NA\n");
|
||||
window_modifyText(secondary_wid, "txtDDesc", buf);
|
||||
return;
|
||||
}
|
||||
|
||||
ship = ship_get(shipname);
|
||||
|
||||
if(player_nships()==0) window_disableButton(secondary_wid, "btnYourShips");
|
||||
|
Loading…
Reference in New Issue
Block a user