Reworked mission progress counting.

This commit is contained in:
Steve 2016-08-11 18:06:42 +01:00
parent 9f1b759c33
commit 3aad3142ac
1 changed files with 16 additions and 26 deletions

View File

@ -133,39 +133,23 @@ void updateStarSystemMissions(void)
{ {
StarSystem *starSystem; StarSystem *starSystem;
Mission *mission, *prev; Mission *mission, *prev;
int numOptional, completedOptional;
game.completedMissions = game.totalMissions = game.availableMissions = 0; game.completedMissions = game.totalMissions = game.availableMissions = 0;
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next) for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
{ {
numOptional = completedOptional = starSystem->completedMissions = starSystem->availableMissions = starSystem->totalMissions = 0; starSystem->completedMissions = starSystem->availableMissions = starSystem->totalMissions = 0;
for (mission = starSystem->missionHead.next ; mission != NULL ; mission = mission->next) for (mission = starSystem->missionHead.next ; mission != NULL ; mission = mission->next)
{ {
starSystem->totalMissions++; starSystem->totalMissions++;
if (mission->completed)
{
starSystem->completedMissions++;
}
if (mission->isOptional && starSystem->type == SS_NORMAL) if (starSystem->type == SS_NORMAL && !mission->isOptional)
{ {
numOptional++; game.totalMissions++;
game.completedMissions++;
if (mission->completed)
{
completedOptional++;
}
} }
} }
if (starSystem->type == SS_NORMAL)
{
game.totalMissions += (starSystem->totalMissions - numOptional);
game.completedMissions += (starSystem->completedMissions - completedOptional);
}
} }
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next) for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
@ -180,22 +164,28 @@ void updateStarSystemMissions(void)
{ {
starSystem->availableMissions++; starSystem->availableMissions++;
if (!mission->completed) if (mission->completed)
{
starSystem->completedMissions++;
}
else
{ {
starSystem->activeMission = mission; starSystem->activeMission = mission;
} }
if (starSystem->type == SS_NORMAL && !mission->isOptional)
{
game.availableMissions++;
}
} }
prev = mission; prev = mission;
} }
if (starSystem->type == SS_NORMAL)
{
game.availableMissions += starSystem->availableMissions;
}
sprintf(starSystem->description, "[ %s ] [ Missions %d / %d ]", starSystem->name, starSystem->completedMissions, starSystem->availableMissions); sprintf(starSystem->description, "[ %s ] [ Missions %d / %d ]", starSystem->name, starSystem->completedMissions, starSystem->availableMissions);
} }
printf("completed=%d, available=%d, total=%d\n", game.completedMissions, game.availableMissions, game.totalMissions);
} }
void destroyStarSystems(void) void destroyStarSystems(void)