- same change for RedNukem front end.

This commit is contained in:
Christoph Oelckers 2019-11-08 01:04:27 +01:00
parent 47227fc90f
commit a40be954f1
8 changed files with 106 additions and 137 deletions

View file

@ -157,9 +157,9 @@ void D_AddWildFile (TArray<FString> &wadfiles, const char *value)
{ {
return; return;
} }
const char *wadfile = BaseFileSearch (value, ".wad", false); FString wadfile = BaseFileSearch (value, ".wad", false);
if (wadfile != NULL) if (wadfile.Len() != 0)
{ {
D_AddFile (wadfiles, wadfile); D_AddFile (wadfiles, wadfile);
} }

View file

@ -65,7 +65,6 @@ static void Demo_RestoreModes(int32_t menu)
g_player[myconnectindex].ps->gm |= MODE_DEMO; g_player[myconnectindex].ps->gm |= MODE_DEMO;
} }
// This is utterly gross. Global configuration should not be manipulated like this.
void Demo_PrepareWarp(void) void Demo_PrepareWarp(void)
{ {
if (!g_demo_paused) if (!g_demo_paused)
@ -279,10 +278,7 @@ void G_CloseDemoWrite(void)
g_demo_filePtr->Write("EnD!", 4); g_demo_filePtr->Write("EnD!", 4);
// lastly, we need to write the number of written recsyncs to the demo file // lastly, we need to write the number of written recsyncs to the demo file
if (g_demo_filePtr->Write(g_demo_filePtr, offsetof(savehead_t, reccnt))) g_demo_filePtr->Write(&g_demo_cnt, sizeof(g_demo_cnt));
Printf("G_CloseDemoWrite: final fseek\n");
else
g_demo_filePtr->Write(&g_demo_cnt, sizeof(g_demo_cnt));
ud.recstat = ud.m_recstat = 0; ud.recstat = ud.m_recstat = 0;
delete g_demo_filePtr; delete g_demo_filePtr;
@ -418,7 +414,8 @@ static void Demo_FinishProfile(void)
dn, gms, (gms*1000.0)/nt); dn, gms, (gms*1000.0)/nt);
} }
if (nf > 0) { if (nf > 0)
{
OSD_Printf("== demo %d: %d frames (%d frames/gametic)\n", dn, nf, g_demo_profile-1); OSD_Printf("== demo %d: %d frames (%d frames/gametic)\n", dn, nf, g_demo_profile-1);
OSD_Printf("== demo %d drawrooms times: %.03f s (%.03f ms/frame)\n", OSD_Printf("== demo %d drawrooms times: %.03f s (%.03f ms/frame)\n",
dn, dms1/1000.0, dms1/nf); dn, dms1/1000.0, dms1/nf);

View file

@ -206,7 +206,7 @@ static void ReadSaveGameHeaders_CACHE1D(TArray<FString> &saves)
static void ReadSaveGameHeaders_Internal(void) static void ReadSaveGameHeaders_Internal(void)
{ {
FString pattern = M_GetSavegamesPath() + "*.esv"; FString pattern = M_GetSavegamesPath() + "*.bsv";
TArray<FString> saves; TArray<FString> saves;
D_AddWildFile(saves, pattern); D_AddWildFile(saves, pattern);
// potentially overallocating but programmatically simple // potentially overallocating but programmatically simple
@ -750,7 +750,7 @@ int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
} }
else else
{ {
static char const SaveName[] = "save0000.svz"; static char const SaveName[] = "save0000.bsv";
fn.Format("%s%s", M_GetSavegamesPath().GetChars(), SaveName); fn.Format("%s%s", M_GetSavegamesPath().GetChars(), SaveName);
auto fnp = fn.LockBuffer(); auto fnp = fn.LockBuffer();
@ -1002,7 +1002,7 @@ static int32_t readspecdata(const dataspec_t *spec, FileReader *fil, uint8_t **d
if (!ptr || !cnt) if (!ptr || !cnt)
continue; continue;
if (fil != nullptr) if (fil != nullptr && fil->isOpen())
{ {
auto const mem = (dump && (spec->flags & DS_NOCHK) == 0) ? dump : (uint8_t *)ptr; auto const mem = (dump && (spec->flags & DS_NOCHK) == 0) ? dump : (uint8_t *)ptr;
int const siz = cnt * spec->size; int const siz = cnt * spec->size;
@ -1376,11 +1376,6 @@ static const dataspec_t svgm_udnetw[] =
{ 0, connectpoint2, sizeof(connectpoint2), 1 }, { 0, connectpoint2, sizeof(connectpoint2), 1 },
{ 0, &randomseed, sizeof(randomseed), 1 }, { 0, &randomseed, sizeof(randomseed), 1 },
{ 0, &g_globalRandom, sizeof(g_globalRandom), 1 }, { 0, &g_globalRandom, sizeof(g_globalRandom), 1 },
#ifdef LUNATIC
// Save game tic count for Lunatic because it is exposed to userland. See
// test/helixspawner.lua for an example.
{ 0, &g_moveThingsCount, sizeof(g_moveThingsCount), 1 },
#endif
// { 0, &lockclock_dummy, sizeof(lockclock), 1 }, // { 0, &lockclock_dummy, sizeof(lockclock), 1 },
{ DS_END, 0, 0, 0 } { DS_END, 0, 0, 0 }
}; };
@ -1695,7 +1690,7 @@ int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, i
} }
else else
{ {
int v = 64000; int v = 0;
fil.Write(&v, 4); fil.Write(&v, 4);
} }
@ -1810,7 +1805,7 @@ int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h)
} }
if (i > 0) if (i > 0)
{ {
if (fil.Seek(i, FileReader::SeekSet) != i) if (fil.Seek(i, FileReader::SeekCur) < 0)
{ {
OSD_Printf("sv_snapshot: failed skipping over the screenshot.\n"); OSD_Printf("sv_snapshot: failed skipping over the screenshot.\n");
return 8; return 8;
@ -2185,13 +2180,6 @@ static int32_t doloadplayer2(FileReader &fil, uint8_t **memptr)
PRINTSIZE("ud"); PRINTSIZE("ud");
if (readspecdata(svgm_secwsp, &fil, &mem)) return -4; if (readspecdata(svgm_secwsp, &fil, &mem)) return -4;
PRINTSIZE("sws"); PRINTSIZE("sws");
#ifdef LUNATIC
{
int32_t ret = El_ReadSaveCode(fil);
if (ret < 0)
return ret;
}
#endif
if (readspecdata(svgm_script, &fil, &mem)) return -5; if (readspecdata(svgm_script, &fil, &mem)) return -5;
PRINTSIZE("script"); PRINTSIZE("script");
if (readspecdata(svgm_anmisc, &fil, &mem)) return -6; if (readspecdata(svgm_anmisc, &fil, &mem)) return -6;

View file

@ -37,8 +37,8 @@ BEGIN_RR_NS
char g_firstDemoFile[BMAX_PATH]; char g_firstDemoFile[BMAX_PATH];
buildvfs_FILE g_demo_filePtr{}; // write FileWriter *g_demo_filePtr{}; // write
FileReader g_demo_recFilePtr; FileReader g_demo_recFilePtr; // read
int32_t g_demo_cnt; int32_t g_demo_cnt;
int32_t g_demo_goalCnt=0; int32_t g_demo_goalCnt=0;
@ -156,7 +156,7 @@ void G_OpenDemoWrite(void)
if (demonum == MAXDEMOS) if (demonum == MAXDEMOS)
return; return;
if (snprintf(demofn, sizeof(demofn), "%s" DEMOFN_FMT, M_GetSavegamesPath().GetChars(), demonum)) if (snprintf(demofn, sizeof(demofn), "%s" DEMOFN_FMT, M_GetDemoPath().GetChars(), demonum))
{ {
initprintf("Couldn't start demo writing: INTERNAL ERROR: file name too long\n"); initprintf("Couldn't start demo writing: INTERNAL ERROR: file name too long\n");
goto error_wopen_demo; goto error_wopen_demo;
@ -164,25 +164,26 @@ void G_OpenDemoWrite(void)
demonum++; demonum++;
g_demo_filePtr = buildvfs_fopen_read(demofn); g_demo_filePtr = FileWriter::Open(demofn);
if (g_demo_filePtr == NULL) if (g_demo_filePtr == NULL)
break; break;
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr); delete g_demo_filePtr;
} }
while (1); while (1);
g_demo_filePtr = buildvfs_fopen_write(demofn); g_demo_filePtr = FileWriter::Open(demofn);
if (g_demo_filePtr == NULL) if (g_demo_filePtr == NULL)
return; return;
i=sv_saveandmakesnapshot(g_demo_filePtr, nullptr, -1, demorec_diffs_cvar, demorec_diffcompress_cvar, i=sv_saveandmakesnapshot(*g_demo_filePtr, nullptr, -1, demorec_diffs_cvar, demorec_diffcompress_cvar,
(demorec_seeds_cvar<<1)); (demorec_seeds_cvar<<1));
if (i) if (i)
{ {
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr); delete g_demo_filePtr;
g_demo_filePtr = nullptr;
error_wopen_demo: error_wopen_demo:
Bstrcpy(apStrings[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS."); Bstrcpy(apStrings[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE CONSOLE FOR DETAILS.");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps); P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
ud.recstat = ud.m_recstat = 0; ud.recstat = ud.m_recstat = 0;
return; return;
@ -233,13 +234,13 @@ static void Demo_WriteSync()
{ {
int16_t tmpreccnt; int16_t tmpreccnt;
buildvfs_fwrite("sYnC", 4, 1, g_demo_filePtr); g_demo_filePtr->Write("sYnC", 4);
tmpreccnt = (int16_t)ud.reccnt; tmpreccnt = (int16_t)ud.reccnt;
buildvfs_fwrite(&tmpreccnt, sizeof(int16_t), 1, g_demo_filePtr); g_demo_filePtr->Write(&tmpreccnt, sizeof(int16_t));
if (demorec_seeds) if (demorec_seeds)
buildvfs_fwrite(g_demo_seedbuf, 1, ud.reccnt, g_demo_filePtr); g_demo_filePtr->Write(g_demo_seedbuf, ud.reccnt);
buildvfs_fwrite(recsync, sizeof(input_t), ud.reccnt, g_demo_filePtr); g_demo_filePtr->Write(recsync, sizeof(input_t)* ud.reccnt);
ud.reccnt = 0; ud.reccnt = 0;
} }
@ -276,16 +277,14 @@ void G_CloseDemoWrite(void)
if (ud.reccnt > 0) if (ud.reccnt > 0)
Demo_WriteSync(); Demo_WriteSync();
buildvfs_fwrite("EnD!", 4, 1, g_demo_filePtr); g_demo_filePtr->Write("EnD!", 4);
// lastly, we need to write the number of written recsyncs to the demo file // lastly, we need to write the number of written recsyncs to the demo file
if (buildvfs_fseek_abs(g_demo_filePtr, offsetof(savehead_t, reccnt))) g_demo_filePtr->Write(&g_demo_cnt, sizeof(g_demo_cnt));
perror("G_CloseDemoWrite: final fseek");
else
buildvfs_fwrite(&g_demo_cnt, sizeof(g_demo_cnt), 1, g_demo_filePtr);
ud.recstat = ud.m_recstat = 0; ud.recstat = ud.m_recstat = 0;
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr); delete g_demo_filePtr;
g_demo_filePtr = nullptr;
sv_freemem(); sv_freemem();

View file

@ -33,7 +33,7 @@ BEGIN_RR_NS
#define LDEMOFN_FMT "demo%d.dmo" #define LDEMOFN_FMT "demo%d.dmo"
#define MAXDEMOS 1000 #define MAXDEMOS 1000
extern FILE *g_demo_filePtr; extern FileWriter * g_demo_filePtr;
extern char g_firstDemoFile[BMAX_PATH]; extern char g_firstDemoFile[BMAX_PATH];
extern int32_t g_demo_cnt; extern int32_t g_demo_cnt;

View file

@ -361,8 +361,11 @@ void G_GameExit(const char *msg)
if (ud.recstat == 1) if (ud.recstat == 1)
G_CloseDemoWrite(); G_CloseDemoWrite();
else if (ud.recstat == 2) else if (ud.recstat == 2)
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr); {
delete g_demo_filePtr;
g_demo_filePtr = nullptr;
}
// JBF: fixes crash on demo playback // JBF: fixes crash on demo playback
// PK: modified from original // PK: modified from original

View file

@ -186,7 +186,7 @@ static void ReadSaveGameHeaders_CACHE1D(TArray<FString>& saves)
static void ReadSaveGameHeaders_Internal(void) static void ReadSaveGameHeaders_Internal(void)
{ {
FString pattern = M_GetSavegamesPath() + "*.esv"; FString pattern = M_GetSavegamesPath() + "*.bsv";
TArray<FString> saves; TArray<FString> saves;
D_AddWildFile(saves, pattern); D_AddWildFile(saves, pattern);
@ -480,55 +480,52 @@ int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
Net_WaitForEverybody(); Net_WaitForEverybody();
ready2send = 0; ready2send = 0;
char temp[BMAX_PATH]; FString fn;
errno = 0; errno = 0;
FILE *fil; buildvfs_FILE fil;
if (sv.isValid()) if (sv.isValid())
{ {
if (snprintf(temp, sizeof(temp), "%s%s", M_GetSavegamesPath().GetChars(), sv.path)) fn.Format("%s%s", M_GetSavegamesPath().GetChars(), sv.path);
{ fil = fopen(fn, "wb");
OSD_Printf("G_SavePlayer: file name \"%s\" too long\n", sv.path); }
goto saveproblem; else
} {
fil = fopen(temp, "wb"); static char const SaveName[] = "save0000.bsv";
} fn.Format("%s%s", M_GetSavegamesPath().GetChars(), SaveName);
else
{
static char const SaveName[] = "save0000.esv";
int const len = snprintf(temp, ARRAY_SIZE(temp), "%s%s", M_GetSavegamesPath().GetChars(), SaveName);
if (len >= ARRAY_SSIZE(temp)-1)
{
OSD_Printf("G_SavePlayer: could not form automatic save path\n");
goto saveproblem;
}
char * zeros = temp + (len-8);
fil = savecounter.opennextfile(temp, zeros);
savecounter.count++;
// don't copy the mod dir into sv.path
Bstrcpy(sv.path, temp + (len-(ARRAY_SIZE(SaveName)-1)));
}
if (!fil) auto fnp = fn.LockBuffer();
{ char* zeros = fnp + (fn.Len() - 8);
OSD_Printf("G_SavePlayer: failed opening \"%s\" for writing: %s\n", fil = savecounter.opennextfile(fnp, zeros);
temp, strerror(errno)); fn.UnlockBuffer();
goto saveproblem; savecounter.count++;
} // don't copy the mod dir into sv.path
Bstrcpy(sv.path, fn + (fn.Len() - (ARRAY_SIZE(SaveName) - 1)));
}
// temporary hack FileWriter fw(fil);
ud.user_map = G_HaveUserMap(); if (!fil)
{
OSD_Printf("G_SavePlayer: failed opening \"%s\" for writing: %s\n",
fn, strerror(errno));
ready2send = 1;
Net_WaitForEverybody();
#ifdef POLYMER G_RestoreTimers();
if (videoGetRenderMode() == REND_POLYMER) ototalclock = totalclock;
polymer_resetlights(); return -1;
#endif }
else
{
// temporary hack
ud.user_map = G_HaveUserMap();
// SAVE!
sv_saveandmakesnapshot(fil, sv.name, 0, 0, 0, 0, isAutoSave);
fclose(fil); // SAVE!
sv_saveandmakesnapshot(fw, sv.name, 0, 0, 0, 0, isAutoSave);
fw.Close();
if (!g_netServer && ud.multimode < 2) if (!g_netServer && ud.multimode < 2)
{ {
@ -543,15 +540,7 @@ int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
ototalclock = totalclock; ototalclock = totalclock;
return 0; return 0;
}
saveproblem:
ready2send = 1;
Net_WaitForEverybody();
G_RestoreTimers();
ototalclock = totalclock;
return -1;
} }
int32_t G_LoadPlayerMaybeMulti(savebrief_t & sv) int32_t G_LoadPlayerMaybeMulti(savebrief_t & sv)
@ -637,7 +626,7 @@ static inline void ds_get(const dataspec_t *spec, void **ptr, int32_t *cnt)
} }
// write state to file and/or to dump // write state to file and/or to dump
static uint8_t *writespecdata(const dataspec_t *spec, FILE *fil, uint8_t *dump) static uint8_t *writespecdata(const dataspec_t *spec, FileWriter *fil, uint8_t *dump)
{ {
for (; spec->flags != DS_END; spec++) for (; spec->flags != DS_END; spec++)
{ {
@ -652,7 +641,7 @@ static uint8_t *writespecdata(const dataspec_t *spec, FILE *fil, uint8_t *dump)
continue; continue;
else if (spec->flags & DS_STRING) else if (spec->flags & DS_STRING)
{ {
fwrite(spec->ptr, Bstrlen((const char *)spec->ptr), 1, fil); // not null-terminated! fil->Write(spec->ptr, Bstrlen((const char *)spec->ptr)); // not null-terminated!
continue; continue;
} }
@ -672,7 +661,7 @@ static uint8_t *writespecdata(const dataspec_t *spec, FILE *fil, uint8_t *dump)
if (fil) if (fil)
{ {
fwrite(ptr, spec->size, cnt, fil); fil->Write(ptr, spec->size * cnt);
} }
if (dump && (spec->flags & (DS_NOCHK|DS_CMP)) == 0) if (dump && (spec->flags & (DS_NOCHK|DS_CMP)) == 0)
@ -739,7 +728,7 @@ static int32_t readspecdata(const dataspec_t *spec, FileReader *fil, uint8_t **d
if (!ptr || !cnt) if (!ptr || !cnt)
continue; continue;
if (fil->isOpen()) if (fil != nullptr && fil->isOpen())
{ {
auto const mem = (dump && (spec->flags & DS_NOCHK) == 0) ? dump : (uint8_t *)ptr; auto const mem = (dump && (spec->flags & DS_NOCHK) == 0) ? dump : (uint8_t *)ptr;
int const siz = cnt * spec->size; int const siz = cnt * spec->size;
@ -1267,7 +1256,7 @@ static const dataspec_t svgm_anmisc[] =
{ DS_END, 0, 0, 0 } { DS_END, 0, 0, 0 }
}; };
static uint8_t *dosaveplayer2(FILE *fil, uint8_t *mem); static uint8_t *dosaveplayer2(FileWriter *fil, uint8_t *mem);
static int32_t doloadplayer2(FileReader &fil, uint8_t **memptr); static int32_t doloadplayer2(FileReader &fil, uint8_t **memptr);
static void postloadplayer(int32_t savegamep); static void postloadplayer(int32_t savegamep);
@ -1299,7 +1288,7 @@ static void SV_AllocSnap(int32_t allocinit)
} }
// make snapshot only if spot < 0 (demo) // make snapshot only if spot < 0 (demo)
int32_t sv_saveandmakesnapshot(FILE *fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave) int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave)
{ {
savehead_t h; savehead_t h;
@ -1347,10 +1336,6 @@ int32_t sv_saveandmakesnapshot(FILE *fil, char const *name, int8_t spot, int8_t
{ {
// savegame // savegame
Bstrncpyz(h.savename, name, sizeof(h.savename)); Bstrncpyz(h.savename, name, sizeof(h.savename));
#ifdef __ANDROID__
Bstrncpyz(h.volname, g_volumeNames[ud.volume_number], sizeof(h.volname));
Bstrncpyz(h.skillname, g_skillNames[ud.player_skill], sizeof(h.skillname));
#endif
} }
else else
{ {
@ -1367,40 +1352,37 @@ int32_t sv_saveandmakesnapshot(FILE *fil, char const *name, int8_t spot, int8_t
// write header // write header
fwrite(&h, sizeof(savehead_t), 1, fil); fil.Write(&h, sizeof(savehead_t));
// for savegames, the file offset after the screenshot goes here; // for savegames, the file offset after the screenshot goes here;
// for demos, we keep it 0 to signify that we didn't save one // for demos, we keep it 0 to signify that we didn't save one
fwrite("\0\0\0\0", 4, 1, fil);
if (spot >= 0 && tileData(TILE_SAVESHOT)) if (spot >= 0 && tileData(TILE_SAVESHOT))
{ {
int32_t ofs;
int v = 64000;
fil.Write(&v, 4);
// write the screenshot compressed // write the screenshot compressed
fwrite(tileData(TILE_SAVESHOT), 320, 200, fil); fil.Write(tileData(TILE_SAVESHOT), 320*200);
// write the current file offset right after the header
ofs = ftell(fil);
fseek(fil, sizeof(savehead_t), SEEK_SET);
fwrite(&ofs, 4, 1, fil);
fseek(fil, ofs, SEEK_SET);
} }
else
{
int v = 0;
fil.Write(&v, 4);
}
#ifdef DEBUGGINGAIDS
OSD_Printf("sv_saveandmakesnapshot: snapshot size: %d bytes.\n", svsnapsiz);
#endif
if (spot >= 0) if (spot >= 0)
{ {
// savegame // savegame
dosaveplayer2(fil, NULL); dosaveplayer2(&fil, NULL);
} }
else else
{ {
// demo // demo
SV_AllocSnap(0); SV_AllocSnap(0);
uint8_t * const p = dosaveplayer2(fil, svsnapshot); uint8_t * const p = dosaveplayer2(&fil, svsnapshot);
if (p != svsnapshot+svsnapsiz) if (p != svsnapshot+svsnapsiz)
{ {
@ -1441,7 +1423,7 @@ int32_t sv_loadheader(FileReader &fil, int32_t spot, savehead_t *h)
#ifndef DEBUGGINGAIDS #ifndef DEBUGGINGAIDS
if (havedemo) if (havedemo)
#endif #endif
OSD_Printf("Incompatible file version. Expected %d.%d.%d.%d.%0x, found %d.%d.%d.%d.%0x\n", SV_MAJOR_VER, SV_MINOR_VER, BYTEVERSION, OSD_Printf("Incompatible savegame. Expected version %d.%d.%d.%d.%0x, found %d.%d.%d.%d.%0x\n", SV_MAJOR_VER, SV_MINOR_VER, BYTEVERSION,
ud.userbytever, g_scriptcrc, h->majorver, h->minorver, h->bytever, h->userbytever, h->scriptcrc); ud.userbytever, g_scriptcrc, h->majorver, h->minorver, h->bytever, h->userbytever, h->scriptcrc);
if (h->majorver == SV_MAJOR_VER && h->minorver == SV_MINOR_VER) if (h->majorver == SV_MAJOR_VER && h->minorver == SV_MINOR_VER)
@ -1500,8 +1482,8 @@ int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h)
} }
if (i > 0) if (i > 0)
{ {
if (fil.Seek(i, FileReader::SeekSet) != i) if (fil.Seek(i, FileReader::SeekCur) < 0)
{ {
OSD_Printf("sv_snapshot: failed skipping over the screenshot.\n"); OSD_Printf("sv_snapshot: failed skipping over the screenshot.\n");
return 8; return 8;
} }
@ -1554,7 +1536,7 @@ int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h)
} }
uint32_t sv_writediff(FILE *fil) uint32_t sv_writediff(FileWriter *fil)
{ {
uint8_t *p = svsnapshot; uint8_t *p = svsnapshot;
uint8_t *d = svdiff; uint8_t *d = svdiff;
@ -1569,10 +1551,10 @@ uint32_t sv_writediff(FILE *fil)
uint32_t const diffsiz = d - svdiff; uint32_t const diffsiz = d - svdiff;
fwrite("dIfF",4,1,fil); fil->Write("dIfF",4);
fwrite(&diffsiz, sizeof(diffsiz), 1, fil); fil->Write(&diffsiz, sizeof(diffsiz));
fwrite(svdiff, 1, diffsiz, fil); fil->Write(svdiff, diffsiz);
return diffsiz; return diffsiz;
} }
@ -1746,7 +1728,7 @@ static void sv_restload()
# define PRINTSIZE(name) do { } while (0) # define PRINTSIZE(name) do { } while (0)
#endif #endif
static uint8_t *dosaveplayer2(FILE *fil, uint8_t *mem) static uint8_t *dosaveplayer2(FileWriter *fil, uint8_t *mem)
{ {
#ifdef DEBUGGINGAIDS #ifdef DEBUGGINGAIDS
uint8_t *tmem = mem; uint8_t *tmem = mem;

View file

@ -111,11 +111,11 @@ extern menusave_t * g_menusaves;
extern uint16_t g_nummenusaves; extern uint16_t g_nummenusaves;
int32_t sv_updatestate(int32_t frominit); int32_t sv_updatestate(int32_t frominit);
int32_t sv_readdiff(FileReader &fil); int32_t sv_readdiff(FileReader& fil);
uint32_t sv_writediff(FILE *fil); uint32_t sv_writediff(FileWriter *fil);
int32_t sv_loadheader(FileReader& fil, int32_t spot, savehead_t* h); int32_t sv_loadheader(FileReader &fil, int32_t spot, savehead_t *h);
int32_t sv_loadsnapshot(FileReader& fil, int32_t spot, savehead_t* h); int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h);
int32_t sv_saveandmakesnapshot(FILE *fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave = false); int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave = false);
void sv_freemem(); void sv_freemem();
void G_DeleteSave(savebrief_t const & sv); void G_DeleteSave(savebrief_t const & sv);
void G_DeleteOldSaves(void); void G_DeleteOldSaves(void);