From 43fef1a59bb9e24b77f59c4de9e3f377074cc8a8 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 24 Jul 2025 19:36:24 +0100 Subject: [PATCH] Replace the Playground Hack with a specific fix via a case that needed its own function --- src/g_game.c | 2 +- src/k_menufunc.c | 13 +++---------- src/m_cond.c | 21 +++++++++++++++++++++ src/m_cond.h | 1 + src/menus/main-1.c | 2 +- src/menus/transient/pause-game.c | 2 +- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index ab7df4954..71e8918fa 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -5130,7 +5130,7 @@ void G_EndGame(void) return; } - if (gametype == GT_TUTORIAL && M_GameTrulyStarted() && restoreMenu == NULL) + if (gametype == GT_TUTORIAL && M_GameAboutToStart() && restoreMenu == NULL) { // Playground Hack F_StartIntro(); diff --git a/src/k_menufunc.c b/src/k_menufunc.c index be6dcc2a3..9c0ff5039 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -829,17 +829,10 @@ void M_StartControlPanel(void) if (gamedata != NULL && gamedata->gonerlevel < GDGONER_OUTRO - && gamestartchallenge < MAXUNLOCKABLES) + && M_GameAboutToStart()) { - // See M_GameTrulyStarted - if ( - gamedata->unlockpending[gamestartchallenge] - || gamedata->unlocked[gamestartchallenge] - ) - { - gamedata->gonerlevel = GDGONER_OUTRO; - M_GonerBGImplyPassageOfTime(); - } + gamedata->gonerlevel = GDGONER_OUTRO; + M_GonerBGImplyPassageOfTime(); } if (M_GameTrulyStarted() == false) diff --git a/src/m_cond.c b/src/m_cond.c index 81908d533..f113cda42 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -3475,6 +3475,27 @@ boolean M_GameTrulyStarted(void) return (gamedata->gonerlevel == GDGONER_DONE); } +boolean M_GameAboutToStart(void) +{ + // Fail safe + if (gamedata == NULL) + return false; + + // Not set + if (gamestartchallenge >= MAXUNLOCKABLES) + return true; + + // An unfortunate sidestep, but sync is important. + if (netgame) + return true; + + // Pending unlocked, but not unlocked + return ( + gamedata->unlockpending[gamestartchallenge] + && !gamedata->unlocked[gamestartchallenge] + ); +} + boolean M_CheckNetUnlockByID(UINT16 unlockid) { if (unlockid >= MAXUNLOCKABLES diff --git a/src/m_cond.h b/src/m_cond.h index f636b9515..09175e8b3 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -472,6 +472,7 @@ extern UINT16 gamestartchallenge; boolean M_CheckNetUnlockByID(UINT16 unlockid); boolean M_SecretUnlocked(INT32 type, boolean local); boolean M_GameTrulyStarted(void); +boolean M_GameAboutToStart(void); boolean M_CupLocked(cupheader_t *cup); boolean M_CupSecondRowLocked(void); boolean M_MapLocked(UINT16 mapnum); diff --git a/src/menus/main-1.c b/src/menus/main-1.c index f055358dc..3a913427e 100644 --- a/src/menus/main-1.c +++ b/src/menus/main-1.c @@ -101,7 +101,7 @@ void M_QuitSRB2(INT32 choice) (void)choice; - if (M_GameTrulyStarted()) + if (!M_GameAboutToStart() && M_GameTrulyStarted()) { INT32 mrand = M_RandomKey(sizeof(quitsounds) / sizeof(INT32)); if (quitsounds[mrand]) diff --git a/src/menus/transient/pause-game.c b/src/menus/transient/pause-game.c index 8ed0078ed..c94be64a1 100644 --- a/src/menus/transient/pause-game.c +++ b/src/menus/transient/pause-game.c @@ -562,7 +562,7 @@ void M_EndGame(INT32 choice) return; if (M_GameTrulyStarted() == false - || (gametype == GT_TUTORIAL && restoreMenu == NULL)) // Playground Hack + || M_GameAboutToStart() == true) // Playground Hack { // No returning to the title screen. M_QuitSRB2(-1);