M_GetNextAchievedUnlock: Skip over adding Chao Keys if you've already unlocked everything

I considered restricting it even further to "unlock every minor unlock that can be unlocked by a Chao Key", but decided that if you haven't "completed the game" yet, you should still be periodically reminded of it.
This commit is contained in:
toaster 2023-06-09 16:42:44 +01:00
parent da1e865e8b
commit bf5aa4b5d8
3 changed files with 21 additions and 6 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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);