From 8efd4788e7cde06a69400f1790d75d5e27283bbe Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 7 Jun 2023 23:05:19 +0100 Subject: [PATCH] enum gdmusic_t Replaces existing musicflag system, which only had one flag, with a priority system that overrides menu music in general. Also adds the CHAO KEY FREE DDL WORKING 2023 goofy music for matchesplayed Chao Key generation. --- src/k_menufunc.c | 24 +++++++++++++++++------- src/m_cond.c | 11 +++++++++-- src/m_cond.h | 11 +++++++++-- src/p_setup.c | 2 +- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 2c2bf3d40..e04675fb2 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -372,18 +372,19 @@ boolean M_Responder(event_t *ev) void M_PlayMenuJam(void) { menu_t *refMenu = (menuactive ? currentMenu : restoreMenu); - static boolean loserclubpermitted = false; - boolean loserclub = (loserclubpermitted && (gamedata->musicflags & GDMUSIC_LOSERCLUB)); + static boolean musicstatepermitted = false; if (challengesmenu.pending) { S_StopMusic(); S_StopMusicCredit(); - loserclubpermitted = true; + musicstatepermitted = true; return; } + gdmusic_t override = musicstatepermitted ? gamedata->musicstate : 0; + if (Playing() || soundtest.playing) return; @@ -395,7 +396,7 @@ void M_PlayMenuJam(void) S_StopMusicCredit(); return; } - else if (!loserclub) + else if (override == 0) { if (NotCurrentlyPlaying(refMenu->music)) { @@ -406,12 +407,21 @@ void M_PlayMenuJam(void) } } - if (loserclub) + if (override != 0) { - if (refMenu != NULL && NotCurrentlyPlaying("LOSERC")) + // See also gdmusic_t + const char* overridetotrack[GDMUSIC_MAX-1] = { + "KEYGEN", + "LOSERC", + }; + + if (refMenu != NULL && NotCurrentlyPlaying(overridetotrack[override - 1])) { - S_ChangeMusicInternal("LOSERC", true); + S_ChangeMusicInternal(overridetotrack[override - 1], true); S_ShowMusicCredit(); + + if (override < GDMUSIC_KEEPONMENU) + gamedata->musicstate = GDMUSIC_NONE; } return; diff --git a/src/m_cond.c b/src/m_cond.c index eca1b5433..d818e0ee5 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -613,7 +613,7 @@ void M_ClearStats(void) gamedata->eversavedreplay = false; gamedata->everseenspecial = false; gamedata->evercrashed = false; - gamedata->musicflags = 0; + gamedata->musicstate = GDMUSIC_NONE; gamedata->importprofilewins = false; } @@ -840,7 +840,8 @@ boolean M_CheckCondition(condition_t *cn, player_t *player) case UC_CRASH: if (gamedata->evercrashed) { - gamedata->musicflags |= GDMUSIC_LOSERCLUB; + if (gamedata->musicstate < GDMUSIC_LOSERCLUB) + gamedata->musicstate = GDMUSIC_LOSERCLUB; return true; } return false; @@ -1710,7 +1711,13 @@ boolean M_UpdateUnlockablesAndExtraEmblems(boolean loud, boolean doall) { gamedata->keyspending++; newkeys++; + } + + if (newkeys != 0) + { response |= true; + if (gamedata->musicstate < GDMUSIC_KEYG) + gamedata->musicstate = GDMUSIC_KEYG; } } diff --git a/src/m_cond.h b/src/m_cond.h index c178b2f5d..2db467e2a 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -220,7 +220,14 @@ typedef enum #endif #define challengegridloops (gamedata->challengegridwidth >= CHALLENGEGRIDLOOPWIDTH) -#define GDMUSIC_LOSERCLUB 0x01 +// See also M_PlayMenuJam +typedef enum { + GDMUSIC_NONE = 0, + GDMUSIC_KEYG, + GDMUSIC_KEEPONMENU, // Minimum to keep after leaving the Challenge Grid + GDMUSIC_LOSERCLUB = GDMUSIC_KEEPONMENU, + GDMUSIC_MAX +} gdmusic_t; // This is the largest number of 9s that will fit in UINT32 and UINT16 respectively. #define GDMAX_RINGS 999999999 @@ -283,7 +290,7 @@ struct gamedata_t boolean eversavedreplay; boolean everseenspecial; boolean evercrashed; - UINT8 musicflags; + gdmusic_t musicstate; // BACKWARDS COMPAT ASSIST boolean importprofilewins; diff --git a/src/p_setup.c b/src/p_setup.c index 023f31773..b082ad037 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -7813,7 +7813,7 @@ static void P_InitGametype(void) // Started a game? Move on to the next jam when you go back to the title screen CV_SetValue(&cv_menujam_update, 1); - gamedata->musicflags = 0; + gamedata->musicstate = GDMUSIC_NONE; } struct minimapinfo minimapinfo;