- fixed savegame loading in Blood.

This commit is contained in:
Christoph Oelckers 2019-11-14 21:22:42 +01:00
parent ba117554b0
commit def63209be
2 changed files with 12 additions and 6 deletions

View File

@ -440,15 +440,19 @@ void MyLoadSave::Save(void)
void LoadSavedInfo(void) void LoadSavedInfo(void)
{ {
FString path = M_GetSavegamesPath() + "%sgame*.sav"; FString path = M_GetSavegamesPath() + "game*.sav";
TArray<FString> saves; TArray<FString> saves;
D_AddWildFile(saves, path); D_AddWildFile(saves, path);
int nCount = 0; int nCount = 0;
for (auto & savename : saves) for (auto & savename : saves)
{ {
auto hFile = fopenFileReader(savename, 0); OpenSaveGameForRead(savename);
auto hFile = ReadSavegameChunk("snapshot.bld");
if (!hFile.isOpen()) if (!hFile.isOpen())
{
FinishSavegameRead();
ThrowError("Error loading save file header."); ThrowError("Error loading save file header.");
}
int vc; int vc;
short v4; short v4;
vc = 0; vc = 0;
@ -471,6 +475,7 @@ void LoadSavedInfo(void)
strcpy(strRestoreGameStrings[gSaveGameOptions[nCount].nSaveGameSlot], gSaveGameOptions[nCount].szUserGameName); strcpy(strRestoreGameStrings[gSaveGameOptions[nCount].nSaveGameSlot], gSaveGameOptions[nCount].szUserGameName);
nCount++; nCount++;
} }
FinishSavegameRead();
} }
void UpdateSavedInfo(int nSlot) void UpdateSavedInfo(int nSlot)

View File

@ -41,6 +41,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "screen.h" #include "screen.h"
#include "sound.h" #include "sound.h"
#include "view.h" #include "view.h"
#include "cmdlib.h"
#include "i_specialpaths.h" #include "i_specialpaths.h"
EXTERN_CVAR(Bool, hud_powerupduration) EXTERN_CVAR(Bool, hud_powerupduration)
@ -2120,7 +2121,7 @@ void LoadGame(CGameMenuItemZEditBitmap *pItem, CGameMenuEvent *event)
if (gGameOptions.nGameType > 0) if (gGameOptions.nGameType > 0)
return; return;
snprintf(strLoadGameName, BMAX_PATH, "%sgame00%02d.sav", M_GetSavegamesPath().GetChars(), nSlot); snprintf(strLoadGameName, BMAX_PATH, "%sgame00%02d.sav", M_GetSavegamesPath().GetChars(), nSlot);
if (!testkopen(strLoadGameName, 0)) if (!FileExists(strLoadGameName))
return; return;
viewLoadingScreen(2518, "Loading", "Loading Saved Game", strRestoreGameStrings[nSlot]); viewLoadingScreen(2518, "Loading", "Loading Saved Game", strRestoreGameStrings[nSlot]);
videoNextPage(); videoNextPage();
@ -2135,7 +2136,7 @@ void QuickLoadGame(void)
if (gGameOptions.nGameType > 0) if (gGameOptions.nGameType > 0)
return; return;
snprintf(strLoadGameName, BMAX_PATH, "%sgame00%02d.sav", M_GetSavegamesPath().GetChars(), gQuickLoadSlot); snprintf(strLoadGameName, BMAX_PATH, "%sgame00%02d.sav", M_GetSavegamesPath().GetChars(), gQuickLoadSlot);
if (!testkopen(strLoadGameName, 0)) if (!FileExists(strLoadGameName))
return; return;
viewLoadingScreen(2518, "Loading", "Loading Saved Game", strRestoreGameStrings[gQuickLoadSlot]); viewLoadingScreen(2518, "Loading", "Loading Saved Game", strRestoreGameStrings[gQuickLoadSlot]);
videoNextPage(); videoNextPage();