Don't save star systems that don't have any missions.

This commit is contained in:
Steve 2016-05-04 10:27:16 +01:00
parent 4a2908cf6e
commit eb225fefc9
1 changed files with 8 additions and 5 deletions

View File

@ -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);