mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 01:48:15 +03: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:
@@ -68,7 +68,7 @@ void gamecompletelogic(void)
|
||||
graphics.titlebg.bscroll = +1;
|
||||
}
|
||||
|
||||
if (graphics.fademode == 1)
|
||||
if (graphics.fademode == FADE_FULLY_BLACK)
|
||||
{
|
||||
//Fix some graphical things
|
||||
graphics.showcutscenebars = false;
|
||||
@@ -77,7 +77,7 @@ void gamecompletelogic(void)
|
||||
graphics.titlebg.bypos = 0;
|
||||
//Return to game
|
||||
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
|
||||
graphics.showcutscenebars = false;
|
||||
@@ -457,8 +457,11 @@ void gamelogic(void)
|
||||
game.deathseq = 1;
|
||||
game.gethardestroom();
|
||||
//start depressing sequence here...
|
||||
if (game.gameoverdelay <= -10 && graphics.fademode==0) graphics.fademode = 2;
|
||||
if (graphics.fademode == 1)
|
||||
if (game.gameoverdelay <= -10 && graphics.fademode == FADE_NONE)
|
||||
{
|
||||
graphics.fademode = FADE_START_FADEOUT;
|
||||
}
|
||||
if (graphics.fademode == FADE_FULLY_BLACK)
|
||||
{
|
||||
game.copyndmresults();
|
||||
script.resetgametomenu();
|
||||
@@ -878,7 +881,10 @@ void gamelogic(void)
|
||||
{
|
||||
//special for tower: is the player touching any spike blocks?
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user