1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-25 05:58:30 +02:00

Use case-switch in mapmenuactionpress()

This prevents from having to repeat 'if (game.menupage == ...)'
everywhere, which makes for more concise code.

I know you're technically supposed to indent the cases surrounded by
if-guards, but I don't think indenting them here would help anything.
I'd only indent it if the 'if' had an 'else', for example. But if it
surrounds the whole case, then there's no need for indentation.
This commit is contained in:
Misa 2020-06-22 15:35:26 -07:00 committed by Ethan Lee
parent 5717afaa37
commit 949e99c950

View File

@ -1996,7 +1996,10 @@ void mapinput()
void mapmenuactionpress()
{
if (game.menupage == 1 && obj.flags[67] && !game.insecretlab && !map.custommode)
switch (game.menupage)
{
case 1:
if (obj.flags[67] && !game.insecretlab && !map.custommode)
{
//Warp back to the ship
graphics.resumegamemode = true;
@ -2019,8 +2022,9 @@ void mapmenuactionpress()
game.state = 4000;
game.statedelay = 0;
}
if (game.menupage == 3 && !game.gamesaved && !game.intimetrial
break;
case 3:
if (!game.gamesaved && !game.intimetrial
&& !game.nodeathmode && !game.insecretlab && !game.inintermission)
{
game.flashlight = 5;
@ -2045,14 +2049,13 @@ void mapmenuactionpress()
game.savequick();
}
}
break;
if (game.menupage == 10)
{
case 10:
//return to game
graphics.resumegamemode = true;
}
if (game.menupage == 11)
{
break;
case 11:
//quit to menu
//Kill contents of offset render buffer, since we do that for some reason.
@ -2063,21 +2066,20 @@ void mapmenuactionpress()
map.nexttowercolour();
game.fadetomenu = true;
game.fadetomenudelay = 16;
}
break;
if (game.menupage == 20)
{
case 20:
//return to game
graphics.resumegamemode = true;
}
if (game.menupage == 21)
{
break;
case 21:
//quit to menu
game.swnmode = false;
graphics.fademode = 2;
music.fadeout();
game.fadetolab = true;
game.fadetolabdelay = 16;
break;
}
}