Fix jank attack

Consistently call D_StartTitle, don't glitch out on invalid replays etc
This commit is contained in:
GenericHeroGuy 2025-03-25 15:55:56 +01:00
parent 784fc8f46c
commit 016435b3b9
5 changed files with 30 additions and 47 deletions

View file

@ -1168,7 +1168,6 @@ void F_GameEndTicker(void)
void F_InitMenuPresValues(void) void F_InitMenuPresValues(void)
{ {
menuanimtimer = 0; menuanimtimer = 0;
M_ClearMenus(false); // TODO maybe call exit funcs here? but that triggers an infinite loop in replay hut...
// Set defaults for presentation values // Set defaults for presentation values
strncpy(curbgname, "TITLESKY", 9); strncpy(curbgname, "TITLESKY", 9);

View file

@ -2992,11 +2992,11 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname); Z_Free(pdemoname);
P_SaveBufferFree(&demobuf); P_SaveBufferFree(&demobuf);
demo.playback = false; demo.playback = false;
demo.title = false; demo.title = false;
M_StartMessage(msg, NULL, MM_NOTHING);
return; return;
} }
demobuf.p += 12; // DEMOHEADER demobuf.p += 12; // DEMOHEADER
@ -3012,11 +3012,11 @@ void G_DoPlayDemo(char *defdemoname)
default: default:
snprintf(msg, 1024, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname); Z_Free(pdemoname);
P_SaveBufferFree(&demobuf); P_SaveBufferFree(&demobuf);
demo.playback = false; demo.playback = false;
demo.title = false; demo.title = false;
M_StartMessage(msg, NULL, MM_NOTHING);
return; return;
} }
@ -3030,11 +3030,11 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname); Z_Free(pdemoname);
P_SaveBufferFree(&demobuf); P_SaveBufferFree(&demobuf);
demo.playback = false; demo.playback = false;
demo.title = false; demo.title = false;
M_StartMessage(msg, NULL, MM_NOTHING);
return; return;
} }
@ -3094,12 +3094,12 @@ void G_DoPlayDemo(char *defdemoname)
} }
CONS_Alert(CONS_ERROR, "%s", msg); 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);
Z_Free(pdemoname); Z_Free(pdemoname);
P_SaveBufferFree(&demobuf); P_SaveBufferFree(&demobuf);
demo.playback = false; demo.playback = false;
demo.title = false; demo.title = false;
if (!CON_Ready()) // In the console they'll just see the notice there! No point pulling them out.
M_StartMessage(msg, NULL, MM_NOTHING);
return; return;
} }
} }
@ -3138,11 +3138,11 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname); Z_Free(pdemoname);
P_SaveBufferFree(&demobuf); P_SaveBufferFree(&demobuf);
demo.playback = false; demo.playback = false;
demo.title = false; demo.title = false;
M_StartMessage(msg, NULL, MM_NOTHING);
return; return;
} }
@ -3166,11 +3166,11 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname); snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname); Z_Free(pdemoname);
P_SaveBufferFree(&demobuf); P_SaveBufferFree(&demobuf);
demo.playback = false; demo.playback = false;
demo.title = false; demo.title = false;
M_StartMessage(msg, NULL, MM_NOTHING);
return; return;
} }
@ -3217,11 +3217,11 @@ void G_DoPlayDemo(char *defdemoname)
{ {
snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with %s, and is thus invalid.\n"), pdemoname, (bot ? "bots" : "spectators")); snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with %s, and is thus invalid.\n"), pdemoname, (bot ? "bots" : "spectators"));
CONS_Alert(CONS_ERROR, "%s", msg); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname); Z_Free(pdemoname);
P_SaveBufferFree(&demobuf); P_SaveBufferFree(&demobuf);
demo.playback = false; demo.playback = false;
demo.title = false; demo.title = false;
M_StartMessage(msg, NULL, MM_NOTHING);
return; return;
} }
} }
@ -3233,11 +3233,11 @@ 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); 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); CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname); Z_Free(pdemoname);
P_SaveBufferFree(&demobuf); P_SaveBufferFree(&demobuf);
demo.playback = false; demo.playback = false;
demo.title = false; demo.title = false;
M_StartMessage(msg, NULL, MM_NOTHING);
return; return;
} }
@ -4019,7 +4019,7 @@ boolean G_CheckDemoStatus(void)
G_StopDemo(); G_StopDemo();
if (modeattacking) if (modeattacking)
M_EndModeAttackRun(); M_ModeAttackEndGame(0);
else else
D_AdvanceDemo(); D_AdvanceDemo();
} }

View file

@ -646,7 +646,7 @@ void G_SetGameModified(boolean silent, boolean major)
// If in record attack recording, cancel it. // If in record attack recording, cancel it.
if (modeattacking) if (modeattacking)
M_EndModeAttackRun(); M_ModeAttackEndGame(0);
else if (marathonmode) else if (marathonmode)
Command_ExitGame_f(); Command_ExitGame_f();
} }
@ -4062,7 +4062,7 @@ void G_AfterIntermission(void)
if (modeattacking) // End the run. if (modeattacking) // End the run.
{ {
M_EndModeAttackRun(); M_ModeAttackEndGame(0);
return; return;
} }

View file

