Skip to content

Commit

Permalink
Abstract checkpoint saving to its own function
Browse files Browse the repository at this point in the history
This also makes the save failed textbox not appear in special modes,
and allows custom levels to quicksave from checkpoints as well.
  • Loading branch information
NyakoFox authored and InfoTeddy committed Sep 28, 2024
1 parent 41d5e68 commit c04c6bc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
12 changes: 1 addition & 11 deletions desktop_version/src/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2750,17 +2750,7 @@ bool entityclass::updateentities( int i )
}
entities[i].state = 0;

if (game.checkpoint_saving)
{
bool success = game.savequick();
game.gamesaved = success;
game.gamesavefailed = !success;

if (game.gamesavefailed) {
game.show_save_fail();
graphics.textboxapplyposition();
}
}
game.checkpoint_save();
}
break;
case 9: //Gravity Lines
Expand Down
16 changes: 16 additions & 0 deletions desktop_version/src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,22 @@ void Game::show_save_fail(void)
graphics.textboxtranslate(TEXTTRANSLATE_FUNCTION, save_textbox_fail);
}

void Game::checkpoint_save(void)
{
if (checkpoint_saving && !inspecial())
{
bool success = map.custommode ? customsavequick(cl.ListOfMetaData[playcustomlevel].filename) : savequick();
gamesaved = success;
gamesavefailed = !success;

if (gamesavefailed)
{
show_save_fail();
graphics.textboxapplyposition();
}
}
}

void Game::savetele_textbox(void)
{
if (inspecial() || map.custommode)
Expand Down
1 change: 1 addition & 0 deletions desktop_version/src/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class Game
void remaining_textbox(void);
void actionprompt_textbox(void);
void show_save_fail(void);
void checkpoint_save(void);
void savetele_textbox(void);

void setstate(int gamestate);
Expand Down
12 changes: 1 addition & 11 deletions desktop_version/src/Script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,17 +1207,7 @@ void scriptclass::run(void)
game.savedir = obj.entities[i].dir;
}

if (game.checkpoint_saving)
{
bool success = game.savequick();
game.gamesaved = success;
game.gamesavefailed = !success;

if (game.gamesavefailed) {
game.show_save_fail();
graphics.textboxapplyposition();
}
}
game.checkpoint_save();
}
else if (words[0] == "gamestate")
{
Expand Down

0 comments on commit c04c6bc

Please sign in to comment.