From b59e5a834621a86413cc7eb7546ff582998db230 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 7 May 2020 14:54:39 -0700 Subject: [PATCH] Move script.hardreset() to after quit to menu This cleans up a whole lot of kludge variables, because this aggressive hardreset() right as ACTION is pressed doesn't do anyone any favors. This aggressive hardreset() was probably here because of the whole fact that exiting to the menu uses Terry's State Machine, to minimize the chances of interruption, but it actually causes more issues and allows towers to interrupt the fadeout. And we should fix the root cause (the usage of the state machine) instead of patching together some kludge. --- desktop_version/src/Game.cpp | 19 +++++-------------- desktop_version/src/Game.h | 7 ------- desktop_version/src/Input.cpp | 8 -------- desktop_version/src/Render.cpp | 8 ++++---- 4 files changed, 9 insertions(+), 33 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 08423e56..6aee3ddd 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -135,7 +135,6 @@ void Game::init(void) teleportscript = ""; savemystats = false; - menukludge = false; quickrestartkludge = false; tapleft = 0; @@ -231,11 +230,6 @@ void Game::init(void) customleveltitle=""; createmenu(Menu::mainmenu); - wasintimetrial = false; - wasinintermission = false; - wasinnodeathmode = false; - wasincustommode = false; - deathcounts = 0; gameoverdelay = 0; frames = 0; @@ -7334,19 +7328,19 @@ void Game::quittomenu() //or "who do you want to play the level with?" //or "do you want cutscenes?" //or the confirm-load-quicksave menu - if (wasintimetrial) + if (intimetrial) { returntomenu(Menu::timetrials); } - else if (wasinintermission) + else if (inintermission) { returntomenu(Menu::intermissionmenu); } - else if (wasinnodeathmode) + else if (nodeathmode) { returntomenu(Menu::playmodes); } - else if (wasincustommode) + else if (map.custommode) { returntomenu(Menu::levellist); } @@ -7358,8 +7352,5 @@ void Game::quittomenu() { createmenu(Menu::mainmenu); } - wasintimetrial = false; - wasinintermission = false; - wasinnodeathmode = false; - wasincustommode = false; + script.hardreset(); } diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 52bda2e5..8355755f 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -234,12 +234,6 @@ public: int creditposx, creditposy, creditposdelay; - //Menu kludge... - bool wasintimetrial; - bool wasinintermission; - bool wasinnodeathmode; - bool wasincustommode; - //Sine Wave Ninja Minigame bool swnmode; @@ -351,7 +345,6 @@ public: int stretchMode; int controllerSensitivity; - bool menukludge; bool quickrestartkludge; //Custom stuff diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 02f5dbd7..6125bdf0 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -1879,7 +1879,6 @@ void mapinput() graphics.resumegamemode = true; obj.removeallblocks(); game.activeactivity = -1; - game.menukludge = false; if (game.menupage >= 20) { game.state = 96; @@ -1968,13 +1967,6 @@ void mapinput() //Kill contents of offset render buffer, since we do that for some reason. //This fixes an apparent frame flicker. FillRect(graphics.tempBuffer, 0x000000); - if (game.intimetrial || game.insecretlab || game.nodeathmode) game.menukludge = true; - game.wasintimetrial = game.intimetrial; - game.wasinintermission = game.inintermission; - game.wasinnodeathmode = game.nodeathmode; - game.wasincustommode = map.custommode; - script.hardreset(); - if(graphics.setflipmode) graphics.flipmode = true; graphics.fademode = 2; music.fadeout(); map.nexttowercolour(); diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index b8358581..4ae14676 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -2353,7 +2353,7 @@ void maprender() if (graphics.flipmode) { - if (game.intimetrial || game.insecretlab || game.nodeathmode || game.menukludge) + if (game.intimetrial || game.insecretlab || game.nodeathmode) { graphics.Print(0, 135, "Return to main menu?", 196, 196, 255 - help.glow, true); } @@ -2369,7 +2369,7 @@ void maprender() else { - if (game.intimetrial || game.insecretlab || game.nodeathmode || game.menukludge) + if (game.intimetrial || game.insecretlab || game.nodeathmode) { graphics.Print(0, 80, "Return to main menu?", 196, 196, 255 - help.glow, true); } @@ -2389,7 +2389,7 @@ void maprender() if (graphics.flipmode) { - if (game.intimetrial || game.insecretlab || game.nodeathmode || game.menukludge) + if (game.intimetrial || game.insecretlab || game.nodeathmode) { graphics.Print(0, 135, "Return to main menu?", 196, 196, 255 - help.glow, true); } @@ -2404,7 +2404,7 @@ void maprender() } else { - if (game.intimetrial || game.insecretlab || game.nodeathmode || game.menukludge) + if (game.intimetrial || game.insecretlab || game.nodeathmode) { graphics.Print(0, 80, "Return to main menu?", 196, 196, 255 - help.glow, true); }