diff --git a/src/battle/battle.c b/src/battle/battle.c index 3dacb1e..e5f6689 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -375,11 +375,6 @@ static void postBattle(void) if (game.currentMission && !game.currentMission->completed) { game.currentMission->completed = (battle.status == MS_COMPLETE || !battle.numObjectivesTotal); - - if (game.currentMission->completed && game.currentMission->trophyId) - { - awardTrophy(game.currentMission->trophyId); - } } } } diff --git a/src/galaxy/galacticMap.c b/src/galaxy/galacticMap.c index 789da5b..2fbcd20 100644 --- a/src/galaxy/galacticMap.c +++ b/src/galaxy/galacticMap.c @@ -88,7 +88,9 @@ void initGalacticMap(void) updatePandoranAdvance(); - checkStatTrophies(); + awardCampaignTrophies(); + + awardStatsTrophies(); saveGame(); diff --git a/src/galaxy/galacticMap.h b/src/galaxy/galacticMap.h index 12e982a..ca97173 100644 --- a/src/galaxy/galacticMap.h +++ b/src/galaxy/galacticMap.h @@ -62,7 +62,8 @@ extern char *getTranslatedString(char *string); extern void clearInput(void); extern void doTrophies(void); extern void drawTrophyAlert(void); -extern void checkStatTrophies(void); +extern void awardCampaignTrophies(void); +extern void awardStatsTrophies(void); extern App app; extern Colors colors; diff --git a/src/game/trophies.c b/src/game/trophies.c index bed47f3..0fb2f7d 100644 --- a/src/game/trophies.c +++ b/src/game/trophies.c @@ -174,7 +174,7 @@ static void loadTrophyData(char *filename) free(text); } -void checkStatTrophies(void) +void awardStatsTrophies(void) { Trophy *t; @@ -188,3 +188,34 @@ void checkStatTrophies(void) } } } + +void awardCampaignTrophies(void) +{ + char trophyId[MAX_NAME_LENGTH]; + char name[MAX_NAME_LENGTH]; + int completedMissions, i, len; + StarSystem *ss; + + /* check % of missions completed */ + completedMissions = (int)getPercent(game.completedMissions, game.totalMissions); + sprintf(trophyId, "CAMPAIGN_%d", completedMissions); + awardTrophy(trophyId); + + /* check if all star system missions are completed */ + for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next) + { + if (starSystem->totalMissions && starSystem->completedMissions == starSystem->totalMissions) + { + memset(name, '\0', MAX_NAME_LENGTH); + + len = strlen(starSystem->name); + + for (i = 0 ; i < len ; i++) + { + name[i] = toupper(starSystem->name[i]); + } + sprintf(trophyId, "CAMPAIGN_%s", name); + awardTrophy(trophyId); + } + } +}