mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-11-05 02:39:41 +01:00
Use enums for time trial indexes
This adds an anonymous enum for time trial indexes (e.g. the bestrank, bestlives, etc. arrays and timetriallevel), and replaces all integer literals with them. Just like the unlock arrays, these are indexes to an array in XML save files, so the numbers matter, and therefore should not use strict typechecking.
This commit is contained in:
parent
e931f2a4a1
commit
8e3ec9aeef
6 changed files with 77 additions and 32 deletions
|
@ -1828,42 +1828,42 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int
|
|||
switch (meta2)
|
||||
{
|
||||
case 1:
|
||||
if(game.bestrank[0]>=3)
|
||||
if (game.bestrank[TimeTrial_SPACESTATION1] >= 3)
|
||||
{
|
||||
entity.tile = 184 + meta1;
|
||||
entity.colour = 31;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(game.bestrank[1]>=3)
|
||||
if (game.bestrank[TimeTrial_LABORATORY] >= 3)
|
||||
{
|
||||
entity.tile = 186 + meta1;
|
||||
entity.colour = 35;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(game.bestrank[2]>=3)
|
||||
if (game.bestrank[TimeTrial_TOWER] >= 3)
|
||||
{
|
||||
entity.tile = 184 + meta1;
|
||||
entity.colour = 33;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if(game.bestrank[3]>=3)
|
||||
if (game.bestrank[TimeTrial_SPACESTATION2] >= 3)
|
||||
{
|
||||
entity.tile = 184 + meta1;
|
||||
entity.colour = 32;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if(game.bestrank[4]>=3)
|
||||
if (game.bestrank[TimeTrial_WARPZONE] >= 3)
|
||||
{
|
||||
entity.tile = 184 + meta1;
|
||||
entity.colour = 34;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if(game.bestrank[5]>=3)
|
||||
if (game.bestrank[TimeTrial_FINALLEVEL] >= 3)
|
||||
{
|
||||
entity.tile = 184 + meta1;
|
||||
entity.colour = 30;
|
||||
|
|
|
@ -1633,13 +1633,28 @@ void Game::updatestate(void)
|
|||
if (timetrialrank > bestrank[timetriallevel] || bestrank[timetriallevel]==-1)
|
||||
{
|
||||
bestrank[timetriallevel] = timetrialrank;
|
||||
if(timetrialrank>=3){
|
||||
if(timetriallevel==0) unlockAchievement("vvvvvvtimetrial_station1_fixed");
|
||||
if(timetriallevel==1) unlockAchievement("vvvvvvtimetrial_lab_fixed");
|
||||
if(timetriallevel==2) unlockAchievement("vvvvvvtimetrial_tower_fixed");
|
||||
if(timetriallevel==3) unlockAchievement("vvvvvvtimetrial_station2_fixed");
|
||||
if(timetriallevel==4) unlockAchievement("vvvvvvtimetrial_warp_fixed");
|
||||
if(timetriallevel==5) unlockAchievement("vvvvvvtimetrial_final_fixed");
|
||||
if (timetrialrank >= 3)
|
||||
{
|
||||
switch (timetriallevel)
|
||||
{
|
||||
case TimeTrial_SPACESTATION1:
|
||||
unlockAchievement("vvvvvvtimetrial_station1_fixed");
|
||||
break;
|
||||
case TimeTrial_LABORATORY:
|
||||
unlockAchievement("vvvvvvtimetrial_lab_fixed");
|
||||
break;
|
||||
case TimeTrial_TOWER:
|
||||
unlockAchievement("vvvvvvtimetrial_tower_fixed");
|
||||
break;
|
||||
case TimeTrial_SPACESTATION2:
|
||||
unlockAchievement("vvvvvvtimetrial_station2_fixed");
|
||||
break;
|
||||
case TimeTrial_WARPZONE:
|
||||
unlockAchievement("vvvvvvtimetrial_warp_fixed");
|
||||
break;
|
||||
case TimeTrial_FINALLEVEL:
|
||||
unlockAchievement("vvvvvvtimetrial_final_fixed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6814,12 +6829,12 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
|
|||
{
|
||||
//Alright, we haven't unlocked any time trials. How about no death mode?
|
||||
temp = 0;
|
||||
if (bestrank[0] >= 2) temp++;
|
||||
if (bestrank[1] >= 2) temp++;
|
||||
if (bestrank[2] >= 2) temp++;
|
||||
if (bestrank[3] >= 2) temp++;
|
||||
if (bestrank[4] >= 2) temp++;
|
||||
if (bestrank[5] >= 2) temp++;
|
||||
if (bestrank[TimeTrial_SPACESTATION1] >= 2) temp++;
|
||||
if (bestrank[TimeTrial_LABORATORY] >= 2) temp++;
|
||||
if (bestrank[TimeTrial_TOWER] >= 2) temp++;
|
||||
if (bestrank[TimeTrial_SPACESTATION2] >= 2) temp++;
|
||||
if (bestrank[TimeTrial_WARPZONE] >= 2) temp++;
|
||||
if (bestrank[TimeTrial_FINALLEVEL] >= 2) temp++;
|
||||
if (temp >= 4 && !unlocknotify[Unlock_NODEATHMODE])
|
||||
{
|
||||
//Unlock No Death Mode
|
||||
|
|
|
@ -158,6 +158,18 @@ enum
|
|||
UnlockTrophy_NODEATHMODE_COMPLETE = 20
|
||||
};
|
||||
|
||||
/* enums for bestrank, bestlives, besttrinkets, besttimes, bestframes arrays
|
||||
* and timetriallevel */
|
||||
enum
|
||||
{
|
||||
TimeTrial_SPACESTATION1 = 0,
|
||||
TimeTrial_LABORATORY = 1,
|
||||
TimeTrial_TOWER = 2,
|
||||
TimeTrial_SPACESTATION2 = 3,
|
||||
TimeTrial_WARPZONE = 4,
|
||||
TimeTrial_FINALLEVEL = 5
|
||||
};
|
||||
|
||||
struct MenuStackFrame
|
||||
{
|
||||
int option;
|
||||
|
|
|
@ -761,22 +761,22 @@ void gamelogic(void)
|
|||
{
|
||||
switch(game.timetriallevel)
|
||||
{
|
||||
case 0:
|
||||
case TimeTrial_SPACESTATION1:
|
||||
music.play(Music_PUSHINGONWARDS);
|
||||
break;
|
||||
case 1:
|
||||
case TimeTrial_LABORATORY:
|
||||
music.play(Music_POTENTIALFORANYTHING);
|
||||
break;
|
||||
case 2:
|
||||
case TimeTrial_TOWER:
|
||||
music.play(Music_POSITIVEFORCE);
|
||||
break;
|
||||
case 3:
|
||||
case TimeTrial_SPACESTATION2:
|
||||
music.play(Music_PUSHINGONWARDS);
|
||||
break;
|
||||
case 4:
|
||||
case TimeTrial_WARPZONE:
|
||||
music.play(Music_PRESSURECOOKER);
|
||||
break;
|
||||
case 5:
|
||||
case TimeTrial_FINALLEVEL:
|
||||
music.play(Music_PREDESTINEDFATEREMIX);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2191,7 +2191,7 @@ const short* spacestation2class::loadlevel(int rx, int ry)
|
|||
obj.createentity(272, 40, 2, 14, 2); // Platform
|
||||
obj.createentity(240, 40, 3, 707); //Disappearing Platform
|
||||
|
||||
if(game.intimetrial && game.timetriallevel > 0)
|
||||
if (game.intimetrial && game.timetriallevel > TimeTrial_SPACESTATION1)
|
||||
{
|
||||
obj.fatal_top();
|
||||
}
|
||||
|
|
|
@ -729,12 +729,30 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if(game.bestrank[0]>=3) game.unlockAchievement("vvvvvvtimetrial_station1_fixed");
|
||||
if(game.bestrank[1]>=3) game.unlockAchievement("vvvvvvtimetrial_lab_fixed");
|
||||
if(game.bestrank[2]>=3) game.unlockAchievement("vvvvvvtimetrial_tower_fixed");
|
||||
if(game.bestrank[3]>=3) game.unlockAchievement("vvvvvvtimetrial_station2_fixed");
|
||||
if(game.bestrank[4]>=3) game.unlockAchievement("vvvvvvtimetrial_warp_fixed");
|
||||
if(game.bestrank[5]>=3) game.unlockAchievement("vvvvvvtimetrial_final_fixed");
|
||||
if (game.bestrank[TimeTrial_SPACESTATION1] >= 3)
|
||||
{
|
||||
game.unlockAchievement("vvvvvvtimetrial_station1_fixed");
|
||||
}
|
||||
if (game.bestrank[TimeTrial_LABORATORY] >= 3)
|
||||
{
|
||||
game.unlockAchievement("vvvvvvtimetrial_lab_fixed");
|
||||
}
|
||||
if (game.bestrank[TimeTrial_TOWER] >= 3)
|
||||
{
|
||||
game.unlockAchievement("vvvvvvtimetrial_tower_fixed");
|
||||
}
|
||||
if (game.bestrank[TimeTrial_SPACESTATION2] >= 3)
|
||||
{
|
||||
game.unlockAchievement("vvvvvvtimetrial_station2_fixed");
|
||||
}
|
||||
if (game.bestrank[TimeTrial_WARPZONE] >= 3)
|
||||
{
|
||||
game.unlockAchievement("vvvvvvtimetrial_warp_fixed");
|
||||
}
|
||||
if (game.bestrank[TimeTrial_FINALLEVEL] >= 3)
|
||||
{
|
||||
game.unlockAchievement("vvvvvvtimetrial_final_fixed");
|
||||
}
|
||||
|
||||
obj.init();
|
||||
|
||||
|
|
Loading…
Reference in a new issue