From 8aec83daec5585dbcdd1898d380a75c83eb52892 Mon Sep 17 00:00:00 2001 From: NyakoFox Date: Wed, 5 Jun 2024 09:17:04 -0300 Subject: [PATCH] Checkpoint autosaving --- desktop_version/src/Entity.cpp | 7 +++++++ desktop_version/src/Game.cpp | 12 ++++++++++++ desktop_version/src/Game.h | 1 + desktop_version/src/Script.cpp | 7 +++++++ 4 files changed, 27 insertions(+) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index f70246d7..7e477dae 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -2749,6 +2749,13 @@ bool entityclass::updateentities( int i ) game.savedir = entities[player].dir; } entities[i].state = 0; + + if (game.checkpoint_saving) + { + bool success = game.savequick(); + game.gamesaved = success; + game.gamesavefailed = !success; + } } break; case 9: //Gravity Lines diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 14647d58..f01bc034 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -377,6 +377,12 @@ void Game::init(void) screenshot_border_timer = 0; screenshot_saved_success = false; +#ifdef __ANDROID__ + checkpoint_saving = true; +#else + checkpoint_saving = false; +#endif + setdefaultcontrollerbuttons(); } @@ -4940,6 +4946,10 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, struct ScreenSett roomname_translator::set_enabled(help.Int(pText)); } + if (SDL_strcmp(pKey, "checkpoint_saving") == 0) + { + checkpoint_saving = help.Int(pText); + } } setdefaultcontrollerbuttons(); @@ -5198,6 +5208,8 @@ void Game::serializesettings(tinyxml2::XMLElement* dataNode, const struct Screen xml::update_tag(dataNode, "english_sprites", (int) loc::english_sprites); xml::update_tag(dataNode, "new_level_font", loc::new_level_font.c_str()); xml::update_tag(dataNode, "roomname_translator", (int) roomname_translator::enabled); + + xml::update_tag(dataNode, "checkpoint_saving", (int) checkpoint_saving); } static bool settings_loaded = false; diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 20c71a4d..64fcb5a2 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -363,6 +363,7 @@ public: int savetrinkets; bool startscript; std::string newscript; + bool checkpoint_saving; bool menustart; diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index d939a600..3353ee2d 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -1206,6 +1206,13 @@ void scriptclass::run(void) { game.savedir = obj.entities[i].dir; } + + if (game.checkpoint_saving) + { + bool success = game.savequick(); + game.gamesaved = success; + game.gamesavefailed = !success; + } } else if (words[0] == "gamestate") {