diff --git a/src/m_cond.c b/src/m_cond.c index d818e0ee5..c0dd67e60 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -1780,32 +1780,47 @@ boolean M_UpdateUnlockablesAndExtraEmblems(boolean loud, boolean doall) return false; } -UINT16 M_GetNextAchievedUnlock(void) +UINT16 M_GetNextAchievedUnlock(boolean canskipchaokeys) { UINT16 i; // Go through unlockables for (i = 0; i < MAXUNLOCKABLES; ++i) { - if (gamedata->unlocked[i] || !unlockables[i].conditionset) + if (!unlockables[i].conditionset) { + // Not worthy of consideration continue; } if (gamedata->unlocked[i] == true) { + // Already unlocked, no need to engage continue; } if (gamedata->unlockpending[i] == false) { + // Not unlocked AND not pending, which means chao keys can be used on something + canskipchaokeys = false; continue; } return i; } - if (gamedata->keyspending != 0) + if (canskipchaokeys == true) + { + // Okay, we're skipping chao keys - let's just insta-digest them. + gamedata->chaokeys += gamedata->keyspending; + gamedata->pendingkeyroundoffset = + (gamedata->pendingkeyroundoffset + gamedata->pendingkeyrounds) + % GDCONVERT_ROUNDSTOKEY; + + gamedata->keyspending = 0; + gamedata->pendingkeyrounds = 0; + } + else if (gamedata->keyspending != 0) { return PENDING_CHAOKEYS; } diff --git a/src/m_cond.h b/src/m_cond.h index 2db467e2a..beb12d039 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -347,7 +347,7 @@ boolean M_CheckCondition(condition_t *cn, player_t *player); boolean M_UpdateUnlockablesAndExtraEmblems(boolean loud, boolean doall); #define PENDING_CHAOKEYS (UINT16_MAX-1) -UINT16 M_GetNextAchievedUnlock(void); +UINT16 M_GetNextAchievedUnlock(boolean canskipchaokeys); UINT16 M_CheckLevelEmblems(void); UINT16 M_CompletionEmblems(void); diff --git a/src/menus/extras-challenges.c b/src/menus/extras-challenges.c index 51cddb8a1..8b8409141 100644 --- a/src/menus/extras-challenges.c +++ b/src/menus/extras-challenges.c @@ -212,7 +212,7 @@ menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu) M_UpdateUnlockablesAndExtraEmblems(false, true); - newunlock = M_GetNextAchievedUnlock(); + newunlock = M_GetNextAchievedUnlock(true); if ((challengesmenu.pending = (newunlock != MAXUNLOCKABLES))) { @@ -457,7 +457,7 @@ void M_ChallengesTick(void) { // The menu apparatus is requesting a new unlock. challengesmenu.requestnew = false; - if ((newunlock = M_GetNextAchievedUnlock()) != MAXUNLOCKABLES) + if ((newunlock = M_GetNextAchievedUnlock(false)) != MAXUNLOCKABLES) { // We got one! M_ChallengesAutoFocus(newunlock, false);