Allow for star systems to fall to Pandorans, once story missions are complete.

This commit is contained in:
Steve 2015-11-30 09:33:43 +00:00
parent 2dd5c66f03
commit 9c532352f5
7 changed files with 19 additions and 0 deletions

View File

@ -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",

View File

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

View File

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

View File

@ -214,6 +214,7 @@ struct StarSystem {
int y;
int completedMissions;
int totalMissions;
int fallsToPandorans;
Mission missionHead, *missionTail;
StarSystem *next;
};

View File

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

View File

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

View File

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