diff --git a/src/menus/extras-challenges.c b/src/menus/extras-challenges.c index 4190211bc..c5c52cb66 100644 --- a/src/menus/extras-challenges.c +++ b/src/menus/extras-challenges.c @@ -47,51 +47,6 @@ menu_t MISC_StatisticsDef = { struct challengesmenu_s challengesmenu; -menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu) -{ - UINT8 i; - - M_UpdateUnlockablesAndExtraEmblems(false); - - if ((challengesmenu.pending = challengesmenu.requestnew = (M_GetNextAchievedUnlock() < MAXUNLOCKABLES))) - { - MISC_ChallengesDef.prevMenu = desiredmenu; - } - - if (challengesmenu.pending || desiredmenu == NULL) - { - challengesmenu.currentunlock = MAXUNLOCKABLES; - challengesmenu.unlockcondition = NULL; - - M_PopulateChallengeGrid(); - if (gamedata->challengegrid) - challengesmenu.extradata = M_ChallengeGridExtraData(); - - memset(setup_explosions, 0, sizeof(setup_explosions)); - memset(&challengesmenu.unlockcount, 0, sizeof(challengesmenu.unlockcount)); - for (i = 0; i < MAXUNLOCKABLES; i++) - { - if (!unlockables[i].conditionset) - { - continue; - } - - challengesmenu.unlockcount[CC_TOTAL]++; - - if (!gamedata->unlocked[i]) - { - continue; - } - - challengesmenu.unlockcount[CC_UNLOCKED]++; - } - - return &MISC_ChallengesDef; - } - - return desiredmenu; -} - static void M_ChallengesAutoFocus(UINT8 unlockid, boolean fresh) { UINT8 i; @@ -196,6 +151,56 @@ static void M_ChallengesAutoFocus(UINT8 unlockid, boolean fresh) } } +menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu) +{ + UINT8 i; + UINT16 newunlock = M_GetNextAchievedUnlock(); + + M_UpdateUnlockablesAndExtraEmblems(false); + + if ((challengesmenu.pending = (newunlock < MAXUNLOCKABLES))) + { + MISC_ChallengesDef.prevMenu = desiredmenu; + } + + if (challengesmenu.pending || desiredmenu == NULL) + { + challengesmenu.requestnew = false; + challengesmenu.currentunlock = MAXUNLOCKABLES; + challengesmenu.unlockcondition = NULL; + + M_PopulateChallengeGrid(); + if (gamedata->challengegrid) + challengesmenu.extradata = M_ChallengeGridExtraData(); + + memset(setup_explosions, 0, sizeof(setup_explosions)); + memset(&challengesmenu.unlockcount, 0, sizeof(challengesmenu.unlockcount)); + for (i = 0; i < MAXUNLOCKABLES; i++) + { + if (!unlockables[i].conditionset) + { + continue; + } + + challengesmenu.unlockcount[CC_TOTAL]++; + + if (!gamedata->unlocked[i]) + { + continue; + } + + challengesmenu.unlockcount[CC_UNLOCKED]++; + } + + if (challengesmenu.pending) + M_ChallengesAutoFocus(newunlock, true); + + return &MISC_ChallengesDef; + } + + return desiredmenu; +} + void M_Challenges(INT32 choice) { UINT8 i; @@ -249,7 +254,6 @@ void M_ChallengesTick(void) { const UINT8 pid = 0; UINT8 i, newunlock = MAXUNLOCKABLES; - boolean fresh = (challengesmenu.currentunlock >= MAXUNLOCKABLES); // Ticking challengesmenu.ticker++; @@ -274,7 +278,7 @@ void M_ChallengesTick(void) if ((newunlock = M_GetNextAchievedUnlock()) < MAXUNLOCKABLES) { // We got one! - M_ChallengesAutoFocus(newunlock, fresh); + M_ChallengesAutoFocus(newunlock, false); } else {