From 9c532352f5b0ac6e4b0f486d91cefd7b524fbb4f Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 30 Nov 2015 09:33:43 +0000 Subject: [PATCH] Allow for star systems to fall to Pandorans, once story missions are complete. --- data/galaxy/starSystems.json | 1 + src/galaxy/galacticMap.c | 5 +++++ src/galaxy/starSystems.c | 5 +++++ src/structs.h | 1 + src/system/load.c | 5 +++++ src/system/load.h | 1 + src/system/save.c | 1 + 7 files changed, 19 insertions(+) diff --git a/data/galaxy/starSystems.json b/data/galaxy/starSystems.json index 3b02100..cd5220b 100644 --- a/data/galaxy/starSystems.json +++ b/data/galaxy/starSystems.json @@ -156,6 +156,7 @@ "side" : "SIDE_UNF", "x": 325, "y": 385, + "fallsToPandorans" : 1, "missions" : [ "data/missions/coyote/01 - coyote assault #1.json", "data/missions/coyote/02 - coyote assault #2.json", diff --git a/src/galaxy/galacticMap.c b/src/galaxy/galacticMap.c index 5047971..444df30 100644 --- a/src/galaxy/galacticMap.c +++ b/src/galaxy/galacticMap.c @@ -176,6 +176,11 @@ static void doStarSystems(void) } } } + + if (starSystem->side != SIDE_PANDORAN && starSystem->fallsToPandorans && starSystem->completedMissions == starSystem->totalMissions && starSystem->totalMissions > 0) + { + starSystem->side = SIDE_PANDORAN; + } } } diff --git a/src/galaxy/starSystems.c b/src/galaxy/starSystems.c index 003f4a8..8b55518 100644 --- a/src/galaxy/starSystems.c +++ b/src/galaxy/starSystems.c @@ -55,6 +55,11 @@ static void loadStarSystem(cJSON *starSystemJSON) starSystem->x = cJSON_GetObjectItem(starSystemJSON, "x")->valueint; starSystem->y = cJSON_GetObjectItem(starSystemJSON, "y")->valueint; + if (cJSON_GetObjectItem(starSystemJSON, "fallsToPandorans")) + { + starSystem->fallsToPandorans = cJSON_GetObjectItem(starSystemJSON, "fallsToPandorans")->valueint; + } + starSystem->missionHead.completed = 1; starSystem->missionTail = &starSystem->missionHead; diff --git a/src/structs.h b/src/structs.h index c45391b..ea7cdc6 100644 --- a/src/structs.h +++ b/src/structs.h @@ -214,6 +214,7 @@ struct StarSystem { int y; int completedMissions; int totalMissions; + int fallsToPandorans; Mission missionHead, *missionTail; StarSystem *next; }; diff --git a/src/system/load.c b/src/system/load.c index 79bab6c..3dbc458 100644 --- a/src/system/load.c +++ b/src/system/load.c @@ -47,10 +47,15 @@ void loadGame(void) static void loadStarSystems(cJSON *starSystemsJSON) { + StarSystem *starSystem; cJSON *starSystemJSON; for (starSystemJSON = starSystemsJSON->child ; starSystemJSON != NULL ; starSystemJSON = starSystemJSON->next) { + starSystem = getStarSystem(cJSON_GetObjectItem(starSystemJSON, "name")->valuestring); + + starSystem->side = lookup(cJSON_GetObjectItem(starSystemJSON, "side")->valuestring); + loadMissions(cJSON_GetObjectItem(starSystemJSON, "missions")); } } diff --git a/src/system/load.h b/src/system/load.h index 19d1c77..91963c4 100644 --- a/src/system/load.h +++ b/src/system/load.h @@ -30,5 +30,6 @@ extern Challenge *getChallenge(Mission *mission, int type); extern int lookup(char *lookup); extern char *getSaveFilePath(char *filename); extern char *getLookupName(char *prefix, long num); +extern StarSystem *getStarSystem(char *name); extern Game game; diff --git a/src/system/save.c b/src/system/save.c index bf16617..2205082 100644 --- a/src/system/save.c +++ b/src/system/save.c @@ -62,6 +62,7 @@ static void saveStarSystems(cJSON *gameJSON) starSystemJSON = cJSON_CreateObject(); cJSON_AddStringToObject(starSystemJSON, "name", starSystem->name); + cJSON_AddStringToObject(starSystemJSON, "side", getLookupName("SIDE_", starSystem->side)); cJSON_AddItemToObject(starSystemJSON, "missions", getMissionsJSON(starSystem)); cJSON_AddItemToArray(starSystemsJSON, starSystemJSON);