ref: 32928efdfdc13d90a29d0506ae8a2cd24c4dd017
parent: 15b8e6e1e47e4f733f862c16a5c18a3485bd22d4
author: Thomas A. Birkel <[email protected]>
date: Thu Oct 27 13:24:04 EDT 2016
heretic/p_saveg.c: Reproduce vanilla savegame error Removes SaveGameType variable, since the SVG_RAM code was never used.
--- a/src/heretic/p_saveg.c
+++ b/src/heretic/p_saveg.c
@@ -29,7 +29,6 @@
#define SVG_FILE 1
static FILE *SaveGameFP;
-static int SaveGameType;
static byte *savebuffer, *save_p;
@@ -63,13 +62,11 @@
void SV_Open(char *fileName)
{
- SaveGameType = SVG_FILE;
SaveGameFP = fopen(fileName, "wb");
}
void SV_OpenRead(char *filename)
{
- SaveGameType = SVG_FILE;
SaveGameFP = fopen(filename, "rb");
}
@@ -81,23 +78,16 @@
void SV_Close(char *fileName)
{
- int length;
-
SV_WriteByte(SAVE_GAME_TERMINATOR);
- if (SaveGameType == SVG_RAM)
+
+ // Enforce the same savegame size limit as in Vanilla Heretic
+
+ if (ftell(SaveGameFP) > SAVEGAMESIZE)
{
- length = save_p - savebuffer;
- if (length > SAVEGAMESIZE)
- {
- I_Error("Savegame buffer overrun");
- }
- M_WriteFile(fileName, savebuffer, length);
- Z_Free(savebuffer);
+ I_Error("Savegame buffer overrun");
}
- else
- { // SVG_FILE
- fclose(SaveGameFP);
- }
+
+ fclose(SaveGameFP);
}
//==========================================================================
@@ -108,15 +98,7 @@
void SV_Write(void *buffer, int size)
{
- if (SaveGameType == SVG_RAM)
- {
- memcpy(save_p, buffer, size);
- save_p += size;
- }
- else
- { // SVG_FILE
- fwrite(buffer, size, 1, SaveGameFP);
- }
+ fwrite(buffer, size, 1, SaveGameFP);
}
void SV_WriteByte(byte val)
@@ -151,15 +133,7 @@
void SV_Read(void *buffer, int size)
{
- if (SaveGameType == SVG_RAM)
- {
- memcpy(buffer, save_p, size);
- save_p += size;
- }
- else
- { // SVG_FILE
- fread(buffer, size, 1, SaveGameFP);
- }
+ fread(buffer, size, 1, SaveGameFP);
}
byte SV_ReadByte(void)