From b89a8ca6f9bb7e7c91221fd722ac9fca0482c49e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 1 Dec 2025 21:02:35 +0100 Subject: [PATCH] replays: properly throw player back to titlescreen from replay error fixes the game becoming stuck in limbo state if replay fails to start --- src/g_demo.c | 26 +++++++++++++------------- src/m_menu.c | 10 ++++++++++ src/m_menu.h | 1 + 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 51f7dc334..70ac4237f 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2612,7 +2612,7 @@ void G_DoPlayDemo(char *defdemoname) snprintf(msg, 1024, M_GetText("Failed to read file '%s'.\n"), defdemoname); CONS_Alert(CONS_ERROR, "%s", msg); gameaction = ga_nothing; - M_StartMessage(msg, NULL, MM_NOTHING); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); return; } @@ -2624,7 +2624,7 @@ void G_DoPlayDemo(char *defdemoname) snprintf(msg, 1024, M_GetText("Failed to read lump '%s'.\n"), defdemoname); CONS_Alert(CONS_ERROR, "%s", msg); gameaction = ga_nothing; - M_StartMessage(msg, NULL, MM_NOTHING); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); return; } else // it's an internal demo @@ -2644,7 +2644,7 @@ void G_DoPlayDemo(char *defdemoname) { snprintf(msg, 1024, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); return; } @@ -2670,7 +2670,7 @@ void G_DoPlayDemo(char *defdemoname) default: snprintf(msg, 1024, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); return; } @@ -2681,7 +2681,7 @@ void G_DoPlayDemo(char *defdemoname) { snprintf(msg, 1024, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); return; } @@ -2698,7 +2698,7 @@ void G_DoPlayDemo(char *defdemoname) { snprintf(msg, 1024, M_GetText("%s is an alpha multiplayer replay and cannot be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); return; } @@ -2756,7 +2756,7 @@ void G_DoPlayDemo(char *defdemoname) CONS_Alert(CONS_ERROR, "%s", msg); if (!CON_Ready()) // In the console they'll just see the notice there! No point pulling them out. - M_StartMessage(msg, NULL, MM_NOTHING); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); return; @@ -2821,7 +2821,7 @@ void G_DoPlayDemo(char *defdemoname) { snprintf(msg, 1024, M_GetText("%s features a character that is not currently loaded.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); return; } @@ -2831,7 +2831,7 @@ void G_DoPlayDemo(char *defdemoname) { snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); return; } @@ -2854,7 +2854,7 @@ void G_DoPlayDemo(char *defdemoname) { snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); return; } @@ -2892,7 +2892,7 @@ void G_DoPlayDemo(char *defdemoname) { snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); return; } @@ -2941,7 +2941,7 @@ void G_DoPlayDemo(char *defdemoname) { snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with spectators, and is thus invalid.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); return; } @@ -2953,7 +2953,7 @@ void G_DoPlayDemo(char *defdemoname) { snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with multiple players, and is thus invalid.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); - M_StartMessage(msg, NULL, MM_NOTHING); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); return; } diff --git a/src/m_menu.c b/src/m_menu.c index 0e7124c99..399c39696 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4830,6 +4830,16 @@ static boolean M_QuitReplayHut(void) return true; } +// same as M_QuitReplayHut, but calls M_StopMessage +void M_ReturnToTitleFromError(void) +{ + M_StopMessage(0); + // D_StartTitle does its own wipe, since GS_TIMEATTACK is now a complete gamestate. + menuactive = false; + D_StartTitle(); + M_ResetDemoList(); +} + static void M_HutStartReplay(INT32 choice) { (void)choice; diff --git a/src/m_menu.h b/src/m_menu.h index 5ec09debb..f3e155b46 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -307,6 +307,7 @@ void M_UpdateOGLMenu(void); void M_ResetDemoList(void); void M_ReplayHut(INT32 choice); +void M_ReturnToTitleFromError(void); void M_SetPlaybackMenuPointer(void); void Nextmap_OnChange(void);