From 2d07090a6b0bc434548f19cac53167a1647e46cb Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 9 May 2020 12:52:58 -0700 Subject: [PATCH] Move returning to editor to end of frame This fixes horizontal and vertical warp backgrounds not resetting, and also a bunch of other 1-frame glitches, most noticeably cutscene bars and fadeouts. This adds a new variable shouldreturntoeditor to Game to signal whether or not it should return to editor at the end of the frame. --- desktop_version/src/Game.cpp | 4 ++++ desktop_version/src/Game.h | 1 + desktop_version/src/Input.cpp | 2 +- desktop_version/src/Logic.cpp | 8 ++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 1476a4cb..c696841a 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -375,6 +375,10 @@ void Game::init(void) fadetolab = false; fadetolabdelay = 0; +#if !defined(NO_CUSTOM_LEVELS) + shouldreturntoeditor = false; +#endif + /* Terry's Patrons... */ superpatrons.push_back("Anders Ekermo"); superpatrons.push_back("Andreas K|mper"); diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 3ca81ba4..db3043f2 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -388,6 +388,7 @@ public: #if !defined(NO_CUSTOM_LEVELS) void returntoeditor(); + bool shouldreturntoeditor; #endif }; diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 8f01fd74..0dbd0aff 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -1537,7 +1537,7 @@ void gameinput() game.activeactivity = -1; } }else{ - game.returntoeditor(); + game.shouldreturntoeditor = true; } } } diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index 3d1771e2..58012f27 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -1380,4 +1380,12 @@ void gamelogic() if (game.teleport_to_new_area) script.teleport(); + +#if !defined(NO_CUSTOM_LEVELS) + if (game.shouldreturntoeditor) + { + game.shouldreturntoeditor = false; + game.returntoeditor(); + } +#endif }