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,38 +133,22 @@ void updateStarSystemMissions(void)
{
StarSystem *starSystem;
Mission *mission, *prev;
int numOptional, completedOptional;
game.completedMissions = game.totalMissions = game.availableMissions = 0;
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)
{
starSystem->totalMissions++;
if (mission->completed)
if (starSystem->type == SS_NORMAL && !mission->isOptional)
{
starSystem->completedMissions++;
game.totalMissions++;
game.completedMissions++;
}
if (mission->isOptional && starSystem->type == SS_NORMAL)
{
numOptional++;
if (mission->completed)
{
completedOptional++;
}
}
}
if (starSystem->type == SS_NORMAL)
{
game.totalMissions += (starSystem->totalMissions - numOptional);
game.completedMissions += (starSystem->completedMissions - completedOptional);
}
}
@ -180,22 +164,28 @@ void updateStarSystemMissions(void)
{
starSystem->availableMissions++;
if (!mission->completed)
if (mission->completed)
{
starSystem->completedMissions++;
}
else
{
starSystem->activeMission = mission;
}
if (starSystem->type == SS_NORMAL && !mission->isOptional)
{
game.availableMissions++;
}
}
prev = mission;
}
if (starSystem->type == SS_NORMAL)
{
game.availableMissions += 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)