Challenge completion bug fix.

This commit is contained in:
Steve 2016-04-03 14:04:31 +01:00
parent f6504fc7a1
commit 16a1e1b20a
1 changed files with 50 additions and 36 deletions

View File

@ -29,7 +29,7 @@ static void updateDisabledChallenge(Challenge *c);
static void updateItemsChallenge(Challenge *c);
static void completeChallenge(void);
static void failChallenge(void);
static void updateChallenges(void);
static int updateChallenges(void);
static char *getFormattedChallengeDescription(const char *format, ...);
char *getChallengeDescription(Challenge *c);
static int challengeFinished(void);
@ -83,19 +83,21 @@ void initChallenges(void)
void doChallenges(void)
{
int passed;
if (game.currentMission->challengeData.isChallenge && battle.status == MS_IN_PROGRESS)
{
if (challengeFinished())
{
if (game.currentMission->challengeData.timeLimit && battle.stats[STAT_TIME] >= game.currentMission->challengeData.timeLimit)
passed = updateChallenges();
if (passed)
{
failChallenge();
completeChallenge();
}
else
{
updateChallenges();
completeChallenge();
failChallenge();
}
}
}
@ -147,18 +149,22 @@ static int challengeFinished(void)
return 0;
}
static void updateChallenges(void)
static int updateChallenges(void)
{
int i;
int i, numPassed;
Challenge *c;
updateAccuracyStats(battle.stats);
numPassed = 0;
for (i = 0 ; i < MAX_CHALLENGES ; i++)
{
c = game.currentMission->challengeData.challenges[i];
if (c && !c->passed)
if (c)
{
if (!c->passed)
{
switch (c->type)
{
@ -195,12 +201,20 @@ static void updateChallenges(void)
break;
}
}
if (c->passed)
{
numPassed++;
}
}
}
if (dev.debug)
{
printStats();
}
return numPassed;
}
static void printStats(void)