mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-22 08:49:46 +01:00
Use enums for swngame
This replaces the swngame int variable with a named enum and enforces strict typechecking on it. Strict typechecking is okay here as the swngame variable is not part of the API surface of the game in any way and is completely internal. And just to make things clear, I've added a SWN_NONE enum to use for initialization, because previously it was being initialized to 0, even though 0 was the Gravitron.
This commit is contained in:
parent
414b0647aa
commit
14d034e4c6
8 changed files with 66 additions and 44 deletions
|
@ -1762,7 +1762,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int
|
||||||
entity.colour = 21;
|
entity.colour = 21;
|
||||||
entity.tile = 78; //default case
|
entity.tile = 78; //default case
|
||||||
entity.animate = 1;
|
entity.animate = 1;
|
||||||
if (game.swngame == 1)
|
if (game.swngame == SWN_SUPERGRAVITRON)
|
||||||
{
|
{
|
||||||
//set colour based on current state
|
//set colour based on current state
|
||||||
entity.colour = swncolour(game.swncolstate);
|
entity.colour = swncolour(game.swncolstate);
|
||||||
|
|
|
@ -316,7 +316,7 @@ void Game::init(void)
|
||||||
inertia = 1.1f;
|
inertia = 1.1f;
|
||||||
swnmode = false;
|
swnmode = false;
|
||||||
swntimer = 0;
|
swntimer = 0;
|
||||||
swngame = 0;//Not playing sine wave ninja!
|
swngame = SWN_NONE; // Not playing sine wave ninja!
|
||||||
swnstate = 0;
|
swnstate = 0;
|
||||||
swnstate2 = 0;
|
swnstate2 = 0;
|
||||||
swnstate3 = 0;
|
swnstate3 = 0;
|
||||||
|
@ -943,7 +943,7 @@ void Game::updatestate(void)
|
||||||
obj.removetrigger(9);
|
obj.removetrigger(9);
|
||||||
|
|
||||||
swnmode = true;
|
swnmode = true;
|
||||||
swngame = 6;
|
swngame = SWN_START_SUPERGRAVITRON_STEP_1;
|
||||||
swndelay = 150;
|
swndelay = 150;
|
||||||
swntimer = 60 * 30;
|
swntimer = 60 * 30;
|
||||||
|
|
||||||
|
@ -964,7 +964,7 @@ void Game::updatestate(void)
|
||||||
obj.removetrigger(10);
|
obj.removetrigger(10);
|
||||||
|
|
||||||
swnmode = true;
|
swnmode = true;
|
||||||
swngame = 4;
|
swngame = SWN_START_GRAVITRON_STEP_1;
|
||||||
swndelay = 150;
|
swndelay = 150;
|
||||||
swntimer = 60 * 30;
|
swntimer = 60 * 30;
|
||||||
|
|
||||||
|
@ -7479,7 +7479,9 @@ bool Game::incompetitive(void)
|
||||||
return (
|
return (
|
||||||
!map.custommode
|
!map.custommode
|
||||||
&& swnmode
|
&& swnmode
|
||||||
&& (swngame == 1 || swngame == 6 || swngame == 7)
|
&& (swngame == SWN_SUPERGRAVITRON ||
|
||||||
|
swngame == SWN_START_SUPERGRAVITRON_STEP_1 ||
|
||||||
|
swngame == SWN_START_SUPERGRAVITRON_STEP_2)
|
||||||
)
|
)
|
||||||
|| intimetrial
|
|| intimetrial
|
||||||
|| nodeathmode;
|
|| nodeathmode;
|
||||||
|
|
|
@ -117,6 +117,21 @@ enum SLIDERMODE
|
||||||
SLIDER_SOUNDVOLUME
|
SLIDER_SOUNDVOLUME
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* enums for swngame variable */
|
||||||
|
enum SWNMODE
|
||||||
|
{
|
||||||
|
SWN_GRAVITRON,
|
||||||
|
SWN_SUPERGRAVITRON,
|
||||||
|
SWN_START_GRAVITRON_STEP_3,
|
||||||
|
SWN_START_GRAVITRON_STEP_2,
|
||||||
|
SWN_START_GRAVITRON_STEP_1,
|
||||||
|
SWN_FINISH_GRAVITRON_STEP_1,
|
||||||
|
SWN_START_SUPERGRAVITRON_STEP_1,
|
||||||
|
SWN_START_SUPERGRAVITRON_STEP_2,
|
||||||
|
SWN_FINISH_GRAVITRON_STEP_2,
|
||||||
|
SWN_NONE
|
||||||
|
};
|
||||||
|
|
||||||
struct MenuStackFrame
|
struct MenuStackFrame
|
||||||
{
|
{
|
||||||
int option;
|
int option;
|
||||||
|
@ -334,7 +349,8 @@ public:
|
||||||
|
|
||||||
//Sine Wave Ninja Minigame
|
//Sine Wave Ninja Minigame
|
||||||
bool swnmode;
|
bool swnmode;
|
||||||
int swngame, swnstate, swnstate2, swnstate3, swnstate4, swndelay, swndeaths;
|
enum SWNMODE swngame;
|
||||||
|
int swnstate, swnstate2, swnstate3, swnstate4, swndelay, swndeaths;
|
||||||
int swntimer, swncolstate, swncoldelay;
|
int swntimer, swncolstate, swncoldelay;
|
||||||
int swnrecord, swnbestrank, swnrank, swnmessage;
|
int swnrecord, swnbestrank, swnrank, swnmessage;
|
||||||
|
|
||||||
|
|
|
@ -2009,7 +2009,8 @@ void Graphics::drawentity(const int i, const int yoff)
|
||||||
case 5: //Horizontal Line
|
case 5: //Horizontal Line
|
||||||
{
|
{
|
||||||
int oldw = obj.entities[i].w;
|
int oldw = obj.entities[i].w;
|
||||||
if ((game.swngame == 3 || kludgeswnlinewidth) && obj.getlineat(84 - 32) == i)
|
if ((game.swngame == SWN_START_GRAVITRON_STEP_2 || kludgeswnlinewidth)
|
||||||
|
&& obj.getlineat(84 - 32) == i)
|
||||||
{
|
{
|
||||||
oldw -= 24;
|
oldw -= 24;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2763,7 +2763,9 @@ void gameinput(void)
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
else if (game.swnmode == 1
|
else if (game.swnmode == 1
|
||||||
&& (game.swngame == 1 || game.swngame == 6 || game.swngame == 7))
|
&& (game.swngame == SWN_SUPERGRAVITRON ||
|
||||||
|
game.swngame == SWN_START_SUPERGRAVITRON_STEP_1 ||
|
||||||
|
game.swngame == SWN_START_SUPERGRAVITRON_STEP_2))
|
||||||
{
|
{
|
||||||
//quitting the super gravitron
|
//quitting the super gravitron
|
||||||
game.mapheld = true;
|
game.mapheld = true;
|
||||||
|
|
|
@ -429,11 +429,11 @@ void gamelogic(void)
|
||||||
if (game.swnmode)
|
if (game.swnmode)
|
||||||
{
|
{
|
||||||
//if playing SWN game a, push the clock back to the nearest 10 second interval
|
//if playing SWN game a, push the clock back to the nearest 10 second interval
|
||||||
if (game.swngame == 0)
|
if (game.swngame == SWN_GRAVITRON)
|
||||||
{
|
{
|
||||||
game.swnpenalty();
|
game.swnpenalty();
|
||||||
}
|
}
|
||||||
else if (game.swngame == 1)
|
else if (game.swngame == SWN_SUPERGRAVITRON)
|
||||||
{
|
{
|
||||||
game.swnstate = 0;
|
game.swnstate = 0;
|
||||||
game.swnstate2 = 0;
|
game.swnstate2 = 0;
|
||||||
|
@ -481,7 +481,7 @@ void gamelogic(void)
|
||||||
if (game.swnmode)
|
if (game.swnmode)
|
||||||
{
|
{
|
||||||
//if playing SWN game b, reset the clock
|
//if playing SWN game b, reset the clock
|
||||||
if (game.swngame == 1)
|
if (game.swngame == SWN_SUPERGRAVITRON)
|
||||||
{
|
{
|
||||||
game.swntimer = 0;
|
game.swntimer = 0;
|
||||||
game.swnmessage = 0;
|
game.swnmessage = 0;
|
||||||
|
@ -557,21 +557,21 @@ void gamelogic(void)
|
||||||
//SWN Minigame Logic
|
//SWN Minigame Logic
|
||||||
if (game.swnmode) //which game?
|
if (game.swnmode) //which game?
|
||||||
{
|
{
|
||||||
if(game.swngame==0) //intermission, survive 60 seconds game
|
switch (game.swngame)
|
||||||
{
|
{
|
||||||
|
case SWN_GRAVITRON: // intermission, survive 60 seconds game
|
||||||
game.swntimer -= 1;
|
game.swntimer -= 1;
|
||||||
if (game.swntimer <= 0)
|
if (game.swntimer <= 0)
|
||||||
{
|
{
|
||||||
music.niceplay(Music_PREDESTINEDFATE);
|
music.niceplay(Music_PREDESTINEDFATE);
|
||||||
game.swngame = 5;
|
game.swngame = SWN_FINISH_GRAVITRON_STEP_1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
obj.generateswnwave(0);
|
obj.generateswnwave(0);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if(game.swngame==1) //super gravitron game
|
case SWN_SUPERGRAVITRON:
|
||||||
{
|
|
||||||
game.swntimer += 1;
|
game.swntimer += 1;
|
||||||
#ifndef MAKEANDPLAY
|
#ifndef MAKEANDPLAY
|
||||||
if (!map.custommode)
|
if (!map.custommode)
|
||||||
|
@ -660,19 +660,18 @@ void gamelogic(void)
|
||||||
graphics.rcol = game.swncolstate;
|
graphics.rcol = game.swncolstate;
|
||||||
obj.swnenemiescol(game.swncolstate);
|
obj.swnenemiescol(game.swncolstate);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (game.swngame == 2) //introduce game a
|
case SWN_START_GRAVITRON_STEP_3: //introduce game a
|
||||||
{
|
|
||||||
game.swndelay--;
|
game.swndelay--;
|
||||||
if (game.swndelay <= 0)
|
if (game.swndelay <= 0)
|
||||||
{
|
{
|
||||||
game.swngame = 0;
|
game.swngame = SWN_GRAVITRON;
|
||||||
game.swndelay = 0;
|
game.swndelay = 0;
|
||||||
game.swntimer = (60 * 30) - 1;
|
game.swntimer = (60 * 30) - 1;
|
||||||
//game.swntimer = 15;
|
//game.swntimer = 15;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (game.swngame == 3) //extend line
|
case SWN_START_GRAVITRON_STEP_2: //extend line
|
||||||
{
|
{
|
||||||
int line = obj.getlineat(84 - 32);
|
int line = obj.getlineat(84 - 32);
|
||||||
if (INBOUNDS_VEC(line, obj.entities))
|
if (INBOUNDS_VEC(line, obj.entities))
|
||||||
|
@ -681,19 +680,19 @@ void gamelogic(void)
|
||||||
if (obj.entities[line].w > 332)
|
if (obj.entities[line].w > 332)
|
||||||
{
|
{
|
||||||
obj.entities[line].w = 332;
|
obj.entities[line].w = 332;
|
||||||
game.swngame = 2;
|
game.swngame = SWN_START_GRAVITRON_STEP_3;
|
||||||
graphics.kludgeswnlinewidth = true;
|
graphics.kludgeswnlinewidth = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (game.swngame == 4) //create top line
|
case SWN_START_GRAVITRON_STEP_1: //create top line
|
||||||
{
|
game.swngame = SWN_START_GRAVITRON_STEP_2;
|
||||||
game.swngame = 3;
|
|
||||||
obj.createentity(-8, 84 - 32, 11, 8); // (horizontal gravity line)
|
obj.createentity(-8, 84 - 32, 11, 8); // (horizontal gravity line)
|
||||||
music.niceplay(Music_POSITIVEFORCE);
|
music.niceplay(Music_POSITIVEFORCE);
|
||||||
game.swndeaths = game.deathcounts;
|
game.swndeaths = game.deathcounts;
|
||||||
}
|
break;
|
||||||
else if (game.swngame == 5) //remove line
|
case SWN_FINISH_GRAVITRON_STEP_1: //remove line
|
||||||
{
|
{
|
||||||
int line = obj.getlineat(148 + 32);
|
int line = obj.getlineat(148 + 32);
|
||||||
if (INBOUNDS_VEC(line, obj.entities))
|
if (INBOUNDS_VEC(line, obj.entities))
|
||||||
|
@ -702,28 +701,27 @@ void gamelogic(void)
|
||||||
if (obj.entities[line].xp > 320)
|
if (obj.entities[line].xp > 320)
|
||||||
{
|
{
|
||||||
obj.disableentity(line);
|
obj.disableentity(line);
|
||||||
game.swngame = 8;
|
game.swngame = SWN_FINISH_GRAVITRON_STEP_2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (game.swngame == 6) //Init the super gravitron
|
case SWN_START_SUPERGRAVITRON_STEP_1: //Init the super gravitron
|
||||||
{
|
game.swngame = SWN_START_SUPERGRAVITRON_STEP_2;
|
||||||
game.swngame = 7;
|
|
||||||
music.niceplay(Music_POTENTIALFORANYTHING);
|
music.niceplay(Music_POTENTIALFORANYTHING);
|
||||||
}
|
break;
|
||||||
else if (game.swngame == 7) //introduce game b
|
case SWN_START_SUPERGRAVITRON_STEP_2: //introduce game b
|
||||||
{
|
|
||||||
game.swndelay--;
|
game.swndelay--;
|
||||||
if (game.swndelay <= 0)
|
if (game.swndelay <= 0)
|
||||||
{
|
{
|
||||||
game.swngame = 1;
|
game.swngame = SWN_SUPERGRAVITRON;
|
||||||
game.swndelay = 0;
|
game.swndelay = 0;
|
||||||
game.swntimer = 0;
|
game.swntimer = 0;
|
||||||
game.swncolstate = 3;
|
game.swncolstate = 3;
|
||||||
game.swncoldelay = 30;
|
game.swncoldelay = 30;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (game.swngame == 8) //extra kludge if player dies after game a ends
|
case SWN_FINISH_GRAVITRON_STEP_2: //extra kludge if player dies after game a ends
|
||||||
{
|
{
|
||||||
bool square_onscreen = false;
|
bool square_onscreen = false;
|
||||||
for (size_t i = 0; i < obj.entities.size(); i++)
|
for (size_t i = 0; i < obj.entities.size(); i++)
|
||||||
|
@ -739,6 +737,9 @@ void gamelogic(void)
|
||||||
game.swnmode = false;
|
game.swnmode = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case SWN_NONE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Time trial stuff
|
//Time trial stuff
|
||||||
|
|
|
@ -2020,7 +2020,7 @@ void gamerender(void)
|
||||||
if (graphics.fademode == FADE_NONE
|
if (graphics.fademode == FADE_NONE
|
||||||
&& !game.intimetrial
|
&& !game.intimetrial
|
||||||
&& !game.isingamecompletescreen()
|
&& !game.isingamecompletescreen()
|
||||||
&& (!game.swnmode || game.swngame != 1)
|
&& (!game.swnmode || game.swngame != SWN_SUPERGRAVITRON)
|
||||||
&& game.showingametimer
|
&& game.showingametimer
|
||||||
&& !roomname_translator::enabled)
|
&& !roomname_translator::enabled)
|
||||||
{
|
{
|
||||||
|
@ -2129,12 +2129,12 @@ void gamerender(void)
|
||||||
|
|
||||||
if (game.swnmode)
|
if (game.swnmode)
|
||||||
{
|
{
|
||||||
if (game.swngame == 0)
|
if (game.swngame == SWN_GRAVITRON)
|
||||||
{
|
{
|
||||||
std::string tempstring = help.timestring(game.swntimer);
|
std::string tempstring = help.timestring(game.swntimer);
|
||||||
font::print(PR_2X | PR_CEN | PR_BOR, -1, 20, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2));
|
font::print(PR_2X | PR_CEN | PR_BOR, -1, 20, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2));
|
||||||
}
|
}
|
||||||
else if (game.swngame == 1)
|
else if (game.swngame == SWN_SUPERGRAVITRON)
|
||||||
{
|
{
|
||||||
if (game.swnmessage == 0)
|
if (game.swnmessage == 0)
|
||||||
{
|
{
|
||||||
|
@ -2210,7 +2210,7 @@ void gamerender(void)
|
||||||
);
|
);
|
||||||
font::print(PR_BOR | PR_CEN, -1, 228, buffer, 160 - (help.glow/2), 160 - (help.glow/2), 160 - (help.glow/2));
|
font::print(PR_BOR | PR_CEN, -1, 228, buffer, 160 - (help.glow/2), 160 - (help.glow/2), 160 - (help.glow/2));
|
||||||
}
|
}
|
||||||
else if(game.swngame==2)
|
else if (game.swngame == SWN_START_GRAVITRON_STEP_3)
|
||||||
{
|
{
|
||||||
if (int(game.swndelay / 15) % 2 == 1 || game.swndelay >= 120)
|
if (int(game.swndelay / 15) % 2 == 1 || game.swndelay >= 120)
|
||||||
{
|
{
|
||||||
|
@ -2230,7 +2230,7 @@ void gamerender(void)
|
||||||
font::print(PR_2X | PR_CEN | PR_BOR, -1, y2, loc::gettext("60 seconds!"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2));
|
font::print(PR_2X | PR_CEN | PR_BOR, -1, y2, loc::gettext("60 seconds!"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(game.swngame==7)
|
else if (game.swngame == SWN_START_SUPERGRAVITRON_STEP_2)
|
||||||
{
|
{
|
||||||
if (game.swndelay >= 60)
|
if (game.swndelay >= 60)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3140,7 +3140,7 @@ void scriptclass::hardreset(void)
|
||||||
|
|
||||||
game.swnmode = false;
|
game.swnmode = false;
|
||||||
game.swntimer = 0;
|
game.swntimer = 0;
|
||||||
game.swngame = 0;//Not playing sine wave ninja!
|
game.swngame = SWN_NONE; // Not playing sine wave ninja!
|
||||||
game.swnstate = 0;
|
game.swnstate = 0;
|
||||||
game.swnstate2 = 0;
|
game.swnstate2 = 0;
|
||||||
game.swnstate3 = 0;
|
game.swnstate3 = 0;
|
||||||
|
|
Loading…
Reference in a new issue