@ -1315,22 +1315,15 @@ boolean M_Responder(event_t *ev)
//case KEY_JOY1 + 2: //case KEY_JOY1 + 2:
noFurtherInput = true; noFurtherInput = true;
currentMenu->lastOn = itemOn; currentMenu->lastOn = itemOn;
if (menustack[0] == MN_SP_TIMEATTACK)
//If we entered the game search menu, but didn't enter a game,
//make sure the game doesn't still think we're in a netgame.
if (!Playing() && netgame && multiplayer)
{ {
// D_StartTitle does its own wipe, since GS_TIMEATTACK is now a complete gamestate. netgame = false;
D_StartTitle(); multiplayer = false;
}
else
{
//If we entered the game search menu, but didn't enter a game,
//make sure the game doesn't still think we're in a netgame.
if (!Playing() && netgame && multiplayer)
{
netgame = false;
multiplayer = false;
}
M_ExitMenu();
} }
M_ExitMenu();
return true; return true;
@ -1655,11 +1648,6 @@ void M_StartControlPanel(void)
CON_ToggleOff(); // move away console CON_ToggleOff(); // move away console
} }
void M_EndModeAttackRun(void)
{
M_ModeAttackEndGame(0);
}
// //
// M_ClearMenus // M_ClearMenus
// //
@ -1676,6 +1664,10 @@ void M_ClearMenus(boolean callexitmenufunc)
memset(menustack, 0, sizeof(menustack)); memset(menustack, 0, sizeof(menustack));
currentMenu = NULL; currentMenu = NULL;
hidetitlemap = false; hidetitlemap = false;
// D_StartTitle does its own wipe, since GS_TIMEATTACK is now a complete gamestate.
if (gamestate == GS_TIMEATTACK)
D_StartTitle();
} }
// //
@ -4004,8 +3996,7 @@ void M_QuitReplayHut(INT32 choice)
{ {
(void)choice; (void)choice;
// D_StartTitle does its own wipe, since GS_TIMEATTACK is now a complete gamestate. M_ClearMenus(false);
D_StartTitle();
if (demolist) if (demolist)
Z_Free(demolist); Z_Free(demolist);
@ -4302,11 +4293,14 @@ void M_PlaybackQuit(INT32 choice)
M_ReplayHut(choice); M_ReplayHut(choice);
else if (modeattacking) else if (modeattacking)
{ {
M_EndModeAttackRun(); M_ModeAttackEndGame(0);
S_ChangeMusicInternal("racent", true); S_ChangeMusicInternal("racent", true);
} }
else else
{
M_ClearMenus(true);
D_StartTitle(); D_StartTitle();
}
} }
void M_PandorasBox(INT32 choice) void M_PandorasBox(INT32 choice)
@ -5842,7 +5836,6 @@ void M_HandleStaffReplay(INT32 choice)
if (l == LUMPERROR) if (l == LUMPERROR)
break; break;
M_ClearMenus(true); M_ClearMenus(true);
modeattacking = (levellistmode == LLM_ITEMBREAKER ? ATTACKING_ITEMBREAK : ATTACKING_TIME);
demo.loadfiles = false; demo.ignorefiles = true; // Just assume that record attack replays have the files needed demo.loadfiles = false; demo.ignorefiles = true; // Just assume that record attack replays have the files needed
G_DoPlayDemo(va("%sS%02u",G_BuildMapName(cv_nextmap.value),cv_dummystaff.value)); G_DoPlayDemo(va("%sS%02u",G_BuildMapName(cv_nextmap.value),cv_dummystaff.value));
break; break;
@ -5859,7 +5852,6 @@ void M_ReplayTimeAttack(INT32 choice)
const char *which; const char *which;
const char *gamemode = (levellistmode == LLM_ITEMBREAKER) ? "IB" : "RA"; const char *gamemode = (levellistmode == LLM_ITEMBREAKER) ? "IB" : "RA";
M_ClearMenus(true); M_ClearMenus(true);
modeattacking = (levellistmode == LLM_ITEMBREAKER ? ATTACKING_ITEMBREAK : ATTACKING_TIME); // set modeattacking before G_DoPlayDemo so the map loader knows
demo.loadfiles = false; demo.ignorefiles = true; // Just assume that record attack replays have the files needed demo.loadfiles = false; demo.ignorefiles = true; // Just assume that record attack replays have the files needed
switch(choice) { switch(choice) {
@ -5976,13 +5968,8 @@ void M_ModeAttackEndGame(INT32 choice)
if (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING) if (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING)
Command_ExitGame_f(); Command_ExitGame_f();
M_StartControlPanel(); M_ClearMenus(true);
M_EnterMenu(MN_SP_TIMEATTACK, true);
if (modeattacking)
{
M_ClearMenus(true);
M_EnterMenu(MN_SP_TIMEATTACK, true);
}
G_SetGamestate(GS_TIMEATTACK); G_SetGamestate(GS_TIMEATTACK);
modeattacking = ATTACKING_NONE; modeattacking = ATTACKING_NONE;

View file

@ -120,9 +120,6 @@ void M_InitCharacterTables(void);
// does nothing if menu is already up. // does nothing if menu is already up.
void M_StartControlPanel(void); void M_StartControlPanel(void);
// Called upon end of a mode attack run
void M_EndModeAttackRun(void);
// Called on new server add, or other reasons // Called on new server add, or other reasons
void M_SortServerList(void); void M_SortServerList(void);