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;