From eb225fefc9833763bc52e199125c54d0e29d63d2 Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 4 May 2016 10:27:16 +0100 Subject: [PATCH] Don't save star systems that don't have any missions. --- src/system/save.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/system/save.c b/src/system/save.c index 0c85c32..83ce48b 100644 --- a/src/system/save.c +++ b/src/system/save.c @@ -64,13 +64,16 @@ static void saveStarSystems(cJSON *gameJSON) for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next) { - starSystemJSON = cJSON_CreateObject(); + if (starSystem->totalMissions > 0) + { + starSystemJSON = cJSON_CreateObject(); - cJSON_AddStringToObject(starSystemJSON, "name", starSystem->name); - cJSON_AddStringToObject(starSystemJSON, "side", getLookupName("SIDE_", starSystem->side)); - cJSON_AddItemToObject(starSystemJSON, "missions", getMissionsJSON(starSystem)); + cJSON_AddStringToObject(starSystemJSON, "name", starSystem->name); + cJSON_AddStringToObject(starSystemJSON, "side", getLookupName("SIDE_", starSystem->side)); + cJSON_AddItemToObject(starSystemJSON, "missions", getMissionsJSON(starSystem)); - cJSON_AddItemToArray(starSystemsJSON, starSystemJSON); + cJSON_AddItemToArray(starSystemsJSON, starSystemJSON); + } } cJSON_AddItemToObject(gameJSON, "starSystems", starSystemsJSON);