1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-31 22:19:44 +01:00

Enumify all fade modes

This removes the magic numbers previously used for controlling the fade
mode, which are really not readable at all unless you already know what
they mean.

0: FADE_NONE
1: FADE_FULLY_BLACK
2: FADE_START_FADEOUT
3: FADE_FADING_OUT
4: FADE_START_FADEIN
5: FADE_FADING_IN

There is also the macro FADEMODE_IS_FADING, which indicates when the
intention is to only check if the game is fading right now, which wasn't
clearly conveyed previously.

I also took the opportunity to clean up the style of any lines I
touched. This included rewriting if-else chains into case-switches,
turning one-liner if-then statements into proper blocks, fixing up
comments, and even commenting the `fademode == FADE_NONE` on the tower
spike checks (which, it was previously undocumented why that check was
there, but I think I know why it's there).

As for type safety, we already get some by transforming the variable
types into the enum. Assignment is prohibited without a cast. But,
apparently, comparison is perfectly legal and won't even give so much as
a warning. To work around this and make absolutely sure I made all
existing comparisons now use the enum, I temporarily changed it to be an
`enum class`, which is a C++11 feature that makes it so all comparisons
are illegal. Unfortunately, it scopes them in a namespace with the same
name as a class, so I had to temporarily define macros to make sure my
existing code worked. I also had to temporarily up the standard in
CMakeLists.txt to get it to compile. But after all that was done, I
found the rest of the places where a comparison to an integer was used,
and fixed them.
This commit is contained in:
Misa 2022-04-25 00:57:47 -07:00
parent af1cebf7a1
commit 98cb415675
9 changed files with 159 additions and 112 deletions

View file

@ -1718,7 +1718,7 @@ void editorlogic(void)
ed.notedelay--; ed.notedelay--;
} }
if (graphics.fademode == 1) if (graphics.fademode == FADE_FULLY_BLACK)
{ {
//Return to game //Return to game
graphics.titlebg.colstate = 10; graphics.titlebg.colstate = 10;
@ -1896,7 +1896,7 @@ static void editormenuactionpress(void)
//Quit without saving //Quit without saving
music.playef(11); music.playef(11);
music.fadeout(); music.fadeout();
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
break; break;
case 2: case 2:
//Go back to editor //Go back to editor
@ -1914,7 +1914,7 @@ static void editormenuactionpress(void)
void editorinput(void) void editorinput(void)
{ {
extern editorclass ed; extern editorclass ed;
if (graphics.fademode == 3 /* fading out */) if (graphics.fademode == FADE_FADING_OUT)
{ {
return; return;
} }
@ -2346,7 +2346,7 @@ void editorinput(void)
if (ed.saveandquit) if (ed.saveandquit)
{ {
graphics.fademode = 2; // quit editor graphics.fademode = FADE_START_FADEOUT; /* quit editor */
} }
break; break;
} }

View file

@ -1399,7 +1399,10 @@ void Game::updatestate(void)
case 80: case 80:
//Used to return to menu from the game //Used to return to menu from the game
if(graphics.fademode == 1) state++; if (graphics.fademode == FADE_FULLY_BLACK)
{
state++;
}
break; break;
case 81: case 81:
quittomenu(); quittomenu();
@ -1454,13 +1457,16 @@ void Game::updatestate(void)
savestatsandsettings(); savestatsandsettings();
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
music.fadeout(); music.fadeout();
state++; state++;
break; break;
case 83: case 83:
frames--; frames--;
if(graphics.fademode == 1) state++; if (graphics.fademode == FADE_FULLY_BLACK)
{
state++;
}
break; break;
case 84: case 84:
quittomenu(); quittomenu();
@ -1537,7 +1543,10 @@ void Game::updatestate(void)
case 96: case 96:
//Used to return to gravitron to game //Used to return to gravitron to game
if(graphics.fademode == 1) state++; if (graphics.fademode == FADE_FULLY_BLACK)
{
state++;
}
break; break;
case 97: case 97:
returntolab(); returntolab();
@ -1924,7 +1933,7 @@ void Game::updatestate(void)
{ {
if(map.custommodeforreal) if(map.custommodeforreal)
{ {
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
state=1014; state=1014;
} }
#ifndef NO_EDITOR #ifndef NO_EDITOR
@ -1946,7 +1955,10 @@ void Game::updatestate(void)
#endif #endif
case 1014: case 1014:
frames--; frames--;
if(graphics.fademode == 1) state++; if (graphics.fademode == FADE_FULLY_BLACK)
{
state++;
}
break; break;
case 1015: case 1015:
#if !defined(NO_CUSTOM_LEVELS) #if !defined(NO_CUSTOM_LEVELS)
@ -2372,12 +2384,12 @@ void Game::updatestate(void)
} }
break; break;
case 3055: case 3055:
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
state++; state++;
statedelay = 10; statedelay = 10;
break; break;
case 3056: case 3056:
if(graphics.fademode==1) if (graphics.fademode == FADE_FULLY_BLACK)
{ {
startscript = true; startscript = true;
if (crewrescued() == 6) if (crewrescued() == 6)
@ -2443,11 +2455,14 @@ void Game::updatestate(void)
case 3070: case 3070:
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
state++; state++;
break; break;
case 3071: case 3071:
if (graphics.fademode == 1) state++; if (graphics.fademode == FADE_FULLY_BLACK)
{
state++;
}
break; break;
case 3072: case 3072:
//Ok, we need to adjust some flags based on who've we've rescued. Some of there conversation options //Ok, we need to adjust some flags based on who've we've rescued. Some of there conversation options
@ -2522,20 +2537,23 @@ void Game::updatestate(void)
//returning from an intermission, very like 3070 //returning from an intermission, very like 3070
if (inintermission) if (inintermission)
{ {
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
companion = 0; companion = 0;
state=3100; state=3100;
} }
else else
{ {
unlocknum(7); unlocknum(7);
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
companion = 0; companion = 0;
state++; state++;
} }
break; break;
case 3081: case 3081:
if (graphics.fademode == 1) state++; if (graphics.fademode == FADE_FULLY_BLACK)
{
state++;
}
break; break;
case 3082: case 3082:
map.finalmode = false; map.finalmode = false;
@ -2552,21 +2570,24 @@ void Game::updatestate(void)
companion = 0; companion = 0;
supercrewmate = false; supercrewmate = false;
state++; state++;
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
music.fadeout(); music.fadeout();
state=3100; state=3100;
} }
else else
{ {
unlocknum(6); unlocknum(6);
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
companion = 0; companion = 0;
supercrewmate = false; supercrewmate = false;
state++; state++;
} }
break; break;
case 3086: case 3086:
if (graphics.fademode == 1) state++; if (graphics.fademode == FADE_FULLY_BLACK)
{
state++;
}
break; break;
case 3087: case 3087:
map.finalmode = false; map.finalmode = false;
@ -2576,7 +2597,10 @@ void Game::updatestate(void)
break; break;
case 3100: case 3100:
if(graphics.fademode == 1) state++; if (graphics.fademode == FADE_FULLY_BLACK)
{
state++;
}
break; break;
case 3101: case 3101:
quittomenu(); quittomenu();
@ -2787,18 +2811,18 @@ void Game::updatestate(void)
break; break;
} }
case 3516: case 3516:
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
state++; state++;
break; break;
case 3517: case 3517:
if (graphics.fademode == 1) if (graphics.fademode == FADE_FULLY_BLACK)
{ {
state++; state++;
statedelay = 30; statedelay = 30;
} }
break; break;
case 3518: case 3518:
graphics.fademode = 4; graphics.fademode = FADE_START_FADEIN;
state = 0; state = 0;
statedelay = 30; statedelay = 30;
@ -2819,11 +2843,14 @@ void Game::updatestate(void)
hascontrol = false; hascontrol = false;
crewstats[0] = true; crewstats[0] = true;
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
state++; state++;
break; break;
case 3521: case 3521:
if(graphics.fademode == 1) state++; if (graphics.fademode == FADE_FULLY_BLACK)
{
state++;
}
break; break;
case 3522: case 3522:
copyndmresults(); copyndmresults();
@ -6699,7 +6726,7 @@ bool Game::save_exists(void)
void Game::quittomenu(void) void Game::quittomenu(void)
{ {
gamestate = TITLEMODE; gamestate = TITLEMODE;
graphics.fademode = 4; graphics.fademode = FADE_START_FADEIN;
FILESYSTEM_unmountAssets(); FILESYSTEM_unmountAssets();
cliplaytest = false; cliplaytest = false;
graphics.titlebg.tdrawback = true; graphics.titlebg.tdrawback = true;
@ -6751,7 +6778,7 @@ void Game::quittomenu(void)
void Game::returntolab(void) void Game::returntolab(void)
{ {
gamestate = GAMEMODE; gamestate = GAMEMODE;
graphics.fademode = 4; graphics.fademode = FADE_START_FADEIN;
map.gotoroom(119, 107); map.gotoroom(119, 107);
int player = obj.getplayer(); int player = obj.getplayer();
if (INBOUNDS_VEC(player, obj.entities)) if (INBOUNDS_VEC(player, obj.entities))
@ -6791,7 +6818,7 @@ void Game::returntoeditor(void)
completestop = false; completestop = false;
state = 0; state = 0;
graphics.showcutscenebars = false; graphics.showcutscenebars = false;
graphics.fademode = 0; graphics.fademode = FADE_NONE;
ed.keydelay = 6; ed.keydelay = 6;
ed.settingskey = true; ed.settingskey = true;

View file

@ -97,8 +97,8 @@ void Graphics::init(void)
SDL_memset(fadebars, 0, sizeof(fadebars)); SDL_memset(fadebars, 0, sizeof(fadebars));
setfade(0); setfade(0);
fademode = 0; fademode = FADE_NONE;
ingame_fademode = 0; ingame_fademode = FADE_NONE;
// initialize everything else to zero // initialize everything else to zero
backBuffer = NULL; backBuffer = NULL;
@ -1451,68 +1451,67 @@ void Graphics::createtextboxflipme(
void Graphics::drawfade(void) void Graphics::drawfade(void)
{ {
int usethisamount = lerp(oldfadeamount, fadeamount); int usethisamount = lerp(oldfadeamount, fadeamount);
if ((fademode == 1)||(fademode == 4)) switch (fademode)
{ {
case FADE_FULLY_BLACK:
case FADE_START_FADEIN:
ClearSurface(backBuffer); ClearSurface(backBuffer);
} break;
else if(fademode==3) case FADE_FADING_OUT:
{
for (size_t i = 0; i < SDL_arraysize(fadebars); i++) for (size_t i = 0; i < SDL_arraysize(fadebars); i++)
{ {
FillRect(backBuffer, fadebars[i], i * 16, usethisamount, 16, 0x000000 ); FillRect(backBuffer, fadebars[i], i * 16, usethisamount, 16, 0x000000 );
} }
} break;
else if(fademode==5 ) case FADE_FADING_IN:
{
for (size_t i = 0; i < SDL_arraysize(fadebars); i++) for (size_t i = 0; i < SDL_arraysize(fadebars); i++)
{ {
FillRect(backBuffer, fadebars[i]-usethisamount, i * 16, 500, 16, 0x000000 ); FillRect(backBuffer, fadebars[i]-usethisamount, i * 16, 500, 16, 0x000000 );
} }
break;
case FADE_NONE:
case FADE_START_FADEOUT:
break;
} }
} }
void Graphics::processfade(void) void Graphics::processfade(void)
{ {
oldfadeamount = fadeamount; oldfadeamount = fadeamount;
if (fademode > 1) switch (fademode)
{ {
if (fademode == 2) case FADE_START_FADEOUT:
for (size_t i = 0; i < SDL_arraysize(fadebars); i++)
{ {
//prepare fade out fadebars[i] = -int(fRandom() * 12) * 8;
for (size_t i = 0; i < SDL_arraysize(fadebars); i++)
{
fadebars[i] = -int(fRandom() * 12) * 8;
}
setfade(0);
fademode = 3;
} }
else if (fademode == 3) setfade(0);
fademode = FADE_FADING_OUT;
break;
case FADE_FADING_OUT:
fadeamount += 24;
if (fadeamount > 416)
{ {
fadeamount += 24; fademode = FADE_FULLY_BLACK;
if (fadeamount > 416)
{
fademode = 1; //faded
}
} }
else if (fademode == 4) break;
case FADE_START_FADEIN:
for (size_t i = 0; i < SDL_arraysize(fadebars); i++)
{ {
//prepare fade in fadebars[i] = 320 + int(fRandom() * 12) * 8;
for (size_t i = 0; i < SDL_arraysize(fadebars); i++)
{
fadebars[i] = 320 + int(fRandom() * 12) * 8;
}
setfade(416);
fademode = 5;
} }
else if (fademode == 5) setfade(416);
fademode = FADE_FADING_IN;
break;
case FADE_FADING_IN:
fadeamount -= 24;
if (fadeamount <= 0)
{ {
fadeamount -= 24; fademode = FADE_NONE;
if (fadeamount <= 0)
{
fademode = 0; //normal
}
} }
case FADE_NONE:
case FADE_FULLY_BLACK:
break;
} }
} }

View file

@ -11,6 +11,18 @@
#include "Textbox.h" #include "Textbox.h"
#include "TowerBG.h" #include "TowerBG.h"
enum FadeBars
{
FADE_NONE,
FADE_FULLY_BLACK,
FADE_START_FADEOUT,
FADE_FADING_OUT,
FADE_START_FADEIN,
FADE_FADING_IN
};
#define FADEMODE_IS_FADING(mode) ((mode) != FADE_NONE && (mode) != FADE_FULLY_BLACK)
class Graphics class Graphics
{ {
public: public:
@ -289,11 +301,11 @@ public:
int crewframe; int crewframe;
int crewframedelay; int crewframedelay;
int fademode; enum FadeBars fademode;
int fadeamount; int fadeamount;
int oldfadeamount; int oldfadeamount;
int fadebars[15]; int fadebars[15];
int ingame_fademode; enum FadeBars ingame_fademode;
bool trinketcolset; bool trinketcolset;
int trinketr, trinketg, trinketb; int trinketr, trinketg, trinketb;

View file

@ -284,7 +284,7 @@ static int gotomode = 0;
static void startmode(const int mode) static void startmode(const int mode)
{ {
gotomode = mode; gotomode = mode;
graphics.fademode = 2; /* fading out */ graphics.fademode = FADE_START_FADEOUT;
fadetomode = true; fadetomode = true;
fadetomodedelay = 19; fadetomodedelay = 19;
} }
@ -1880,7 +1880,7 @@ void titleinput(void)
if (!game.press_action && !game.press_left && !game.press_right && !key.isDown(27) && !key.isDown(game.controllerButton_esc)) game.jumpheld = false; if (!game.press_action && !game.press_left && !game.press_right && !key.isDown(27) && !key.isDown(game.controllerButton_esc)) game.jumpheld = false;
if (!game.press_map) game.mapheld = false; if (!game.press_map) game.mapheld = false;
if (!game.jumpheld && graphics.fademode==0) if (!game.jumpheld && graphics.fademode == FADE_NONE)
{ {
if (game.press_action || game.press_left || game.press_right || game.press_map || key.isDown(27) || key.isDown(game.controllerButton_esc)) if (game.press_action || game.press_left || game.press_right || game.press_map || key.isDown(27) || key.isDown(game.controllerButton_esc))
{ {
@ -2074,7 +2074,7 @@ void gameinput(void)
game.interactheld = false; game.interactheld = false;
} }
if (game.intimetrial && graphics.fademode == 1 && game.quickrestartkludge) if (game.intimetrial && graphics.fademode == FADE_FULLY_BLACK && game.quickrestartkludge)
{ {
//restart the time trial //restart the time trial
game.quickrestartkludge = false; game.quickrestartkludge = false;
@ -2367,10 +2367,10 @@ void gameinput(void)
game.gamesavefailed = false; game.gamesavefailed = false;
game.menupage = 20; // The Map Page game.menupage = 20; // The Map Page
} }
else if (game.intimetrial && graphics.fademode == 0) else if (game.intimetrial && graphics.fademode == FADE_NONE)
{ {
//Quick restart of time trial //Quick restart of time trial
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
game.completestop = true; game.completestop = true;
music.fadeout(); music.fadeout();
game.quickrestartkludge = true; game.quickrestartkludge = true;
@ -2431,7 +2431,7 @@ void mapinput(void)
game.press_map = false; game.press_map = false;
game.press_interact = false; game.press_interact = false;
if (version2_2 && graphics.fademode == 1 && graphics.menuoffset == 0) if (version2_2 && graphics.fademode == FADE_FULLY_BLACK && graphics.menuoffset == 0)
{ {
// Deliberate re-addition of the glitchy gamestate-based fadeout! // Deliberate re-addition of the glitchy gamestate-based fadeout!
@ -2496,7 +2496,7 @@ void mapinput(void)
if(graphics.menuoffset==0 if(graphics.menuoffset==0
&& ((!version2_2 && !game.fadetomenu && game.fadetomenudelay <= 0 && !game.fadetolab && game.fadetolabdelay <= 0) && ((!version2_2 && !game.fadetomenu && game.fadetomenudelay <= 0 && !game.fadetolab && game.fadetolabdelay <= 0)
|| graphics.fademode == 0)) || graphics.fademode == FADE_NONE))
{ {
if (key.isDown(KEYBOARD_LEFT) || key.isDown(KEYBOARD_UP) || key.isDown(KEYBOARD_a) || key.isDown(KEYBOARD_w)|| key.controllerWantsLeft(true)) if (key.isDown(KEYBOARD_LEFT) || key.isDown(KEYBOARD_UP) || key.isDown(KEYBOARD_a) || key.isDown(KEYBOARD_w)|| key.controllerWantsLeft(true))
{ {
@ -2672,7 +2672,7 @@ static void mapmenuactionpress(const bool version2_2)
//Kill contents of offset render buffer, since we do that for some reason. //Kill contents of offset render buffer, since we do that for some reason.
//This fixes an apparent frame flicker. //This fixes an apparent frame flicker.
ClearSurface(graphics.tempBuffer); ClearSurface(graphics.tempBuffer);
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
music.fadeout(); music.fadeout();
map.nexttowercolour(); map.nexttowercolour();
if (!version2_2) if (!version2_2)
@ -2691,7 +2691,7 @@ static void mapmenuactionpress(const bool version2_2)
case 21: case 21:
//quit to menu //quit to menu
game.swnmode = false; game.swnmode = false;
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
music.fadeout(); music.fadeout();
if (!version2_2) if (!version2_2)
{ {
@ -2712,7 +2712,7 @@ static void mapmenuactionpress(const bool version2_2)
graphics.flipmode = false; graphics.flipmode = false;
game.ingame_titlemode = true; game.ingame_titlemode = true;
graphics.ingame_fademode = graphics.fademode; graphics.ingame_fademode = graphics.fademode;
graphics.fademode = 0; graphics.fademode = FADE_NONE;
// Set this before we create the menu // Set this before we create the menu
game.kludge_ingametemp = game.currentmenuname; game.kludge_ingametemp = game.currentmenuname;
@ -2892,9 +2892,9 @@ void gamecompleteinput(void)
game.creditposition -= 6; game.creditposition -= 6;
if (game.creditposition <= -Credits::creditmaxposition) if (game.creditposition <= -Credits::creditmaxposition)
{ {
if(graphics.fademode==0) if (graphics.fademode == FADE_NONE)
{ {
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
} }
game.creditposition = -Credits::creditmaxposition; game.creditposition = -Credits::creditmaxposition;
} }
@ -2911,9 +2911,9 @@ void gamecompleteinput(void)
if(game.press_map) if(game.press_map)
{ {
//Return to game //Return to game
if(graphics.fademode==0) if(graphics.fademode == FADE_NONE)
{ {
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
} }
} }
} }
@ -2936,9 +2936,9 @@ void gamecompleteinput2(void)
game.oldcreditposx++; game.oldcreditposx++;
if (game.creditposy >= 30) if (game.creditposy >= 30)
{ {
if(graphics.fademode==0) if(graphics.fademode == FADE_NONE)
{ {
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
music.fadeout(); music.fadeout();
} }
} }
@ -2951,9 +2951,9 @@ void gamecompleteinput2(void)
if(game.press_map) if(game.press_map)
{ {
//Return to game //Return to game
if(graphics.fademode==0) if(graphics.fademode == FADE_NONE)
{ {
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
music.fadeout(); music.fadeout();
} }
} }

View file

@ -68,7 +68,7 @@ void gamecompletelogic(void)
graphics.titlebg.bscroll = +1; graphics.titlebg.bscroll = +1;
} }
if (graphics.fademode == 1) if (graphics.fademode == FADE_FULLY_BLACK)
{ {
//Fix some graphical things //Fix some graphical things
graphics.showcutscenebars = false; graphics.showcutscenebars = false;
@ -77,7 +77,7 @@ void gamecompletelogic(void)
graphics.titlebg.bypos = 0; graphics.titlebg.bypos = 0;
//Return to game //Return to game
game.gamestate = GAMECOMPLETE2; game.gamestate = GAMECOMPLETE2;
graphics.fademode = 4; graphics.fademode = FADE_START_FADEIN;
} }
} }
@ -100,7 +100,7 @@ void gamecompletelogic2(void)
} }
} }
if (graphics.fademode == 1) if (graphics.fademode == FADE_FULLY_BLACK)
{ {
//Fix some graphical things //Fix some graphical things
graphics.showcutscenebars = false; graphics.showcutscenebars = false;
@ -457,8 +457,11 @@ void gamelogic(void)
game.deathseq = 1; game.deathseq = 1;
game.gethardestroom(); game.gethardestroom();
//start depressing sequence here... //start depressing sequence here...
if (game.gameoverdelay <= -10 && graphics.fademode==0) graphics.fademode = 2; if (game.gameoverdelay <= -10 && graphics.fademode == FADE_NONE)
if (graphics.fademode == 1) {
graphics.fademode = FADE_START_FADEOUT;
}
if (graphics.fademode == FADE_FULLY_BLACK)
{ {
game.copyndmresults(); game.copyndmresults();
script.resetgametomenu(); script.resetgametomenu();
@ -878,7 +881,10 @@ void gamelogic(void)
{ {
//special for tower: is the player touching any spike blocks? //special for tower: is the player touching any spike blocks?
int player = obj.getplayer(); int player = obj.getplayer();
if(INBOUNDS_VEC(player, obj.entities) && obj.checktowerspikes(player) && graphics.fademode==0) if (INBOUNDS_VEC(player, obj.entities)
&& obj.checktowerspikes(player)
/* not really needed, but is slight improvement when exiting to menu near spikes */
&& graphics.fademode == FADE_NONE)
{ {
game.deathseq = 30; game.deathseq = 30;
} }

View file

@ -1716,7 +1716,11 @@ void gamerender(void)
} }
} }
if (graphics.fademode==0 && !game.intimetrial && !game.isingamecompletescreen() && (!game.swnmode || game.swngame != 1) && game.showingametimer) if (graphics.fademode == FADE_NONE
&& !game.intimetrial
&& !game.isingamecompletescreen()
&& (!game.swnmode || game.swngame != 1)
&& game.showingametimer)
{ {
char buffer[SCREEN_WIDTH_CHARS + 1]; char buffer[SCREEN_WIDTH_CHARS + 1];
graphics.bprint(6, 6, "TIME:", 255,255,255); graphics.bprint(6, 6, "TIME:", 255,255,255);
@ -1911,7 +1915,7 @@ void gamerender(void)
} }
} }
if (game.intimetrial && graphics.fademode==0) if (game.intimetrial && graphics.fademode == FADE_NONE)
{ {
//Draw countdown! //Draw countdown!
if (game.timetrialcountdown > 0) if (game.timetrialcountdown > 0)
@ -2703,8 +2707,7 @@ void maprender(void)
// being jankily brought down in glitchrunner mode when exiting to the title // being jankily brought down in glitchrunner mode when exiting to the title
// Otherwise, there's no reason to obscure the menu // Otherwise, there's no reason to obscure the menu
if (GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2) if (GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2)
|| graphics.fademode == 3 || FADEMODE_IS_FADING(graphics.fademode)
|| graphics.fademode == 5
|| game.fadetomenu || game.fadetomenu
|| game.fadetolab) || game.fadetolab)
{ {

View file

@ -1298,19 +1298,19 @@ void scriptclass::run(void)
else if (words[0] == "befadein") else if (words[0] == "befadein")
{ {
graphics.setfade(0); graphics.setfade(0);
graphics.fademode= 0; graphics.fademode = FADE_NONE;
} }
else if (words[0] == "fadein") else if (words[0] == "fadein")
{ {
graphics.fademode = 4; graphics.fademode = FADE_START_FADEIN;
} }
else if (words[0] == "fadeout") else if (words[0] == "fadeout")
{ {
graphics.fademode = 2; graphics.fademode = FADE_START_FADEOUT;
} }
else if (words[0] == "untilfade") else if (words[0] == "untilfade")
{ {
if (graphics.fademode>1) if (FADEMODE_IS_FADING(graphics.fademode))
{ {
scriptdelay = 1; scriptdelay = 1;
position--; position--;
@ -1383,7 +1383,7 @@ void scriptclass::run(void)
#endif #endif
{ {
game.gamestate = GAMECOMPLETE; game.gamestate = GAMECOMPLETE;
graphics.fademode = 4; graphics.fademode = FADE_START_FADEIN;
game.creditposition = 0; game.creditposition = 0;
} }
} }
@ -2374,7 +2374,7 @@ static void gotoerrorloadinglevel(void)
{ {
game.createmenu(Menu::errorloadinglevel); game.createmenu(Menu::errorloadinglevel);
map.nexttowercolour(); map.nexttowercolour();
graphics.fademode = 4; /* start fade in */ graphics.fademode = FADE_START_FADEIN; /* start fade in */
music.currentsong = -1; /* otherwise music.play won't work */ music.currentsong = -1; /* otherwise music.play won't work */
music.play(6); /* title screen music */ music.play(6); /* title screen music */
} }
@ -2424,7 +2424,7 @@ void scriptclass::startgamemode( int t )
map.resetplayer(); map.resetplayer();
map.gotoroom(game.saverx, game.savery); map.gotoroom(game.saverx, game.savery);
map.initmapdata(); map.initmapdata();
graphics.fademode = 4; graphics.fademode = FADE_START_FADEIN;
break; break;
case 2: //Load Quicksave case 2: //Load Quicksave
game.gamestate = GAMEMODE; game.gamestate = GAMEMODE;
@ -2460,7 +2460,7 @@ void scriptclass::startgamemode( int t )
map.cameramode = 0; map.cameramode = 0;
map.colsuperstate = 0; map.colsuperstate = 0;
} }
graphics.fademode = 4; graphics.fademode = FADE_START_FADEIN;
break; break;
case 3: case 3:
case 4: case 4:
@ -2522,7 +2522,7 @@ void scriptclass::startgamemode( int t )
map.resetplayer(); map.resetplayer();
map.gotoroom(game.saverx, game.savery); map.gotoroom(game.saverx, game.savery);
map.initmapdata(); map.initmapdata();
graphics.fademode = 4; graphics.fademode = FADE_START_FADEIN;
break; break;
case 9: case 9:
game.gamestate = GAMEMODE; game.gamestate = GAMEMODE;
@ -2597,7 +2597,7 @@ void scriptclass::startgamemode( int t )
map.gotoroom(game.saverx, game.savery); map.gotoroom(game.saverx, game.savery);
map.initmapdata(); map.initmapdata();
music.play(11); music.play(11);
graphics.fademode = 4; graphics.fademode = FADE_START_FADEIN;
break; break;
case 12: case 12:
game.gamestate = GAMEMODE; game.gamestate = GAMEMODE;
@ -2857,7 +2857,7 @@ void scriptclass::startgamemode( int t )
map.resetplayer(); map.resetplayer();
map.gotoroom(game.saverx, game.savery); map.gotoroom(game.saverx, game.savery);
map.initmapdata(); map.initmapdata();
graphics.fademode = 4; graphics.fademode = FADE_START_FADEIN;
break; break;
case 21: //play custom level (in editor) case 21: //play custom level (in editor)
game.gamestate = GAMEMODE; game.gamestate = GAMEMODE;
@ -2934,7 +2934,7 @@ void scriptclass::startgamemode( int t )
}else{ }else{
music.currentsong=-1; music.currentsong=-1;
} }
graphics.fademode = 4; graphics.fademode = FADE_START_FADEIN;
break; break;
} }
case 23: //Continue in custom level case 23: //Continue in custom level
@ -2972,7 +2972,7 @@ void scriptclass::startgamemode( int t )
map.gotoroom(game.saverx, game.savery); map.gotoroom(game.saverx, game.savery);
map.initmapdata(); map.initmapdata();
cl.generatecustomminimap(); cl.generatecustomminimap();
graphics.fademode = 4; graphics.fademode = FADE_START_FADEIN;
break; break;
} }
#endif /* NO_CUSTOM_LEVELS */ #endif /* NO_CUSTOM_LEVELS */

View file

@ -656,7 +656,7 @@ int main(int argc, char *argv[])
script.startgamemode(22); script.startgamemode(22);
} }
graphics.fademode = 0; graphics.fademode = FADE_NONE;
} }
#endif #endif