Error when no capital ship found.
This commit is contained in:
parent
81a536177c
commit
33373457b2
|
@ -39,6 +39,8 @@ Entity *spawnCapitalShip(char *name, int x, int y, int side)
|
||||||
{
|
{
|
||||||
Entity *def, *e, *capitalShip;
|
Entity *def, *e, *capitalShip;
|
||||||
|
|
||||||
|
capitalShip = NULL;
|
||||||
|
|
||||||
for (def = defHead.next ; def != NULL ; def = def->next)
|
for (def = defHead.next ; def != NULL ; def = def->next)
|
||||||
{
|
{
|
||||||
if ((strcmp(def->name, name) == 0) || (def->owner != NULL && strcmp(def->owner->name, name) == 0))
|
if ((strcmp(def->name, name) == 0) || (def->owner != NULL && strcmp(def->owner->name, name) == 0))
|
||||||
|
@ -65,6 +67,12 @@ Entity *spawnCapitalShip(char *name, int x, int y, int side)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!capitalShip)
|
||||||
|
{
|
||||||
|
printf("Error: no such capital ship '%s'\n", name);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
return capitalShip;
|
return capitalShip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +332,6 @@ static void loadCapitalShipDef(char *filename)
|
||||||
|
|
||||||
STRNCPY(e->name, cJSON_GetObjectItem(root, "name")->valuestring, MAX_NAME_LENGTH);
|
STRNCPY(e->name, cJSON_GetObjectItem(root, "name")->valuestring, MAX_NAME_LENGTH);
|
||||||
STRNCPY(e->defName, e->name, MAX_NAME_LENGTH);
|
STRNCPY(e->defName, e->name, MAX_NAME_LENGTH);
|
||||||
e->health = e->maxHealth = cJSON_GetObjectItem(root, "health")->valueint;
|
|
||||||
e->shield = e->maxShield = cJSON_GetObjectItem(root, "shield")->valueint;
|
e->shield = e->maxShield = cJSON_GetObjectItem(root, "shield")->valueint;
|
||||||
e->shieldRechargeRate = cJSON_GetObjectItem(root, "shieldRechargeRate")->valueint;
|
e->shieldRechargeRate = cJSON_GetObjectItem(root, "shieldRechargeRate")->valueint;
|
||||||
e->texture = getTexture(cJSON_GetObjectItem(root, "texture")->valuestring);
|
e->texture = getTexture(cJSON_GetObjectItem(root, "texture")->valuestring);
|
||||||
|
@ -353,7 +360,7 @@ static void loadComponents(Entity *parent, cJSON *components)
|
||||||
Entity *e;
|
Entity *e;
|
||||||
cJSON *component;
|
cJSON *component;
|
||||||
|
|
||||||
parent->health = 0;
|
parent->health = 1;
|
||||||
|
|
||||||
if (components)
|
if (components)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue