Remove game.savemystats

This variable seems to have been intended to make sure
game.savestatsandsettings() was called at the end of the frame, or make
sure that it didn't get called more than once per frame. I don't see any
frame ordering-related reason why it needs to be called specifically at
the end of the frame (the function doesn't modify any state), so it's
more plausible that it was added to make sure it didn't get called more
than one per frame.

However, upon further analysis, none of the code paths where
game.savemystats is used ever calls or sets game.savemystats more than
once, and a majority of the code directly calls
game.savestatsandsettings() anyway, so there's no reason for this
variable to exist. If we ever need to make sure it doesn't get called
more than once, and there's no way to change the code paths around to
prevent it otherwise, we can use the defer callbacks system that I added
to #535, when it gets merged.
This commit is contained in:
Misa 2021-01-10 19:39:19 -08:00 committed by Ethan Lee
parent 17d06f06be
commit b1558f574c
4 changed files with 7 additions and 16 deletions

View File

@ -130,7 +130,6 @@ void Game::init(void)
roomchange = false;
savemystats = false;
quickrestartkludge = false;
tapleft = 0;
@ -6623,12 +6622,12 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
if (temp == 1)
{
createmenu(Menu::unlocktimetrial, true);
savemystats = true;
savestatsandsettings();
}
else if (temp > 1)
{
createmenu(Menu::unlocktimetrials, true);
savemystats = true;
savestatsandsettings();
}
}
else
@ -6647,7 +6646,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
unlocknotify[17] = true;
unlock[17] = true;
createmenu(Menu::unlocknodeathmode, true);
savemystats = true;
savestatsandsettings();
}
//Alright then! Flip mode?
else if (unlock[5] && !unlocknotify[18])
@ -6655,7 +6654,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
unlock[18] = true;
unlocknotify[18] = true;
createmenu(Menu::unlockflipmode, true);
savemystats = true;
savestatsandsettings();
}
//What about the intermission levels?
else if (unlock[7] && !unlocknotify[16])
@ -6663,7 +6662,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
unlock[16] = true;
unlocknotify[16] = true;
createmenu(Menu::unlockintermission, true);
savemystats = true;
savestatsandsettings();
}
else
{

View File

@ -374,8 +374,6 @@ public:
std::string hardestroom;
int hardestroomdeaths, currentroomdeaths;
bool savemystats;
bool quickrestartkludge;

View File

@ -687,7 +687,7 @@ static void menuactionpress()
{
// toggle Flip Mode
graphics.setflipmode = !graphics.setflipmode;
game.savemystats = true;
game.savestatsandsettings();
if (graphics.setflipmode)
{
music.playef(18);
@ -1307,7 +1307,7 @@ static void menuactionpress()
{
// WARNING: Partially duplicated in Menu::options
graphics.setflipmode = !graphics.setflipmode;
game.savemystats = true;
game.savestatsandsettings();
if (graphics.setflipmode)
{
music.playef(18);

View File

@ -639,12 +639,6 @@ static void inline fixedloop()
//We did editorinput, now it's safe to turn this off
key.linealreadyemptykludge = false;
if (game.savemystats)
{
game.savemystats = false;
game.savestatsandsettings();
}
//Mute button
if (key.isDown(KEYBOARD_m) && game.mutebutton<=0 && !key.textentry())
{