From e931f2a4a1718a95957599a69984b0f35c15253f Mon Sep 17 00:00:00 2001 From: Misa Date: Mon, 5 Jun 2023 17:34:27 -0700 Subject: [PATCH] Use enums for unlock, unlocknotify, unlocknum This adds an anonymous enum for the unlock and unlocknotify arrays and unlocknum function, and replaces all integer literals with them. This is not named and thus cannot be used for strict typechecking because these are actually indexes into an array in XML save files, so the numbers themselves matter a lot. --- desktop_version/src/Entity.cpp | 6 +- desktop_version/src/Game.cpp | 168 ++++++++++++++++++++------------- desktop_version/src/Game.h | 26 +++++ desktop_version/src/Input.cpp | 81 +++++++++------- desktop_version/src/Render.cpp | 22 ++--- desktop_version/src/Script.cpp | 2 +- desktop_version/src/main.cpp | 15 ++- 7 files changed, 202 insertions(+), 118 deletions(-) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index 32d21731..5233c769 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -1871,7 +1871,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 7: - if(game.unlock[5]) + if (game.unlock[UnlockTrophy_GAME_COMPLETE]) { entity.tile = 188 + meta1; entity.colour = 37; @@ -1880,7 +1880,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int } break; case 8: - if(game.unlock[19]) + if (game.unlock[UnlockTrophy_FLIPMODE_COMPLETE]) { entity.tile = 188 + meta1; entity.colour = 37; @@ -1973,7 +1973,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 19: - if(game.unlock[20]) + if (game.unlock[UnlockTrophy_NODEATHMODE_COMPLETE]) { entity.tile = 3; entity.colour = 102; diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 1181f69f..50105785 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -2462,7 +2462,7 @@ void Game::updatestate(void) case 3006: //Level complete! (warp zone) - unlocknum(4); + unlocknum(Unlock_WARPZONE_COMPLETE); lastsaved = 4; music.play(Music_PATHCOMPLETE); incstate(); @@ -2503,7 +2503,7 @@ void Game::updatestate(void) case 3020: //Level complete! (Space Station 2) - unlocknum(3); + unlocknum(Unlock_SPACESTATION2_COMPLETE); lastsaved = 2; music.play(Music_PATHCOMPLETE); incstate(); @@ -2545,7 +2545,7 @@ void Game::updatestate(void) case 3040: //Level complete! (Lab) - unlocknum(1); + unlocknum(Unlock_LABORATORY_COMPLETE); lastsaved = 5; music.play(Music_PATHCOMPLETE); incstate(); @@ -2586,7 +2586,7 @@ void Game::updatestate(void) case 3050: //Level complete! (Space Station 1) - unlocknum(0); + unlocknum(Unlock_SPACESTATION1_COMPLETE); lastsaved = 1; music.play(Music_PATHCOMPLETE); incstate(); @@ -2653,7 +2653,7 @@ void Game::updatestate(void) case 3060: //Level complete! (Tower) - unlocknum(2); + unlocknum(Unlock_TOWER_COMPLETE); lastsaved = 3; music.play(Music_PATHCOMPLETE); incstate(); @@ -2782,7 +2782,7 @@ void Game::updatestate(void) } else { - unlocknum(7); + unlocknum(Unlock_INTERMISSION2_COMPLETE); graphics.fademode = FADE_START_FADEOUT; companion = 0; incstate(); @@ -2815,7 +2815,7 @@ void Game::updatestate(void) } else { - unlocknum(6); + unlocknum(Unlock_INTERMISSION1_COMPLETE); graphics.fademode = FADE_START_FADEOUT; companion = 0; supercrewmate = false; @@ -2875,7 +2875,7 @@ void Game::updatestate(void) case 3501: //Game complete! unlockAchievement("vvvvvvgamecomplete"); - unlocknum(5); + unlocknum(UnlockTrophy_GAME_COMPLETE); crewstats[0] = true; incstate(); setstatedelay(75); @@ -2994,7 +2994,7 @@ void Game::updatestate(void) { //flip mode complete unlockAchievement("vvvvvvgamecompleteflip"); - unlocknum(19); + unlocknum(UnlockTrophy_FLIPMODE_COMPLETE); } #ifndef MAKEANDPLAY @@ -3033,7 +3033,7 @@ void Game::updatestate(void) if (nodeathmode) { unlockAchievement("vvvvvvmaster"); //bloody hell - unlocknum(20); + unlocknum(UnlockTrophy_NODEATHMODE_COMPLETE); setstate(3520); setstatedelay(0); } @@ -6406,7 +6406,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) break; case Menu::gameplayoptions: #if !defined(MAKEANDPLAY) - if (ingame_titlemode && unlock[18]) + if (ingame_titlemode && unlock[Unlock_FLIPMODE]) #endif { option(loc::gettext("flip mode")); @@ -6694,11 +6694,11 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) break; case Menu::unlockmenu: option(loc::gettext("unlock time trials")); - option(loc::gettext("unlock intermissions"), !unlock[16]); - option(loc::gettext("unlock no death mode"), !unlock[17]); - option(loc::gettext("unlock flip mode"), !unlock[18]); + option(loc::gettext("unlock intermissions"), !unlock[Unlock_INTERMISSION_REPLAYS]); + option(loc::gettext("unlock no death mode"), !unlock[Unlock_NODEATHMODE]); + option(loc::gettext("unlock flip mode"), !unlock[Unlock_FLIPMODE]); option(loc::gettext("unlock ship jukebox"), (stat_trinkets<20)); - option(loc::gettext("unlock secret lab"), !unlock[8]); + option(loc::gettext("unlock secret lab"), !unlock[Unlock_SECRETLAB]); option(loc::gettext("return")); menuyoff = -20; break; @@ -6729,44 +6729,74 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) //Ok, here's where the unlock stuff comes into it: //First up, time trials: int temp = 0; - if (unlock[0] && stat_trinkets >= 3 && !unlocknotify[9]) temp++; - if (unlock[1] && stat_trinkets >= 6 && !unlocknotify[10]) temp++; - if (unlock[2] && stat_trinkets >= 9 && !unlocknotify[11]) temp++; - if (unlock[3] && stat_trinkets >= 12 && !unlocknotify[12]) temp++; - if (unlock[4] && stat_trinkets >= 15 && !unlocknotify[13]) temp++; - if (unlock[5] && stat_trinkets >= 18 && !unlocknotify[14]) temp++; + if (unlock[Unlock_SPACESTATION1_COMPLETE] + && stat_trinkets >= 3 + && !unlocknotify[Unlock_TIMETRIAL_SPACESTATION1]) + { + temp++; + } + if (unlock[Unlock_LABORATORY_COMPLETE] + && stat_trinkets >= 6 + && !unlocknotify[Unlock_TIMETRIAL_LABORATORY]) + { + temp++; + } + if (unlock[Unlock_TOWER_COMPLETE] + && stat_trinkets >= 9 + && !unlocknotify[Unlock_TIMETRIAL_TOWER]) + { + temp++; + } + if (unlock[Unlock_SPACESTATION2_COMPLETE] + && stat_trinkets >= 12 + && !unlocknotify[Unlock_TIMETRIAL_SPACESTATION2]) + { + temp++; + } + if (unlock[Unlock_WARPZONE_COMPLETE] + && stat_trinkets >= 15 + && !unlocknotify[Unlock_TIMETRIAL_WARPZONE]) + { + temp++; + } + if (unlock[UnlockTrophy_GAME_COMPLETE] + && stat_trinkets >= 18 + && !unlocknotify[Unlock_TIMETRIAL_FINALLEVEL]) + { + temp++; + } if (temp > 0) { //you've unlocked a time trial! - if (unlock[0] && stat_trinkets >= 3) + if (unlock[Unlock_SPACESTATION1_COMPLETE] && stat_trinkets >= 3) { - unlocknotify[9] = true; - unlock[9] = true; + unlocknotify[Unlock_TIMETRIAL_SPACESTATION1] = true; + unlock[Unlock_TIMETRIAL_SPACESTATION1] = true; } - if (unlock[1] && stat_trinkets >= 6) + if (unlock[Unlock_LABORATORY_COMPLETE] && stat_trinkets >= 6) { - unlocknotify[10] = true; - unlock[10] = true; + unlocknotify[Unlock_TIMETRIAL_LABORATORY] = true; + unlock[Unlock_TIMETRIAL_LABORATORY] = true; } - if (unlock[2] && stat_trinkets >= 9) + if (unlock[Unlock_TOWER_COMPLETE] && stat_trinkets >= 9) { - unlocknotify[11] = true; - unlock[11] = true; + unlocknotify[Unlock_TIMETRIAL_TOWER] = true; + unlock[Unlock_TIMETRIAL_TOWER] = true; } - if (unlock[3] && stat_trinkets >= 12) + if (unlock[Unlock_SPACESTATION2_COMPLETE] && stat_trinkets >= 12) { - unlocknotify[12] = true; - unlock[12] = true; + unlocknotify[Unlock_TIMETRIAL_SPACESTATION2] = true; + unlock[Unlock_TIMETRIAL_SPACESTATION2] = true; } - if (unlock[4] && stat_trinkets >= 15) + if (unlock[Unlock_WARPZONE_COMPLETE] && stat_trinkets >= 15) { - unlocknotify[13] = true; - unlock[13] = true; + unlocknotify[Unlock_TIMETRIAL_WARPZONE] = true; + unlock[Unlock_TIMETRIAL_WARPZONE] = true; } - if (unlock[5] && stat_trinkets >= 18) + if (unlock[UnlockTrophy_GAME_COMPLETE] && stat_trinkets >= 18) { - unlocknotify[14] = true; - unlock[14] = true; + unlocknotify[Unlock_TIMETRIAL_FINALLEVEL] = true; + unlock[Unlock_TIMETRIAL_FINALLEVEL] = true; } if (temp == 1) @@ -6790,27 +6820,29 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) if (bestrank[3] >= 2) temp++; if (bestrank[4] >= 2) temp++; if (bestrank[5] >= 2) temp++; - if (temp >= 4 && !unlocknotify[17]) + if (temp >= 4 && !unlocknotify[Unlock_NODEATHMODE]) { //Unlock No Death Mode - unlocknotify[17] = true; - unlock[17] = true; + unlocknotify[Unlock_NODEATHMODE] = true; + unlock[Unlock_NODEATHMODE] = true; createmenu(Menu::unlocknodeathmode, true); savestatsandsettings(); } //Alright then! Flip mode? - else if (unlock[5] && !unlocknotify[18]) + else if (unlock[UnlockTrophy_GAME_COMPLETE] + && !unlocknotify[Unlock_FLIPMODE]) { - unlock[18] = true; - unlocknotify[18] = true; + unlock[Unlock_FLIPMODE] = true; + unlocknotify[Unlock_FLIPMODE] = true; createmenu(Menu::unlockflipmode, true); savestatsandsettings(); } //What about the intermission levels? - else if (unlock[7] && !unlocknotify[16]) + else if (unlock[Unlock_INTERMISSION2_COMPLETE] + && !unlocknotify[Unlock_INTERMISSION_REPLAYS]) { - unlock[16] = true; - unlocknotify[16] = true; + unlock[Unlock_INTERMISSION_REPLAYS] = true; + unlocknotify[Unlock_INTERMISSION_REPLAYS] = true; createmenu(Menu::unlockintermission, true); savestatsandsettings(); } @@ -6825,7 +6857,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) option(loc::gettext("new game")); } //ok, secret lab! no notification, but test: - if (unlock[8]) + if (unlock[Unlock_SECRETLAB]) { option(loc::gettext("secret lab")); } @@ -6835,7 +6867,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) option(loc::gettext("new game")); } option(loc::gettext("return")); - if (unlock[8]) + if (unlock[Unlock_SECRETLAB]) { menuyoff = -30; } @@ -6862,9 +6894,9 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) break; case Menu::playmodes: option(loc::gettext("time trials"), !nocompetitive_unless_translator()); - option(loc::gettext("intermissions"), unlock[16]); - option(loc::gettext("no death mode"), unlock[17] && !nocompetitive()); - option(loc::gettext("flip mode"), unlock[18]); + option(loc::gettext("intermissions"), unlock[Unlock_INTERMISSION_REPLAYS]); + option(loc::gettext("no death mode"), unlock[Unlock_NODEATHMODE] && !nocompetitive()); + option(loc::gettext("flip mode"), unlock[Unlock_FLIPMODE]); option(loc::gettext("return")); menuyoff = 8; maxspacing = 20; @@ -6915,23 +6947,29 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) menuyoff = 80; break; case Menu::unlockmenutrials: - option(loc::gettext("space station 1"), !unlock[9]); - option(loc::gettext("the laboratory"), !unlock[10]); - option(loc::gettext("the tower"), !unlock[11]); - option(loc::gettext("space station 2"), !unlock[12]); - option(loc::gettext("the warp zone"), !unlock[13]); - option(loc::gettext("the final level"), !unlock[14]); + option(loc::gettext("space station 1"), !unlock[Unlock_TIMETRIAL_SPACESTATION1]); + option(loc::gettext("the laboratory"), !unlock[Unlock_TIMETRIAL_LABORATORY]); + option(loc::gettext("the tower"), !unlock[Unlock_TIMETRIAL_TOWER]); + option(loc::gettext("space station 2"), !unlock[Unlock_TIMETRIAL_SPACESTATION2]); + option(loc::gettext("the warp zone"), !unlock[Unlock_TIMETRIAL_WARPZONE]); + option(loc::gettext("the final level"), !unlock[Unlock_TIMETRIAL_FINALLEVEL]); option(loc::gettext("return")); menuyoff = 0; break; case Menu::timetrials: - option(loc::gettext(unlock[9] ? "space station 1" : "???"), unlock[9]); - option(loc::gettext(unlock[10] ? "the laboratory" : "???"), unlock[10]); - option(loc::gettext(unlock[11] ? "the tower" : "???"), unlock[11]); - option(loc::gettext(unlock[12] ? "space station 2" : "???"), unlock[12]); - option(loc::gettext(unlock[13] ? "the warp zone" : "???"), unlock[13]); - option(loc::gettext(unlock[14] ? "the final level" : "???"), unlock[14]); + option(loc::gettext(unlock[Unlock_TIMETRIAL_SPACESTATION1] ? "space station 1" : "???"), + unlock[Unlock_TIMETRIAL_SPACESTATION1]); + option(loc::gettext(unlock[Unlock_TIMETRIAL_LABORATORY] ? "the laboratory" : "???"), + unlock[Unlock_TIMETRIAL_LABORATORY]); + option(loc::gettext(unlock[Unlock_TIMETRIAL_TOWER] ? "the tower" : "???"), + unlock[Unlock_TIMETRIAL_TOWER]); + option(loc::gettext(unlock[Unlock_TIMETRIAL_SPACESTATION2] ? "space station 2" : "???"), + unlock[Unlock_TIMETRIAL_SPACESTATION2]); + option(loc::gettext(unlock[Unlock_TIMETRIAL_WARPZONE] ? "the warp zone" : "???"), + unlock[Unlock_TIMETRIAL_WARPZONE]); + option(loc::gettext(unlock[Unlock_TIMETRIAL_FINALLEVEL] ? "the final level" : "???"), + unlock[Unlock_TIMETRIAL_FINALLEVEL]); option(loc::gettext("return")); menuyoff = 0; diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 4c10e692..ca3a115a 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -132,6 +132,32 @@ enum SWNMODE SWN_NONE }; +/* enums for unlock, unlocknotify arrays and unlocknum function */ +enum +{ + Unlock_SPACESTATION1_COMPLETE = 0, + Unlock_LABORATORY_COMPLETE = 1, + Unlock_TOWER_COMPLETE = 2, + Unlock_SPACESTATION2_COMPLETE = 3, + Unlock_WARPZONE_COMPLETE = 4, + UnlockTrophy_GAME_COMPLETE = 5, + Unlock_INTERMISSION1_COMPLETE = 6, + Unlock_INTERMISSION2_COMPLETE = 7, + Unlock_SECRETLAB = 8, + Unlock_TIMETRIAL_SPACESTATION1 = 9, + Unlock_TIMETRIAL_LABORATORY = 10, + Unlock_TIMETRIAL_TOWER = 11, + Unlock_TIMETRIAL_SPACESTATION2 = 12, + Unlock_TIMETRIAL_WARPZONE = 13, + Unlock_TIMETRIAL_FINALLEVEL = 14, + Unlock_INTERMISSION_UNUSED = 15, + Unlock_INTERMISSION_REPLAYS = 16, + Unlock_NODEATHMODE = 17, + Unlock_FLIPMODE = 18, + UnlockTrophy_FLIPMODE_COMPLETE = 19, + UnlockTrophy_NODEATHMODE_COMPLETE = 20 +}; + struct MenuStackFrame { int option; diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 89b973b8..86bd6b5f 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -938,7 +938,7 @@ static void menuactionpress(void) { int gameplayoptionsoffset = 0; #if !defined(MAKEANDPLAY) - if (game.ingame_titlemode && game.unlock[18]) + if (game.ingame_titlemode && game.unlock[Unlock_FLIPMODE]) #endif { gameplayoptionsoffset = 1; @@ -1401,43 +1401,43 @@ static void menuactionpress(void) switch (game.currentmenuoption) { case 0: //unlock 1 - game.unlock[9] = true; - game.unlocknotify[9] = true; + game.unlock[Unlock_TIMETRIAL_SPACESTATION1] = true; + game.unlocknotify[Unlock_TIMETRIAL_SPACESTATION1] = true; music.playef(Sound_VIRIDIAN); game.createmenu(Menu::unlockmenutrials, true); game.savestatsandsettings_menu(); break; case 1: //unlock 2 - game.unlock[10] = true; - game.unlocknotify[10] = true; + game.unlock[Unlock_TIMETRIAL_LABORATORY] = true; + game.unlocknotify[Unlock_TIMETRIAL_LABORATORY] = true; music.playef(Sound_VIRIDIAN); game.createmenu(Menu::unlockmenutrials, true); game.savestatsandsettings_menu(); break; case 2: //unlock 3 - game.unlock[11] = true; - game.unlocknotify[11] = true; + game.unlock[Unlock_TIMETRIAL_TOWER] = true; + game.unlocknotify[Unlock_TIMETRIAL_TOWER] = true; music.playef(Sound_VIRIDIAN); game.createmenu(Menu::unlockmenutrials, true); game.savestatsandsettings_menu(); break; case 3: //unlock 4 - game.unlock[12] = true; - game.unlocknotify[12] = true; + game.unlock[Unlock_TIMETRIAL_SPACESTATION2] = true; + game.unlocknotify[Unlock_TIMETRIAL_SPACESTATION2] = true; music.playef(Sound_VIRIDIAN); game.createmenu(Menu::unlockmenutrials, true); game.savestatsandsettings_menu(); break; case 4: //unlock 5 - game.unlock[13] = true; - game.unlocknotify[13] = true; + game.unlock[Unlock_TIMETRIAL_WARPZONE] = true; + game.unlocknotify[Unlock_TIMETRIAL_WARPZONE] = true; music.playef(Sound_VIRIDIAN); game.createmenu(Menu::unlockmenutrials, true); game.savestatsandsettings_menu(); break; case 5: //unlock 6 - game.unlock[14] = true; - game.unlocknotify[14] = true; + game.unlock[Unlock_TIMETRIAL_FINALLEVEL] = true; + game.unlocknotify[Unlock_TIMETRIAL_FINALLEVEL] = true; music.playef(Sound_VIRIDIAN); game.createmenu(Menu::unlockmenutrials, true); game.savestatsandsettings_menu(); @@ -1462,26 +1462,26 @@ static void menuactionpress(void) case 1: //unlock intermissions music.playef(Sound_VIRIDIAN); - game.unlock[16] = true; - game.unlocknotify[16] = true; - game.unlock[6] = true; - game.unlock[7] = true; + game.unlock[Unlock_INTERMISSION_REPLAYS] = true; + game.unlocknotify[Unlock_INTERMISSION_REPLAYS] = true; + game.unlock[Unlock_INTERMISSION1_COMPLETE] = true; + game.unlock[Unlock_INTERMISSION2_COMPLETE] = true; game.createmenu(Menu::unlockmenu, true); game.savestatsandsettings_menu(); break; case 2: //unlock no death mode music.playef(Sound_VIRIDIAN); - game.unlock[17] = true; - game.unlocknotify[17] = true; + game.unlock[Unlock_NODEATHMODE] = true; + game.unlocknotify[Unlock_NODEATHMODE] = true; game.createmenu(Menu::unlockmenu, true); game.savestatsandsettings_menu(); break; case 3: //unlock flip mode music.playef(Sound_VIRIDIAN); - game.unlock[18] = true; - game.unlocknotify[18] = true; + game.unlock[Unlock_FLIPMODE] = true; + game.unlocknotify[Unlock_FLIPMODE] = true; game.createmenu(Menu::unlockmenu, true); game.savestatsandsettings_menu(); break; @@ -1495,8 +1495,8 @@ static void menuactionpress(void) case 5: //unlock secret lab music.playef(Sound_VIRIDIAN); - game.unlock[8] = true; - game.unlocknotify[8] = true; + game.unlock[Unlock_SECRETLAB] = true; + game.unlocknotify[Unlock_SECRETLAB] = true; game.createmenu(Menu::unlockmenu, true); game.savestatsandsettings_menu(); break; @@ -1754,7 +1754,7 @@ static void menuactionpress(void) case Menu::play: { //Do we have the Secret Lab option? - int sloffset = game.unlock[8] ? 0 : -1; + int sloffset = game.unlock[Unlock_SECRETLAB] ? 0 : -1; //Do we have a telesave or quicksave? int ngoffset = game.save_exists() ? 0 : -1; if (game.currentmenuoption == 0) @@ -1787,7 +1787,7 @@ static void menuactionpress(void) game.createmenu(Menu::continuemenu); } } - else if (game.currentmenuoption == 1 && game.unlock[8]) + else if (game.currentmenuoption == 1 && game.unlock[Unlock_SECRETLAB]) { music.playef(Sound_VIRIDIAN); startmode(Start_SECRETLAB); @@ -1893,26 +1893,31 @@ static void menuactionpress(void) map.nexttowercolour(); break; case Menu::playmodes: - if (game.currentmenuoption == 0 && !game.nocompetitive_unless_translator()) //go to the time trial menu + if (game.currentmenuoption == 0 + && !game.nocompetitive_unless_translator()) //go to the time trial menu { music.playef(Sound_VIRIDIAN); game.createmenu(Menu::timetrials); map.nexttowercolour(); } - else if (game.currentmenuoption == 1 && game.unlock[16]) + else if (game.currentmenuoption == 1 + && game.unlock[Unlock_INTERMISSION_REPLAYS]) { //intermission mode menu music.playef(Sound_VIRIDIAN); game.createmenu(Menu::intermissionmenu); map.nexttowercolour(); } - else if (game.currentmenuoption == 2 && game.unlock[17] && !game.nocompetitive()) //start a game in no death mode + else if (game.currentmenuoption == 2 + && game.unlock[Unlock_NODEATHMODE] + && !game.nocompetitive()) //start a game in no death mode { music.playef(Sound_VIRIDIAN); game.createmenu(Menu::startnodeathmode); map.nexttowercolour(); } - else if (game.currentmenuoption == 3 && game.unlock[18]) //enable/disable flip mode + else if (game.currentmenuoption == 3 + && game.unlock[Unlock_FLIPMODE]) //enable/disable flip mode { toggleflipmode(); } @@ -2060,32 +2065,38 @@ static void menuactionpress(void) map.nexttowercolour(); break; case Menu::timetrials: - if (game.currentmenuoption == 0 && game.unlock[9]) + if (game.currentmenuoption == 0 + && game.unlock[Unlock_TIMETRIAL_SPACESTATION1]) { music.playef(Sound_VIRIDIAN); startmode(Start_TIMETRIAL_SPACESTATION1); } - else if (game.currentmenuoption == 1 && game.unlock[10]) + else if (game.currentmenuoption == 1 + && game.unlock[Unlock_TIMETRIAL_LABORATORY]) { music.playef(Sound_VIRIDIAN); startmode(Start_TIMETRIAL_LABORATORY); } - else if (game.currentmenuoption == 2 && game.unlock[11]) + else if (game.currentmenuoption == 2 + && game.unlock[Unlock_TIMETRIAL_TOWER]) { music.playef(Sound_VIRIDIAN); startmode(Start_TIMETRIAL_TOWER); } - else if (game.currentmenuoption == 3 && game.unlock[12]) + else if (game.currentmenuoption == 3 + && game.unlock[Unlock_TIMETRIAL_SPACESTATION2]) { music.playef(Sound_VIRIDIAN); startmode(Start_TIMETRIAL_SPACESTATION2); } - else if (game.currentmenuoption == 4 && game.unlock[13]) + else if (game.currentmenuoption == 4 + && game.unlock[Unlock_TIMETRIAL_WARPZONE]) { music.playef(Sound_VIRIDIAN); startmode(Start_TIMETRIAL_WARPZONE); } - else if (game.currentmenuoption == 5 && game.unlock[14]) + else if (game.currentmenuoption == 5 + && game.unlock[Unlock_TIMETRIAL_FINALLEVEL]) { music.playef(Sound_VIRIDIAN); startmode(Start_TIMETRIAL_FINALLEVEL); diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 96470a17..600aa0e2 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -164,7 +164,7 @@ static inline void draw_skip_message() * but not Flip Mode until the player hits "play" on the title screen */ bool draw = #ifndef MAKEANDPLAY - game.unlock[18] && + game.unlock[Unlock_FLIPMODE] && #endif graphics.fademode == FADE_NONE; if (!draw) @@ -269,7 +269,7 @@ static void menurender(void) { int gameplayoptionsoffset = 0; #if !defined(MAKEANDPLAY) - if (game.ingame_titlemode && game.unlock[18]) + if (game.ingame_titlemode && game.unlock[Unlock_FLIPMODE]) #endif { gameplayoptionsoffset = 1; @@ -1161,7 +1161,7 @@ static void menurender(void) font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("Intermissions"), tr, tg, tb); int next_y = font::print_wrap(PR_CEN, -1, 65, loc::gettext("Replay the intermission levels."), tr, tg, tb); - if (!game.unlock[15] && !game.unlock[16]) + if (!game.unlock[Unlock_INTERMISSION_REPLAYS]) { font::print_wrap(PR_CEN, -1, next_y, loc::gettext("TO UNLOCK: Complete the intermission levels in-game."), tr, tg, tb); } @@ -1176,7 +1176,7 @@ static void menurender(void) { font::print_wrap(PR_CEN, -1, next_y, loc::gettext("No Death Mode is not available with slowdown or invincibility."), tr, tg, tb); } - else if (!game.unlock[17]) + else if (!game.unlock[Unlock_NODEATHMODE]) { font::print_wrap(PR_CEN, -1, next_y, loc::gettext("TO UNLOCK: Achieve an S-rank or above in at least 4 time trials."), tr, tg, tb); } @@ -1187,7 +1187,7 @@ static void menurender(void) font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("Flip Mode"), tr, tg, tb); int next_y = font::print_wrap(PR_CEN, -1, 65, loc::gettext("Flip the entire game vertically. Compatible with other game modes."), tr, tg, tb); - if (game.unlock[18]) + if (game.unlock[Unlock_FLIPMODE]) { if (graphics.setflipmode) { @@ -1427,7 +1427,7 @@ static void menurender(void) switch (game.currentmenuoption) { case 0: - if(game.unlock[9]) + if (game.unlock[Unlock_TIMETRIAL_SPACESTATION1]) { font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("Space Station 1"), tr, tg, tb); unlocked = true; @@ -1443,7 +1443,7 @@ static void menurender(void) } break; case 1: - if(game.unlock[10]) + if (game.unlock[Unlock_TIMETRIAL_LABORATORY]) { font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("The Laboratory"), tr, tg, tb); unlocked = true; @@ -1459,7 +1459,7 @@ static void menurender(void) } break; case 2: - if(game.unlock[11]) + if (game.unlock[Unlock_TIMETRIAL_TOWER]) { font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("The Tower"), tr, tg, tb); unlocked = true; @@ -1475,7 +1475,7 @@ static void menurender(void) } break; case 3: - if(game.unlock[12]) + if (game.unlock[Unlock_TIMETRIAL_SPACESTATION2]) { font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("Space Station 2"), tr, tg, tb); unlocked = true; @@ -1491,7 +1491,7 @@ static void menurender(void) } break; case 4: - if(game.unlock[13]) + if (game.unlock[Unlock_TIMETRIAL_WARPZONE]) { font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("The Warp Zone"), tr, tg, tb); unlocked = true; @@ -1507,7 +1507,7 @@ static void menurender(void) } break; case 5: - if(game.unlock[14]) + if (game.unlock[Unlock_TIMETRIAL_FINALLEVEL]) { font::print(PR_2X | PR_CEN, -1, 30, loc::gettext("The Final Level"), tr, tg, tb); unlocked = true; diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index d510f719..e4cee6e5 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -1359,7 +1359,7 @@ void scriptclass::run(void) } else if (words[0] == "entersecretlab") { - game.unlocknum(8); + game.unlocknum(Unlock_SECRETLAB); game.insecretlab = true; SDL_memset(map.explored, true, sizeof(map.explored)); } diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index 37180c22..392cc2a9 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -701,9 +701,18 @@ int main(int argc, char *argv[]) if(game.swnbestrank >= 6) game.unlockAchievement("vvvvvvsupgrav60"); } - if(game.unlock[5]) game.unlockAchievement("vvvvvvgamecomplete"); - if(game.unlock[19]) game.unlockAchievement("vvvvvvgamecompleteflip"); - if(game.unlock[20]) game.unlockAchievement("vvvvvvmaster"); + if (game.unlock[UnlockTrophy_GAME_COMPLETE]) + { + game.unlockAchievement("vvvvvvgamecomplete"); + } + if (game.unlock[UnlockTrophy_FLIPMODE_COMPLETE]) + { + game.unlockAchievement("vvvvvvgamecompleteflip"); + } + if (game.unlock[UnlockTrophy_NODEATHMODE_COMPLETE]) + { + game.unlockAchievement("vvvvvvmaster"); + } if (game.bestgamedeaths > -1) { if (game.bestgamedeaths <= 500) {