From 0116202471636a73d133377792f1cfc6a1051386 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 15 May 2016 10:50:09 +0100 Subject: [PATCH] Use type in Star System instead of isSol, to allow for special Pandoran missions. --- src/defs.h | 4 ++++ src/galaxy/galacticMap.c | 44 +++++++++++++++++++++++++--------------- src/galaxy/starSystems.c | 10 +++++---- src/game/stats.c | 2 +- src/structs.h | 2 +- 5 files changed, 40 insertions(+), 22 deletions(-) diff --git a/src/defs.h b/src/defs.h index 5aab531..1833d95 100644 --- a/src/defs.h +++ b/src/defs.h @@ -139,6 +139,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MB_IMPORTANT 1 #define MB_PANDORAN 2 +#define SS_NORMAL 0 +#define SS_SOL 1 +#define SS_PANDORAN 2 + enum { CONTROL_FIRE, diff --git a/src/galaxy/galacticMap.c b/src/galaxy/galacticMap.c index b54cef1..c67d0b9 100644 --- a/src/galaxy/galacticMap.c +++ b/src/galaxy/galacticMap.c @@ -299,16 +299,22 @@ static void addPulses(void) pulse->x = starSystem->x; pulse->y = starSystem->y; pulse->life = 255; - - if (!starSystem->isSol) + + switch (starSystem->type) { - pulse->r = 255; + case SS_NORMAL: + pulse->r = 255; + break; + + case SS_SOL: + pulse->g = 255; + break; + + case SS_PANDORAN: + pulse->b = 255; + break; } - else - { - pulse->g = 255; - } - + pulseTail->next = pulse; pulseTail = pulse; } @@ -462,15 +468,21 @@ static void drawGalaxy(void) if (aa != -1) { - if (!starSystem->isSol) + switch (starSystem->type) { - SDL_SetTextureColorMod(arrowTexture, 255, 0, 0); + case SS_NORMAL: + SDL_SetTextureColorMod(arrowTexture, 255, 0, 0); + break; + + case SS_SOL: + SDL_SetTextureColorMod(arrowTexture, 0, 255, 0); + break; + + case SS_PANDORAN: + SDL_SetTextureColorMod(arrowTexture, 0, 0, 255); + break; } - else - { - SDL_SetTextureColorMod(arrowTexture, 0, 255, 0); - } - + blitRotated(arrowTexture, ax, ay, aa); } } @@ -593,7 +605,7 @@ static void drawStarSystemDetail(void) drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.yellow, _("Note: this is an Epic Mission.")); } - startMissionButton->enabled = (!game.currentMission->completed || selectedStarSystem->isSol); + startMissionButton->enabled = (!game.currentMission->completed || selectedStarSystem->type == SS_SOL); drawWidgets("starSystem"); } diff --git a/src/galaxy/starSystems.c b/src/galaxy/starSystems.c index ad8bc8a..29db419 100644 --- a/src/galaxy/starSystems.c +++ b/src/galaxy/starSystems.c @@ -57,10 +57,12 @@ static StarSystem *loadStarSystem(cJSON *starSystemJSON) starSystem->x = cJSON_GetObjectItem(starSystemJSON, "x")->valueint; starSystem->y = cJSON_GetObjectItem(starSystemJSON, "y")->valueint; starSystem->fallsToPandorans = getJSONValue(starSystemJSON, "fallsToPandorans", 0); + + starSystem->type = (starSystem->side != SIDE_PANDORAN) ? SS_NORMAL : SS_PANDORAN; if (strcmp(starSystem->name, "Sol") == 0) { - starSystem->isSol = 1; + starSystem->type = SS_SOL; } starSystem->missionHead.completed = 1; @@ -148,7 +150,7 @@ void updateStarSystemMissions(void) } } - if (!starSystem->isSol) + if (starSystem->type == SS_NORMAL) { game.totalMissions += starSystem->totalMissions; game.completedMissions += starSystem->completedMissions; @@ -161,7 +163,7 @@ void updateStarSystemMissions(void) for (mission = starSystem->missionHead.next ; mission != NULL ; mission = mission->next) { - mission->available = starSystem->isSol || isMissionAvailable(mission, prev); + mission->available = starSystem->type == SS_SOL || isMissionAvailable(mission, prev); if (mission->available) { @@ -171,7 +173,7 @@ void updateStarSystemMissions(void) prev = mission; } - if (!starSystem->isSol) + if (starSystem->type == SS_NORMAL) { game.availableMissions += starSystem->availableMissions; } diff --git a/src/game/stats.c b/src/game/stats.c index 9e6732d..930e4e9 100644 --- a/src/game/stats.c +++ b/src/game/stats.c @@ -103,7 +103,7 @@ static void calculatePercentComplete(void) for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next) { - if (!starSystem->isSol) + if (starSystem->type == SS_NORMAL) { completed += starSystem->completedMissions; total += starSystem->totalMissions; diff --git a/src/structs.h b/src/structs.h index eb75e2d..52e10f1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -297,7 +297,7 @@ struct StarSystem { int totalMissions; int availableMissions; int fallsToPandorans; - int isSol; + int type; Mission missionHead; StarSystem *next; };