From c36402eb5c1cab3792fb20fb4e28017d1eaf57ac Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Nov 2019 23:33:04 +0100 Subject: [PATCH] - fixed savegame validation and recursive ticker calls. --- source/build/src/timer.cpp | 7 +++++++ source/common/menu/savegamemanager.cpp | 24 +++++++++++++++--------- source/duke3d/src/savegame.cpp | 2 +- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/source/build/src/timer.cpp b/source/build/src/timer.cpp index 0d1b343fa..8fc00ade3 100644 --- a/source/build/src/timer.cpp +++ b/source/build/src/timer.cpp @@ -52,10 +52,17 @@ ATTRIBUTE((flatten)) void timerUpdateClock(void) totalclock += n; timerlastsample += n*nanoseconds(1000000000/timerticspersec); + // This function can get called from deep within processing loops. + // The callbacks in here may not be called recursively, though. + static bool recursion; + if (recursion) return; + recursion = true; + for (; n > 0; n--) { for (auto cb : callbacks) cb(); } + recursion = false; } void(*timerSetCallback(void(*callback)(void)))(void) diff --git a/source/common/menu/savegamemanager.cpp b/source/common/menu/savegamemanager.cpp index 694157f9e..75cedfbe8 100644 --- a/source/common/menu/savegamemanager.cpp +++ b/source/common/menu/savegamemanager.cpp @@ -205,8 +205,8 @@ void FSavegameManager::ReadSaveStrings() { FSaveGameNode *node = new FSaveGameNode; node->Filename = filepath; - node->bOldVersion = true; - node->bMissingWads = false; + node->bOldVersion = check == -1; + node->bMissingWads = check == -2; node->SaveTitle = title; InsertSaveNode(node); } @@ -281,13 +281,17 @@ void FSavegameManager::NotifyNewSave(const FString &file, const FString &title, void FSavegameManager::LoadSavegame(int Selected) { - savegameManager.LoadGame(SaveGames[Selected]); - if (quickSaveSlot == (FSaveGameNode*)1) + auto sel = savegameManager.GetSavegame(Selected); + if (sel && !sel->bOldVersion && !sel->bMissingWads) { - quickSaveSlot = SaveGames[Selected]; + savegameManager.LoadGame(SaveGames[Selected]); + if (quickSaveSlot == (FSaveGameNode*)1) + { + quickSaveSlot = SaveGames[Selected]; + } + M_ClearMenus(); + LastAccessed = Selected; } - M_ClearMenus(); - LastAccessed = Selected; } @@ -365,6 +369,7 @@ unsigned FSavegameManager::ExtractSaveData(int index) } auto fr = info->NewReader(); auto data = fr.ReadPadded(1); + fr.Close(); sjson_context* ctx = sjson_create_context(0, 0, NULL); if (ctx) { @@ -372,8 +377,9 @@ unsigned FSavegameManager::ExtractSaveData(int index) FString comment = sjson_get_string(root, "Creation Time", ""); - FString pcomment = sjson_get_string(root, "Comment", ""); - if (comment.Len() > 0) comment += "\n"; + FString fcomment = sjson_get_string(root, "Map File", ""); + FString ncomment = sjson_get_string(root, "Map Name", ""); + FStringf pcomment("%s - %s\n", fcomment.GetChars(), ncomment.GetChars()); comment += pcomment; SaveCommentString = comment; diff --git a/source/duke3d/src/savegame.cpp b/source/duke3d/src/savegame.cpp index 4ca22833e..72d746177 100644 --- a/source/duke3d/src/savegame.cpp +++ b/source/duke3d/src/savegame.cpp @@ -665,7 +665,7 @@ bool GameInterface::SaveGame(FSaveGameNode* sv) { videoNextPage(); // no idea if this is needed here. g_screenCapture = 1; - G_DrawRooms(myconnectindex, 65536); + //G_DrawRooms(myconnectindex, 65536); g_screenCapture = 0; return G_SavePlayer(sv);