From 387ee4dc795a5dca24974251f773ebfe5875a413 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 25 Jun 2020 14:49:54 -0700 Subject: [PATCH] Un-hardreset certain variables for glitchrunner mode Ironically enough, resetting more variables in script.hardreset() makes the glitchy fadeout system even more glitchy. Resetting map.towermode, for example, makes it so that if you're in towers when you quit to the menu, script.hardreset() makes it so that the game thinks you're no longer inbounds (because it no longer thinks you're in a tower and thus considers coordinates in the space of 40x30 tiles to be inbounds instead of 40x700 or 40x100 tiles to be inbounds), calls map.gotoroom(), which resets the gamestate to 0. So if we're using the old system, it's better to reset only as much as needed. And furthermore, we shouldn't be relying on script.hardreset() to initialize variables for us. That should be done at the class constructor level. So I've gone ahead and initialized the variables in class constructors, too. --- desktop_version/src/Game.cpp | 7 +++++++ desktop_version/src/Map.cpp | 4 ++++ desktop_version/src/Script.cpp | 22 +++++++++++++++++----- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 32bfeea3..ea55b8a2 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -116,6 +116,13 @@ bool GetButtonFromString(const char *pText, SDL_GameControllerButton *button) void Game::init(void) { + roomx = 0; + roomy = 0; + prevroomx = 0; + prevroomy = 0; + saverx = 0; + savery = 0; + mutebutton = 0; muted = false; musicmuted = false; diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 30a456a8..02f4ea43 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -31,6 +31,10 @@ mapclass::mapclass() cursorstate = 0; cursordelay = 0; + towermode = false; + cameraseekframe = 0; + resumedelay = 0; + final_colormode = false; final_colorframe = 0; final_colorframedelay = 0; diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 0e9aad48..b93cb277 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -3482,8 +3482,12 @@ void scriptclass::hardreset() game.teleport = false; game.companion = 0; game.roomchange = false; - game.roomx = 0; - game.roomy = 0; + if (!game.glitchrunnermode) + { + // Ironically, resetting more variables makes the janky fadeout system in glitchrunnermode even more glitchy + game.roomx = 0; + game.roomy = 0; + } game.prevroomx = 0; game.prevroomy = 0; game.teleport_to_new_area = false; @@ -3521,8 +3525,12 @@ void scriptclass::hardreset() game.savetime = "00:00"; game.savearea = "nowhere"; game.savetrinkets = 0; - game.saverx = 0; - game.savery = 0; + if (!game.glitchrunnermode) + { + // Ironically, resetting more variables makes the janky fadeout system in glitchrunnermode even more glitchy + game.saverx = 0; + game.savery = 0; + } game.intimetrial = false; game.timetrialcountdown = 0; @@ -3606,7 +3614,11 @@ void scriptclass::hardreset() map.resetnames(); map.custommode=false; map.custommodeforreal=false; - map.towermode=false; + if (!game.glitchrunnermode) + { + // Ironically, resetting more variables makes the janky fadeout system even more glitchy + map.towermode=false; + } map.cameraseekframe = 0; map.resumedelay = 0; map.scrolldir = 0;