1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

Remove game.shouldreturntoeditor in favor of using defer callback

game.shouldreturntoeditor was added to fix a frame ordering issue that
was causing a bug where if you started playtesting in a room with a
horizontal/vertical warp background, and exited playtesting in a
different room that also had a horizontal/vertical warp background and
which was different, then the background of the room you exited in would
slowly scroll offscreen, when you re-entered the editor, instead of the
background consisting entirely of the actual background of the room.

Namely, the issue was that the game would render one more frame of
GAMEMODE after graphics.backgrounddrawn got set to false, and re-set it
to true, thus negating the background redraw, so the editor background
would be incorrect.

With defer callbacks, we can now just use a couple lines of code,
instead of having to add an extra kludge variable and putting handling
for it all over the code.
This commit is contained in:
Misa 2021-01-10 14:48:25 -08:00 committed by Ethan Lee
parent 32be2fcd81
commit 3da0e31215
5 changed files with 9 additions and 25 deletions

View file

@ -7,6 +7,7 @@
#include <string.h>
#include <tinyxml2.h>
#include "DeferCallbacks.h"
#include "editor.h"
#include "Entity.h"
#include "Enums.h"
@ -365,10 +366,6 @@ void Game::init(void)
fadetolab = false;
fadetolabdelay = 0;
#if !defined(NO_CUSTOM_LEVELS)
shouldreturntoeditor = false;
#endif
over30mode = false;
glitchrunnermode = false;
@ -1902,7 +1899,7 @@ void Game::updatestate(void)
}
else
{
shouldreturntoeditor = true;
returntoeditor();
if(!muted && ed.levmusic>0) music.fadeMusicVolumeIn(3000);
if(ed.levmusic>0) music.fadeout();
}
@ -6584,6 +6581,11 @@ void Game::returntolab(void)
}
#if !defined(NO_CUSTOM_LEVELS)
static void resetbg(void)
{
graphics.backgrounddrawn = false;
}
void Game::returntoeditor(void)
{
gamestate = EDITORMODE;
@ -6602,7 +6604,7 @@ void Game::returntoeditor(void)
ed.notedelay = 0;
ed.roomnamehide = 0;
graphics.backgrounddrawn=false;
DEFER_CALLBACK(resetbg);
music.fadeout();
//If warpdir() is used during playtesting, we need to set it back after!
for (int j = 0; j < ed.maxheight; j++)

View file

@ -434,7 +434,6 @@ public:
#if !defined(NO_CUSTOM_LEVELS)
void returntoeditor(void);
bool shouldreturntoeditor;
#endif
int gametimer;

View file

@ -1779,7 +1779,7 @@ void gameinput(void)
}else if(game.activetele && game.readytotele > 20 && game.press_map){
//pass, let code block below handle it
}else{
game.shouldreturntoeditor = true;
game.returntoeditor();
game.mapheld = true;
}
}

View file

@ -1576,11 +1576,4 @@ void gamelogic(void)
if (game.teleport_to_new_area)
script.teleport();
#if !defined(NO_CUSTOM_LEVELS)
if (game.shouldreturntoeditor)
{
game.returntoeditor();
}
#endif
}

View file

@ -2419,11 +2419,6 @@ static void editormenurender(int tr, int tg, int tb)
void editorrender(void)
{
extern editorclass ed;
if (game.shouldreturntoeditor)
{
graphics.backgrounddrawn = false;
}
//Draw grid
ClearSurface(graphics.backBuffer);
@ -3647,11 +3642,6 @@ void editorlogic(void)
//Misc
help.updateglow();
if (game.shouldreturntoeditor)
{
game.shouldreturntoeditor = false;
}
graphics.titlebg.bypos -= 2;
graphics.titlebg.bscroll = -2;