Replace a whole bunch of copypasted boilerplate with direct call to Command_ExitGame_f

Fixes not going back to the Title Screen at the cusp of the game's true beginning.
Also generally cleaner code
This commit is contained in:
toaster 2023-12-01 17:03:37 +00:00
parent d0117bc222
commit 30383ba82f
2 changed files with 14 additions and 54 deletions

View file

@ -1751,10 +1751,7 @@ static boolean CL_FinishedFileList(void)
} }
else if (i == 3) // too many files else if (i == 3) // too many files
{ {
D_QuitNetGame(); Command_ExitGame_f();
CL_Reset();
D_ClearState();
M_StartControlPanel();
M_StartMessage("Server Connection Failure", M_StartMessage("Server Connection Failure",
M_GetText( M_GetText(
"You have too many WAD files loaded\n" "You have too many WAD files loaded\n"
@ -1765,10 +1762,7 @@ static boolean CL_FinishedFileList(void)
} }
else if (i == 2) // cannot join for some reason else if (i == 2) // cannot join for some reason
{ {
D_QuitNetGame(); Command_ExitGame_f();
CL_Reset();
D_ClearState();
M_StartControlPanel();
M_StartMessage("Server Connection Failure", M_StartMessage("Server Connection Failure",
M_GetText( M_GetText(
"You have the wrong addons loaded.\n\n" "You have the wrong addons loaded.\n\n"
@ -1804,10 +1798,7 @@ static boolean CL_FinishedFileList(void)
{ {
if (!CL_CheckDownloadable()) // nope! if (!CL_CheckDownloadable()) // nope!
{ {
D_QuitNetGame(); Command_ExitGame_f();
CL_Reset();
D_ClearState();
M_StartControlPanel();
M_StartMessage("Server Connection Failure", M_StartMessage("Server Connection Failure",
M_GetText( M_GetText(
"An error occured when trying to\n" "An error occured when trying to\n"
@ -1931,10 +1922,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent)
serverlist[i].info.commit[n]); serverlist[i].info.commit[n]);
} }
D_QuitNetGame(); Command_ExitGame_f();
CL_Reset();
D_ClearState();
M_StartControlPanel();
M_StartMessage("Server Connection Failure", M_StartMessage("Server Connection Failure",
va( va(
@ -2084,10 +2072,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
{ {
CONS_Printf(M_GetText("Legacy downloader request packet failed.\n")); CONS_Printf(M_GetText("Legacy downloader request packet failed.\n"));
CONS_Printf(M_GetText("Network game synchronization aborted.\n")); CONS_Printf(M_GetText("Network game synchronization aborted.\n"));
D_QuitNetGame(); Command_ExitGame_f();
CL_Reset();
D_ClearState();
M_StartControlPanel();
M_StartMessage("Server Connection Failure", M_StartMessage("Server Connection Failure",
M_GetText( M_GetText(
"The direct download encountered an error.\n" "The direct download encountered an error.\n"
@ -2113,10 +2098,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
{ {
CONS_Printf(M_GetText("5 minute wait time exceeded.\n")); CONS_Printf(M_GetText("5 minute wait time exceeded.\n"));
CONS_Printf(M_GetText("Network game synchronization aborted.\n")); CONS_Printf(M_GetText("Network game synchronization aborted.\n"));
D_QuitNetGame(); Command_ExitGame_f();
CL_Reset();
D_ClearState();
M_StartControlPanel();
M_StartMessage("Server Connection Failure", M_StartMessage("Server Connection Failure",
M_GetText( M_GetText(
"5 minute wait time exceeded.\n" "5 minute wait time exceeded.\n"
@ -2226,10 +2208,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
CONS_Printf(M_GetText("Network game synchronization aborted.\n")); CONS_Printf(M_GetText("Network game synchronization aborted.\n"));
// M_StartMessage("Server Connection", M_GetText("Network game synchronization aborted.\n"), NULL, MM_NOTHING, NULL, "Back to Menu"); // M_StartMessage("Server Connection", M_GetText("Network game synchronization aborted.\n"), NULL, MM_NOTHING, NULL, "Back to Menu");
D_QuitNetGame(); Command_ExitGame_f();
CL_Reset();
D_ClearState();
M_StartControlPanel();
return false; return false;
} }
@ -3125,10 +3104,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
#endif #endif
LUA_HookBool(false, HOOK(GameQuit)); //Lua hooks handled differently now LUA_HookBool(false, HOOK(GameQuit)); //Lua hooks handled differently now
D_QuitNetGame(); Command_ExitGame_f();
CL_Reset();
D_ClearState();
M_StartControlPanel();
if (msg == KICK_MSG_CON_FAIL) if (msg == KICK_MSG_CON_FAIL)
M_StartMessage("Server Disconnected", M_GetText("Server closed connection\n(Synch failure)\n"), NULL, MM_NOTHING, NULL, "Back to Menu"); M_StartMessage("Server Disconnected", M_GetText("Server closed connection\n(Synch failure)\n"), NULL, MM_NOTHING, NULL, "Back to Menu");
@ -4326,10 +4302,7 @@ static void HandleShutdown(SINT8 node)
{ {
(void)node; (void)node;
LUA_HookBool(false, HOOK(GameQuit)); LUA_HookBool(false, HOOK(GameQuit));
D_QuitNetGame(); Command_ExitGame_f();
CL_Reset();
D_ClearState();
M_StartControlPanel();
M_StartMessage("Server Disconnected", M_GetText("Server has shutdown\n"), NULL, MM_NOTHING, NULL, "Back to Menu"); M_StartMessage("Server Disconnected", M_GetText("Server has shutdown\n"), NULL, MM_NOTHING, NULL, "Back to Menu");
} }
@ -4342,10 +4315,7 @@ static void HandleTimeout(SINT8 node)
{ {
(void)node; (void)node;
LUA_HookBool(false, HOOK(GameQuit)); LUA_HookBool(false, HOOK(GameQuit));
D_QuitNetGame(); Command_ExitGame_f();
CL_Reset();
D_ClearState();
M_StartControlPanel();
M_StartMessage("Server Disconnected", M_GetText("Server Timeout\n"), NULL, MM_NOTHING, NULL, "Back to Menu"); M_StartMessage("Server Disconnected", M_GetText("Server Timeout\n"), NULL, MM_NOTHING, NULL, "Back to Menu");
} }
@ -4359,10 +4329,7 @@ void HandleSigfail(const char *string)
} }
LUA_HookBool(false, HOOK(GameQuit)); LUA_HookBool(false, HOOK(GameQuit));
D_QuitNetGame(); Command_ExitGame_f();
CL_Reset();
D_ClearState();
M_StartControlPanel();
M_StartMessage("Server Disconnected", va(M_GetText("Signature check failed.\n(%s)\n"), string), NULL, MM_NOTHING, NULL, "Back to Menu"); M_StartMessage("Server Disconnected", va(M_GetText("Signature check failed.\n(%s)\n"), string), NULL, MM_NOTHING, NULL, "Back to Menu");
} }
@ -4561,10 +4528,7 @@ static void HandlePacketFromAwayNode(SINT8 node)
break; break;
} }
D_QuitNetGame(); Command_ExitGame_f();
CL_Reset();
D_ClearState();
M_StartControlPanel();
if (reason[1] == '|') if (reason[1] == '|')
{ {

View file

@ -3000,10 +3000,7 @@ void G_FinishExitLevel(void)
{ {
// Back to the menu with you. // Back to the menu with you.
G_HandleSaveLevel(true); G_HandleSaveLevel(true);
D_QuitNetGame(); Command_ExitGame_f();
CL_Reset();
D_ClearState();
M_StartControlPanel();
return; return;
} }
} }
@ -4511,8 +4508,7 @@ void G_EndGame(void)
} }
// Time to return to the menu. // Time to return to the menu.
D_ClearState(); Command_ExitGame_f();
M_StartControlPanel();
} }
// //