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