Fix No Death Mode results being reset before being shown

This does the same thing as the last commit, but for No Death Mode
instead of Time Trials. Whenever you die in No Death Mode, or complete
it, all the relevant variables get copied to variables prefixed with
'ndmresult' that never get reset by script.hardreset(), and these
variables are what titlerender() use, instead of the "live" ones.
This commit is contained in:
Misa 2021-01-07 16:18:07 -08:00 committed by Ethan Lee
parent 4d7baa9e9e
commit 626aac59fb
4 changed files with 31 additions and 10 deletions

View File

@ -171,10 +171,13 @@ void Game::init(void)
nodeathmode = false;
nocutscenes = false;
ndmresultcrewrescued = 0;
ndmresulttrinkets = 0;
customcol=0;
SDL_memset(crewstats, false, sizeof(crewstats));
SDL_memset(ndmresultcrewstats, false, sizeof(ndmresultcrewstats));
SDL_memset(tele_crewstats, false, sizeof(tele_crewstats));
SDL_memset(quick_crewstats, false, sizeof(quick_crewstats));
SDL_memset(besttimes, -1, sizeof(besttimes));
@ -3219,6 +3222,7 @@ void Game::updatestate()
if(graphics.fademode == 1) state++;
break;
case 3522:
copyndmresults();
quittomenu();
createmenu(Menu::nodeathmodecomplete);
state = 0;
@ -7116,3 +7120,11 @@ void Game::mapmenuchange(const int newgamestate)
}
graphics.oldmenuoffset = graphics.menuoffset;
}
void Game::copyndmresults()
{
ndmresultcrewrescued = crewrescued();
ndmresulttrinkets = trinkets();
ndmresulthardestroom = hardestroom;
SDL_memcpy(ndmresultcrewstats, crewstats, sizeof(ndmresultcrewstats));
}

View File

@ -290,6 +290,10 @@ public:
bool nodeathmode;
int gameoverdelay;
bool nocutscenes;
int ndmresultcrewrescued;
int ndmresulttrinkets;
std::string ndmresulthardestroom;
void copyndmresults();
//Time Trials
bool intimetrial, timetrialparlost;
@ -306,6 +310,7 @@ public:
static const int numcrew = 6;
bool crewstats[numcrew];
bool ndmresultcrewstats[numcrew];
bool alarmon;
int alarmdelay;

View File

@ -445,7 +445,11 @@ void gamelogic()
game.gethardestroom();
//start depressing sequence here...
if (game.gameoverdelay <= -10 && graphics.fademode==0) graphics.fademode = 2;
if (graphics.fademode == 1) script.resetgametomenu();
if (graphics.fademode == 1)
{
game.copyndmresults();
script.resetgametomenu();
}
}
else
{

View File

@ -686,22 +686,22 @@ static void menurender()
{
graphics.bigprint( -1, 25, "GAME OVER", tr, tg, tb, true, 3);
for (int i = 0; i < 6; i++)
for (size_t i = 0; i < SDL_arraysize(game.ndmresultcrewstats); i++)
{
graphics.drawcrewman(169-(3*42)+(i*42), 68, i, game.crewstats[i], true);
graphics.drawcrewman(169-(3*42)+(i*42), 68, i, game.ndmresultcrewstats[i], true);
}
std::string tempstring;
tempstring = "You rescued " + help.number(game.crewrescued()) + (game.crewrescued() == 1 ? " crewmate" : " crewmates");
tempstring = "You rescued " + help.number(game.ndmresultcrewrescued) + (game.ndmresultcrewrescued == 1 ? " crewmate" : " crewmates");
graphics.Print(0, 100, tempstring, tr, tg, tb, true);
tempstring = "and found " + help.number(game.trinkets()) + (game.trinkets() == 1 ? " trinket." : " trinkets.");
tempstring = "and found " + help.number(game.ndmresulttrinkets) + (game.ndmresulttrinkets == 1 ? " trinket." : " trinkets.");
graphics.Print(0, 110, tempstring, tr, tg, tb, true);
tempstring = "You managed to reach:";
graphics.Print(0, 145, tempstring, tr, tg, tb, true);
graphics.Print(0, 155, game.hardestroom, tr, tg, tb, true);
graphics.Print(0, 155, game.ndmresulthardestroom, tr, tg, tb, true);
switch (game.crewrescued())
switch (game.ndmresultcrewrescued)
{
case 1:
tempstring = "Keep trying! You'll get there!";
@ -731,14 +731,14 @@ static void menurender()
{
graphics.bigprint( -1, 8, "WOW", tr, tg, tb, true, 4);
for (int i = 0; i < 6; i++)
for (size_t i = 0; i < SDL_arraysize(game.ndmresultcrewstats); i++)
{
graphics.drawcrewman(169-(3*42)+(i*42), 68, i, game.crewstats[i], true);
graphics.drawcrewman(169-(3*42)+(i*42), 68, i, game.ndmresultcrewstats[i], true);
}
std::string tempstring = "You rescued all the crewmates!";
graphics.Print(0, 100, tempstring, tr, tg, tb, true);
tempstring = "And you found " + help.number(game.trinkets()) + " trinkets.";
tempstring = "And you found " + help.number(game.ndmresulttrinkets) + " trinkets.";
graphics.Print(0, 110, tempstring, tr, tg, tb, true);
graphics.Print(0, 160, "A new trophy has been awarded and", tr, tg, tb, true);