From 146bd1ef45e17fcdc4d5b96cdbdf6dffa0dd9175 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 29 Nov 2015 12:56:15 +0000 Subject: [PATCH] Made name option for fighters. --- src/galaxy/mission.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index 6c90e7a..428d944 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -206,6 +206,7 @@ static void loadFighters(cJSON *node) while (node) { + name = NULL; groupName = NULL; flags = -1; scatter = 1; @@ -214,10 +215,14 @@ static void loadFighters(cJSON *node) types = toFighterTypeArray(cJSON_GetObjectItem(node, "types")->valuestring, &numTypes); side = lookup(cJSON_GetObjectItem(node, "side")->valuestring); - name = cJSON_GetObjectItem(node, "name")->valuestring; x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH; y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT; + if (cJSON_GetObjectItem(node, "name")) + { + name = cJSON_GetObjectItem(node, "name")->valuestring; + } + if (cJSON_GetObjectItem(node, "groupName")) { groupName = cJSON_GetObjectItem(node, "groupName")->valuestring; @@ -259,7 +264,10 @@ static void loadFighters(cJSON *node) f->flags = flags; } - STRNCPY(f->name, name, MAX_NAME_LENGTH); + if (name) + { + STRNCPY(f->name, name, MAX_NAME_LENGTH); + } if (groupName) {