mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-25 19:43:22 +00:00
extras-challenges: Clean up open and close
- Dedicated function for cleaning up Challenges Menu memory
- Adjust the required function slate to open Challenges menu without malformed data
- Permits it to be used with restoreMenu, where it would silently infinitely loop before
This commit is contained in:
parent
7c7bfe6054
commit
248541833a
1 changed files with 26 additions and 19 deletions
|
|
@ -375,10 +375,13 @@ menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu)
|
|||
if ((challengesmenu.pending = (newunlock != MAXUNLOCKABLES)))
|
||||
{
|
||||
Music_StopAll();
|
||||
MISC_ChallengesDef.prevMenu = desiredmenu;
|
||||
if (desiredmenu && desiredmenu != &MISC_ChallengesDef)
|
||||
{
|
||||
MISC_ChallengesDef.prevMenu = desiredmenu;
|
||||
}
|
||||
}
|
||||
|
||||
if (challengesmenu.pending || desiredmenu == NULL)
|
||||
if (challengesmenu.pending || desiredmenu == &MISC_ChallengesDef)
|
||||
{
|
||||
static boolean firstopen = true;
|
||||
|
||||
|
|
@ -413,9 +416,14 @@ menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu)
|
|||
|
||||
if (challengesmenu.pending)
|
||||
M_ChallengesAutoFocus(newunlock, true);
|
||||
else if (newunlock >= MAXUNLOCKABLES && gamedata->pendingkeyrounds > 0
|
||||
&& (gamedata->chaokeys < GDMAX_CHAOKEYS))
|
||||
challengesmenu.chaokeyadd = true;
|
||||
else
|
||||
{
|
||||
if (newunlock >= MAXUNLOCKABLES && gamedata->pendingkeyrounds > 0
|
||||
&& (gamedata->chaokeys < GDMAX_CHAOKEYS))
|
||||
challengesmenu.chaokeyadd = true;
|
||||
|
||||
M_ChallengesAutoFocus(UINT16_MAX, true);
|
||||
}
|
||||
|
||||
M_CacheChallengeTiles();
|
||||
|
||||
|
|
@ -429,17 +437,23 @@ void M_Challenges(INT32 choice)
|
|||
{
|
||||
(void)choice;
|
||||
|
||||
M_InterruptMenuWithChallenges(NULL);
|
||||
M_InterruptMenuWithChallenges(&MISC_ChallengesDef);
|
||||
MISC_ChallengesDef.prevMenu = currentMenu;
|
||||
|
||||
if (gamedata->challengegrid != NULL && !challengesmenu.pending)
|
||||
{
|
||||
M_ChallengesAutoFocus(UINT16_MAX, true);
|
||||
}
|
||||
|
||||
M_SetupNextMenu(&MISC_ChallengesDef, false);
|
||||
}
|
||||
|
||||
static void M_CloseChallenges(void)
|
||||
{
|
||||
Music_Stop("challenge_altmusic");
|
||||
|
||||
Z_Free(challengesmenu.extradata);
|
||||
challengesmenu.extradata = NULL;
|
||||
|
||||
Z_Free(challengesmenu.unlockcondition);
|
||||
challengesmenu.unlockcondition = NULL;
|
||||
}
|
||||
|
||||
boolean M_CanKeyHiliTile(void)
|
||||
{
|
||||
// No tile data?
|
||||
|
|
@ -954,19 +968,12 @@ boolean M_ChallengesInputs(INT32 ch)
|
|||
{
|
||||
if (M_MenuBackPressed(pid) || start)
|
||||
{
|
||||
Music_Stop("challenge_altmusic");
|
||||
|
||||
currentMenu->prevMenu = M_SpecificMenuRestore(currentMenu->prevMenu);
|
||||
|
||||
M_GoBack(0);
|
||||
M_SetMenuDelay(pid);
|
||||
|
||||
Z_Free(challengesmenu.extradata);
|
||||
challengesmenu.extradata = NULL;
|
||||
|
||||
if (challengesmenu.unlockcondition)
|
||||
Z_Free(challengesmenu.unlockcondition);
|
||||
challengesmenu.unlockcondition = NULL;
|
||||
M_CloseChallenges();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue