From def63209be67d4683b78c6e750e940d29e38fe31 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 14 Nov 2019 21:22:42 +0100 Subject: [PATCH] - fixed savegame loading in Blood. --- source/blood/src/loadsave.cpp | 13 +++++++++---- source/blood/src/menu.cpp | 5 +++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/source/blood/src/loadsave.cpp b/source/blood/src/loadsave.cpp index 5d4149828..9ea75dd63 100644 --- a/source/blood/src/loadsave.cpp +++ b/source/blood/src/loadsave.cpp @@ -440,15 +440,19 @@ void MyLoadSave::Save(void) void LoadSavedInfo(void) { - FString path = M_GetSavegamesPath() + "%sgame*.sav"; + FString path = M_GetSavegamesPath() + "game*.sav"; TArray saves; D_AddWildFile(saves, path); int nCount = 0; for (auto & savename : saves) { - auto hFile = fopenFileReader(savename, 0); - if (!hFile.isOpen()) - ThrowError("Error loading save file header."); + OpenSaveGameForRead(savename); + auto hFile = ReadSavegameChunk("snapshot.bld"); + if (!hFile.isOpen()) + { + FinishSavegameRead(); + ThrowError("Error loading save file header."); + } int vc; short v4; vc = 0; @@ -471,6 +475,7 @@ void LoadSavedInfo(void) strcpy(strRestoreGameStrings[gSaveGameOptions[nCount].nSaveGameSlot], gSaveGameOptions[nCount].szUserGameName); nCount++; } + FinishSavegameRead(); } void UpdateSavedInfo(int nSlot) diff --git a/source/blood/src/menu.cpp b/source/blood/src/menu.cpp index b8929c5ac..2cd2194bf 100644 --- a/source/blood/src/menu.cpp +++ b/source/blood/src/menu.cpp @@ -41,6 +41,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "screen.h" #include "sound.h" #include "view.h" +#include "cmdlib.h" #include "i_specialpaths.h" EXTERN_CVAR(Bool, hud_powerupduration) @@ -2120,7 +2121,7 @@ void LoadGame(CGameMenuItemZEditBitmap *pItem, CGameMenuEvent *event) if (gGameOptions.nGameType > 0) return; snprintf(strLoadGameName, BMAX_PATH, "%sgame00%02d.sav", M_GetSavegamesPath().GetChars(), nSlot); - if (!testkopen(strLoadGameName, 0)) + if (!FileExists(strLoadGameName)) return; viewLoadingScreen(2518, "Loading", "Loading Saved Game", strRestoreGameStrings[nSlot]); videoNextPage(); @@ -2135,7 +2136,7 @@ void QuickLoadGame(void) if (gGameOptions.nGameType > 0) return; snprintf(strLoadGameName, BMAX_PATH, "%sgame00%02d.sav", M_GetSavegamesPath().GetChars(), gQuickLoadSlot); - if (!testkopen(strLoadGameName, 0)) + if (!FileExists(strLoadGameName)) return; viewLoadingScreen(2518, "Loading", "Loading Saved Game", strRestoreGameStrings[gQuickLoadSlot]); videoNextPage();