From f6ecf83190ae4bfef9062712a5a79cedbc6583c5 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 19 Mar 2021 23:09:11 -0700 Subject: [PATCH] Ensure oldfadeamount is updated when fadeamount is Like cutscene bars, I've added Graphics::setfade(), to ensure that no deltaframe rendering glitches happen due to oldfadeamount not being updated properly. And indeed, this fixes a deltaframe rendering glitch that happens if you return to the editor from playtesting on a faded-out screen, then fade out again (by either re-entering playtesting and then cause a fadeout to happen again, or by quitting from the editor afterwards). The same glitch also happens outside of in-editor playtesting if you exit to the menu while the screen is faded out. --- desktop_version/src/Graphics.cpp | 13 +++++++++---- desktop_version/src/Graphics.h | 1 + desktop_version/src/Script.cpp | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index dc2c2cb0..7d5efe0d 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -95,8 +95,7 @@ void Graphics::init(void) //Fading stuff SDL_memset(fadebars, 0, sizeof(fadebars)); - fadeamount = 0; - oldfadeamount = 0; + setfade(0); fademode = 0; // initialize everything else to zero @@ -1354,7 +1353,7 @@ void Graphics::processfade(void) { fadebars[i] = -int(fRandom() * 12) * 8; } - fadeamount = 0; + setfade(0); fademode = 3; } else if (fademode == 3) @@ -1372,7 +1371,7 @@ void Graphics::processfade(void) { fadebars[i] = 320 + int(fRandom() * 12) * 8; } - fadeamount = 416; + setfade(416); fademode = 5; } else if (fademode == 5) @@ -1386,6 +1385,12 @@ void Graphics::processfade(void) } } +void Graphics::setfade(const int amount) +{ + fadeamount = amount; + oldfadeamount = amount; +} + void Graphics::drawmenu( int cr, int cg, int cb, bool levelmenu /*= false*/ ) { for (size_t i = 0; i < game.menuoptions.size(); i++) diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index b9b928ff..7738bbef 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -45,6 +45,7 @@ public: void drawmenu(int cr, int cg, int cb, bool levelmenu = false); void processfade(void); + void setfade(const int amount); void drawfade(void); diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 879fd1dc..34adcb3d 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -1498,7 +1498,7 @@ void scriptclass::run(void) } else if (words[0] == "befadein") { - graphics.fadeamount = 0; + graphics.setfade(0); graphics.fademode= 0; } else if (words[0] == "fadein")