Attract: fix attract demos end handling

Fixes two bugs:

- Attract mode carrying over to gameplay if an attract
  demo is allowed to finish without interrupting it
- Credits ending after the first replay ends
This commit is contained in:
James R 2024-03-18 01:02:48 -07:00
parent 0a1f8331fe
commit 326e560329
6 changed files with 23 additions and 19 deletions

View file

@ -1131,6 +1131,8 @@ static boolean g_deferredtitle = false;
//
void D_StartTitle(void)
{
demo.attract = DEMO_ATTRACT_OFF;
Music_StopAll();
D_ClearState();

View file

@ -71,6 +71,7 @@
#include "k_roulette.h"
#include "k_bans.h"
#include "k_director.h"
#include "k_credits.h"
#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES
#include "m_avrecorder.h"
@ -6374,14 +6375,20 @@ void Command_ExitGame_f(void)
if (!modeattacking)
{
if (restoreMenu == NULL)
// YES, this is where demo.attract gets cleared!
if (demo.attract == DEMO_ATTRACT_CREDITS)
{
D_StartTitle();
F_ContinueCredits(); // <-- clears demo.attract
}
else if (restoreMenu == NULL) // this is true for attract demos too!
{
D_StartTitle(); // <-- clears demo.attract
}
else
{
D_ClearState();
M_StartControlPanel();
demo.attract = DEMO_ATTRACT_OFF; // shouldn't ever happen, but let's keep the code symmetrical
}
}
}

View file

@ -1348,7 +1348,6 @@ boolean G_Responder(event_t *ev)
{
// stop the title demo
G_CheckDemoStatus();
demo.attract = DEMO_ATTRACT_OFF;
return true;
}
}

View file

@ -430,6 +430,7 @@ void F_ContinueCredits(void)
{
G_SetGamestate(GS_CREDITS);
F_CreditsReset();
demo.attract = DEMO_ATTRACT_OFF;
// Returning from playing a demo.
// Go to the next slide.

View file

@ -94,8 +94,12 @@ void M_EndModeAttackRun(void)
// - Now we need to clear the rest of the gamestate ourself!
}
// Playback: modeattacking is always false, so calling this returns to the menu.
// Recording: modeattacking is still true and this function call preserves that.
// Playback:
// - modeattacking is always false, so calling this returns to the menu.
// - Because modeattacking is false, also clears demo.attract.
//
// Recording:
// - modeattacking is still true and this function call preserves that.
Command_ExitGame_f();
if (!modeattacking)
@ -123,19 +127,8 @@ void M_EndModeAttackRun(void)
modeattacking = ATTACKING_NONE;
// Return to the menu.
if (demo.attract == DEMO_ATTRACT_TITLE)
{
D_SetDeferredStartTitle(true);
}
else if (demo.attract == DEMO_ATTRACT_CREDITS)
{
F_ContinueCredits();
}
else
{
D_ClearState();
M_StartControlPanel();
}
D_ClearState();
M_StartControlPanel();
}
// Replay Playback Menu

View file

@ -8342,8 +8342,10 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
P_InitLevelSettings();
if (demo.attract != DEMO_ATTRACT_TITLE)
if (demo.attract != DEMO_ATTRACT_TITLE && gamestate != GS_TITLESCREEN)
{
// Stop titlescreen music from overriding level music.
// Except on the title screen, where an attract demo or title map may be used.
Music_Stop("title");
}