mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +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:
@@ -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];
|
||||
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!
|
||||
if (game.timetrialcountdown > 0)
|
||||
@@ -2703,8 +2707,7 @@ void maprender(void)
|
||||
// being jankily brought down in glitchrunner mode when exiting to the title
|
||||
// Otherwise, there's no reason to obscure the menu
|
||||
if (GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2)
|
||||
|| graphics.fademode == 3
|
||||
|| graphics.fademode == 5
|
||||
|| FADEMODE_IS_FADING(graphics.fademode)
|
||||
|| game.fadetomenu
|
||||
|| game.fadetolab)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user