diff --git a/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index 042d471e7..0fc2cec75 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -838,8 +838,18 @@ bool M_DoResponder (event_t *ev) bool M_Responder(event_t* ev) { + bool res = false; // delayed deletion, so that self-deleting menus don't crash if they are getting accessed after being closed. - auto res = M_DoResponder(ev); + try + { + res = M_DoResponder(ev); + } + catch (...) + { + for (auto p : toDelete) delete p; + toDelete.Clear(); + throw; + } for (auto p : toDelete) delete p; toDelete.Clear(); return res; diff --git a/source/exhumed/src/d_menu.cpp b/source/exhumed/src/d_menu.cpp index b5204a816..8a4fc6bfd 100644 --- a/source/exhumed/src/d_menu.cpp +++ b/source/exhumed/src/d_menu.cpp @@ -42,11 +42,9 @@ int handle1; int MenuExitCondition; -int MenuStartCondition; int menu_Menu(int nVal) { - MenuStartCondition = nVal; MenuExitCondition = -2; M_StartControlPanel(false); M_SetMenu(NAME_MainMenu); @@ -70,7 +68,9 @@ int menu_Menu(int nVal) videoNextPage(); } - return MenuExitCondition; + int me = MenuExitCondition; + MenuExitCondition = -2; + return me; } @@ -107,7 +107,13 @@ class PSMainMenu : public DListMenu void PreDraw() override { - menu_DoPlasma(); + if (mDesc->mMenuName == NAME_MainMenu) + menu_DoPlasma(); + else + { + auto nLogoTile = EXHUMED ? kExhumedLogo : kPowerslaveLogo; + overwritesprite(160, 40, nLogoTile, 32, 3, kPalNormal); + } } }; diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index a6813c458..668e0bd20 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -822,9 +822,12 @@ void timerhandler() } } +extern int MenuExitCondition; void HandleAsync() { + MenuExitCondition = -2; handleevents(); + } int MyGetStringWidth(const char *str) @@ -2357,12 +2360,12 @@ GAMELOOP: } if (!bInDemo) { - if (inputState.GetKeyStatus(sc_Escape)) + nMenu = MenuExitCondition; + if (nMenu != -2) { - inputState.ClearKeyStatus(sc_Escape); + MenuExitCondition = -2; // MENU2: bInMove = kTrue; - nMenu = menu_Menu(1); switch (nMenu) { @@ -2379,6 +2382,7 @@ GAMELOOP: goto LOOP2; case 3: + forcelevel = 0; goto STARTGAME2; case 6: goto GAMELOOP;