From c04c6bc552042d933fd49ee89e1b1be61b8834a4 Mon Sep 17 00:00:00 2001 From: NyakoFox Date: Thu, 26 Sep 2024 15:25:13 -0300 Subject: [PATCH] Abstract checkpoint saving to its own function This also makes the save failed textbox not appear in special modes, and allows custom levels to quicksave from checkpoints as well. --- desktop_version/src/Entity.cpp | 12 +----------- desktop_version/src/Game.cpp | 16 ++++++++++++++++ desktop_version/src/Game.h | 1 + desktop_version/src/Script.cpp | 12 +----------- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index 1946fd41..5023b16b 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -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 diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 72ea288a..c8fdc0d7 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -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) diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index b416859a..05817b05 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -226,6 +226,7 @@ public: 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); diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 9160e7fe..b4cd8f9b 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -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") {