Skip to content

Commit

Permalink
criticial bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Jul 9, 2024
1 parent 03809b5 commit 5b18238
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# BetterEdit 6

## v6.6.2
* Fix bugs with <cp>auto-save</c> that made it impossible to save any new progress as well as causing levels to be duplicated and made it impossible to delete levels

## v6.6.1
* <cj>Auto-saved changes</c> are now <co>discarded if you exit without saving</c>
* Fix <cj>Auto-Save countdown</c> being permanently stuck on screen
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "3.2.0",
"version": "6.6.1",
"version": "6.6.2",
"gd": {
"win": "2.206",
"mac": "2.206",
Expand Down
24 changes: 18 additions & 6 deletions src/features/backups/QuickSave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,24 @@ class $modify(MenuLayer) {
if (!MenuLayer::init())
return false;

// Check if there's quicksaved crash data
auto files = file::readDirectory(getQuickSaveDir()).unwrapOrDefault();
ranges::push(files, file::readDirectory(getAutoSaveDir()).unwrapOrDefault());
for (auto file : files) {
// Only check once on startup so deleting levels doesn't become impossible
static bool CHECKED_CRASHDATA = false;
if (CHECKED_CRASHDATA) {
return true;
}
CHECKED_CRASHDATA = true;

restoreCrashData(getAutoSaveDir());

// Important: Load Quick Saved crash data *after* autosaved crash data,
// as quick saved data is always more up-to-date
restoreCrashData(getQuickSaveDir());

return true;
}

static void restoreCrashData(std::filesystem::path const& path) {
for (auto file : file::readDirectory(path).unwrapOrDefault()) {
auto data = gmd::importGmdAsLevel(file);
if (!data) continue;
auto imported = *data;
Expand All @@ -121,7 +135,5 @@ class $modify(MenuLayer) {
log::info("Restored crashed level {}", imported->m_levelName);
}
}

return true;
}
};

0 comments on commit 5b18238

Please sign in to comment.