From 57efb26567bb9f88fba3a5247d0d727ca7b5235c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 16 Aug 2020 20:04:27 +0200 Subject: [PATCH] - wrap Blood's main loop into an exception handler for recoverable errors. --- source/blood/src/blood.cpp | 92 +++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 40 deletions(-) diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 0288a8d55..d28cdf0a3 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -916,52 +916,64 @@ int GameInterface::app_main() bool playvideo = !bQuickStart; while (true) { - if (gamestate == GS_STARTUP) gameInit(); - - commonTicker(playvideo); - netGetPackets(); - handleevents(); - updatePauseStatus(); - D_ProcessEvents(); - ctrlGetInput(); - - switch (gamestate) + try { - default: - case GS_STARTUP: - if (playvideo) playlogos(); - else - { - gamestate = GS_MENUSCREEN; - M_StartControlPanel(false); - M_SetMenu(NAME_Mainmenu); - } - break; + if (gamestate == GS_STARTUP) gameInit(); - case GS_MENUSCREEN: - case GS_FULLCONSOLE: - drawBackground(); - break; + commonTicker(playvideo); + netGetPackets(); + handleevents(); + updatePauseStatus(); + D_ProcessEvents(); + ctrlGetInput(); - case GS_INTRO: - case GS_INTERMISSION: - RunScreenJobFrame(); // This handles continuation through its completion callback. - break; + switch (gamestate) + { + default: + case GS_STARTUP: + if (userConfig.CommandMap.IsNotEmpty()) + { + } + else + { + if (playvideo) playlogos(); + else + { + gamestate = GS_MENUSCREEN; + M_StartControlPanel(false); + M_SetMenu(NAME_Mainmenu); + } + } + break; - case GS_LEVEL: - gameTicker(); - LocalKeys(); - break; + case GS_MENUSCREEN: + case GS_FULLCONSOLE: + drawBackground(); + break; - case GS_FINALE: - gEndGameMgr.ProcessKeys(); - gEndGameMgr.Draw(); - break; + case GS_INTRO: + case GS_INTERMISSION: + RunScreenJobFrame(); // This handles continuation through its completion callback. + break; + + case GS_LEVEL: + gameTicker(); + LocalKeys(); + break; + + case GS_FINALE: + gEndGameMgr.ProcessKeys(); + gEndGameMgr.Draw(); + break; + } + + videoNextPage(); + } + catch (CRecoverableError& err) + { + C_FullConsole(); + Printf(TEXTCOLOR_RED "%s\n", err.what()); } - - videoNextPage(); - - } return 0; }