From a0c2b1e9f688911095643174d011fdb3785a906e Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 24 Jul 2016 08:24:04 +0100 Subject: [PATCH] Auto select next available mission when clicking on a star system. --- src/galaxy/galacticMap.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/galaxy/galacticMap.c b/src/galaxy/galacticMap.c index 3a3b007..3017b90 100644 --- a/src/galaxy/galacticMap.c +++ b/src/galaxy/galacticMap.c @@ -47,6 +47,7 @@ static void returnFromOptions(void); static void doStarSystemView(void); static void updatePandoranAdvance(void); static void fallenOK(void); +static Mission *nextAvailableMission(StarSystem *starSystem); static StarSystem *selectedStarSystem; static SDL_Texture *background; @@ -556,11 +557,26 @@ static void selectStarSystem(void) { show = SHOW_STAR_SYSTEM; STRNCPY(game.selectedStarSystem, selectedStarSystem->name, MAX_NAME_LENGTH); - game.currentMission = selectedStarSystem->missionHead.next; + game.currentMission = nextAvailableMission(selectedStarSystem); playSound(SND_GUI_SELECT); } } +static Mission *nextAvailableMission(StarSystem *starSystem) +{ + Mission *m; + + for (m = starSystem->missionHead.next ; m != NULL ; m = m->next) + { + if (m->available && !m->completed) + { + return m; + } + } + + return starSystem->missionHead.next; +} + static void drawStarSystemDetail(void) { int y, start, i;