Skip to content

Commit

Permalink
Checkpoint autosaving
Browse files Browse the repository at this point in the history
  • Loading branch information
NyakoFox committed Jun 5, 2024
1 parent c20db02 commit e5b29af
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions desktop_version/src/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2732,6 +2732,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
Expand Down
12 changes: 12 additions & 0 deletions desktop_version/src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,12 @@ void Game::init(void)
screenshot_border_timer = 0;
screenshot_saved_success = false;

#ifdef __ANDROID__
checkpoint_saving = true;
#else
checkpoint_saving = false;
#endif

setdefaultcontrollerbuttons();
}

Expand Down Expand Up @@ -4936,6 +4942,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();
Expand Down Expand Up @@ -5194,6 +5204,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;
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 @@ -363,6 +363,7 @@ class Game
int savetrinkets;
bool startscript;
std::string newscript;
bool checkpoint_saving;

bool menustart;

Expand Down
7 changes: 7 additions & 0 deletions desktop_version/src/Script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
{
Expand Down

0 comments on commit e5b29af

Please sign in to comment.