From 493525a58eace33ad6c38c316f664fe0c68d7d21 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 21 Jan 2020 21:51:05 +0100 Subject: [PATCH] - consolidation of engine save code. This had discrepancies between the game modules so now all use the same code to save the common engine state. --- source/blood/src/config.cpp | 1 - source/blood/src/config.h | 1 - source/blood/src/fx.cpp | 6 +- source/blood/src/gib.cpp | 4 +- source/blood/src/loadsave.cpp | 60 +-------------- source/common/console/d_event.cpp | 3 +- source/common/menu/savegamemanager.cpp | 7 +- source/common/savegamehelp.cpp | 89 ++++++++++++++++++++++ source/common/version.h | 20 ++--- source/duke3d/src/game.cpp | 2 - source/duke3d/src/gameexec.cpp | 2 +- source/duke3d/src/savegame.cpp | 101 +------------------------ source/duke3d/src/savegame.h | 2 - source/exhumed/src/save.cpp | 3 - source/rr/src/game.cpp | 4 - source/rr/src/savegame.cpp | 90 +--------------------- source/rr/src/savegame.h | 6 -- source/sw/src/save.cpp | 79 +------------------ 18 files changed, 119 insertions(+), 361 deletions(-) diff --git a/source/blood/src/config.cpp b/source/blood/src/config.cpp index 7ab218bdb..7fa55ac8e 100644 --- a/source/blood/src/config.cpp +++ b/source/blood/src/config.cpp @@ -54,7 +54,6 @@ int32_t gRotateMap = 0; int32_t gMessageCount = 4; int32_t gMessageTime = 5; int32_t gMessageFont = 0; -int32_t gbAdultContent = 0; int32_t gMouseSensitivity; bool gNoClip; bool gInfiniteAmmo; diff --git a/source/blood/src/config.h b/source/blood/src/config.h index aff4d3d8c..402997b75 100644 --- a/source/blood/src/config.h +++ b/source/blood/src/config.h @@ -40,7 +40,6 @@ extern int32_t gRotateMap; extern int32_t gMessageCount; extern int32_t gMessageTime; extern int32_t gMessageFont; -extern int32_t gbAdultContent; extern int32_t gMouseSensitivity; extern bool gNoClip; extern bool gInfiniteAmmo; diff --git a/source/blood/src/fx.cpp b/source/blood/src/fx.cpp index 6fbcbca21..7b628447b 100644 --- a/source/blood/src/fx.cpp +++ b/source/blood/src/fx.cpp @@ -148,7 +148,7 @@ spritetype * CFX::fxSpawn(FX_ID nFx, int nSector, int x, int y, int z, unsigned int nSector2 = nSector; if (!FindSector(x, y, z, &nSector2)) return NULL; - if (gbAdultContent && gGameOptions.nGameType <= 0) + if (adult_lockout && gGameOptions.nGameType <= 0) { switch (nFx) { @@ -280,7 +280,7 @@ void fxSpawnBlood(spritetype *pSprite, int a2) int nSector = pSprite->sectnum; if (!FindSector(pSprite->x, pSprite->y, pSprite->z, &nSector)) return; - if (gbAdultContent && gGameOptions.nGameType <= 0) + if (adult_lockout && gGameOptions.nGameType <= 0) return; spritetype *pBlood = gFX.fxSpawn(FX_27, pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0); if (pBlood) @@ -301,7 +301,7 @@ void sub_746D4(spritetype *pSprite, int a2) int nSector = pSprite->sectnum; if (!FindSector(pSprite->x, pSprite->y, pSprite->z, &nSector)) return; - if (gbAdultContent && gGameOptions.nGameType <= 0) + if (adult_lockout && gGameOptions.nGameType <= 0) return; spritetype *pSpawn; if (pSprite->type == kDudePodGreen) diff --git a/source/blood/src/gib.cpp b/source/blood/src/gib.cpp index dc88dd80c..059c40720 100644 --- a/source/blood/src/gib.cpp +++ b/source/blood/src/gib.cpp @@ -297,7 +297,7 @@ int ChanceToCount(int a1, int a2) void GibFX(spritetype *pSprite, GIBFX *pGFX, CGibPosition *pPos, CGibVelocity *pVel) { int nSector = pSprite->sectnum; - if (gbAdultContent && gGameOptions.nGameType == 0 && pGFX->at0 == FX_13) + if (adult_lockout && gGameOptions.nGameType == 0 && pGFX->at0 == FX_13) return; CGibPosition gPos(pSprite->x, pSprite->y, pSprite->z); if (pPos) @@ -363,7 +363,7 @@ void GibFX(spritetype *pSprite, GIBFX *pGFX, CGibPosition *pPos, CGibVelocity *p void GibThing(spritetype *pSprite, GIBTHING *pGThing, CGibPosition *pPos, CGibVelocity *pVel) { - if (gbAdultContent && gGameOptions.nGameType <= 0) + if (adult_lockout && gGameOptions.nGameType <= 0) switch (pGThing->at0) { case kThingBloodBits: case kThingZombieHead: diff --git a/source/blood/src/loadsave.cpp b/source/blood/src/loadsave.cpp index 47f70287e..269f326c2 100644 --- a/source/blood/src/loadsave.cpp +++ b/source/blood/src/loadsave.cpp @@ -114,10 +114,7 @@ bool GameInterface::LoadGame(FSaveGameNode* node) if (!gGameStarted) { memset(xsprite, 0, sizeof(xsprite)); - memset(sprite, 0, sizeof(spritetype)*kMaxSprites); - automapping = 1; } - OpenSaveGameForRead(node->Filename); LoadSave::hLFile = ReadSavegameChunk("snapshot.bld"); if (!LoadSave::hLFile.isOpen()) return false; @@ -137,9 +134,6 @@ bool GameInterface::LoadGame(FSaveGameNode* node) if (!bVanilla && !gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect sfxSetReverb(0); ambInit(); -#ifdef YAX_ENABLE - yax_update(numyaxbunches > 0 ? 2 : 1); -#endif memset(myMinLag, 0, sizeof(myMinLag)); otherMinLag = 0; myMaxLag = 0; @@ -254,40 +248,17 @@ void MyLoadSave::Load(void) if (version != BYTEVERSION) ThrowError("Incompatible version of saved game found!"); Read(&gGameOptions, sizeof(gGameOptions)); - Read(&numsectors, sizeof(numsectors)); - Read(&numwalls, sizeof(numwalls)); - Read(&numsectors, sizeof(numsectors)); + int nNumSprites; Read(&nNumSprites, sizeof(nNumSprites)); - memset(sector, 0, sizeof(sector[0])*kMaxSectors); - memset(wall, 0, sizeof(wall[0])*kMaxWalls); - memset(sprite, 0, sizeof(sprite[0])*kMaxSprites); - Read(sector, sizeof(sector[0])*numsectors); - Read(wall, sizeof(wall[0])*numwalls); - Read(sprite, sizeof(sprite[0])*kMaxSprites); Read(qsector_filler, sizeof(qsector_filler[0])*numsectors); Read(qsprite_filler, sizeof(qsprite_filler[0])*kMaxSprites); - Read(&randomseed, sizeof(randomseed)); - Read(¶llaxtype, sizeof(parallaxtype)); - Read(&showinvisibility, sizeof(showinvisibility)); Read(&pSky->horizfrac, sizeof(pSky->horizfrac)); Read(&pSky->yoffs, sizeof(pSky->yoffs)); Read(&pSky->yscale, sizeof(pSky->yscale)); Read(&gVisibility, sizeof(gVisibility)); - Read(&g_visibility, sizeof(g_visibility)); - Read(¶llaxvisibility, sizeof(parallaxvisibility)); Read(pSky->tileofs, sizeof(pSky->tileofs)); Read(&pSky->lognumtiles, sizeof(pSky->lognumtiles)); - Read(headspritesect, sizeof(headspritesect)); - Read(headspritestat, sizeof(headspritestat)); - Read(prevspritesect, sizeof(prevspritesect)); - Read(prevspritestat, sizeof(prevspritestat)); - Read(nextspritesect, sizeof(nextspritesect)); - Read(nextspritestat, sizeof(nextspritestat)); - Read(show2dsector, sizeof(show2dsector)); - Read(show2dwall, sizeof(show2dwall)); - Read(show2dsprite, sizeof(show2dsprite)); - Read(&automapping, sizeof(automapping)); Read(gotpic, sizeof(gotpic)); Read(gotsector, sizeof(gotsector)); Read(&gFrameClock, sizeof(gFrameClock)); @@ -298,7 +269,6 @@ void MyLoadSave::Load(void) totalclock = nGameClock; Read(&gLevelTime, sizeof(gLevelTime)); Read(&gPaused, sizeof(gPaused)); - Read(&gbAdultContent, sizeof(gbAdultContent)); Read(baseWall, sizeof(baseWall[0])*numwalls); Read(baseSprite, sizeof(baseSprite[0])*nNumSprites); Read(baseFloor, sizeof(baseFloor[0])*numsectors); @@ -345,9 +315,6 @@ void MyLoadSave::Load(void) Read(&gSongId, sizeof(gSkyCount)); Read(&gFogMode, sizeof(gFogMode)); Read(&gModernMap, sizeof(gModernMap)); -#ifdef YAX_ENABLE - Read(&numyaxbunches, sizeof(numyaxbunches)); -#endif gCheatMgr.sub_5BCF4(); } @@ -368,36 +335,15 @@ void MyLoadSave::Save(void) //nNumSprites += 2; nNumSprites++; Write(&gGameOptions, sizeof(gGameOptions)); - Write(&numsectors, sizeof(numsectors)); - Write(&numwalls, sizeof(numwalls)); - Write(&numsectors, sizeof(numsectors)); Write(&nNumSprites, sizeof(nNumSprites)); - Write(sector, sizeof(sector[0])*numsectors); - Write(wall, sizeof(wall[0])*numwalls); - Write(sprite, sizeof(sprite[0])*kMaxSprites); Write(qsector_filler, sizeof(qsector_filler[0])*numsectors); Write(qsprite_filler, sizeof(qsprite_filler[0])*kMaxSprites); - Write(&randomseed, sizeof(randomseed)); - Write(¶llaxtype, sizeof(parallaxtype)); - Write(&showinvisibility, sizeof(showinvisibility)); Write(&pSky->horizfrac, sizeof(pSky->horizfrac)); Write(&pSky->yoffs, sizeof(pSky->yoffs)); Write(&pSky->yscale, sizeof(pSky->yscale)); Write(&gVisibility, sizeof(gVisibility)); - Write(&g_visibility, sizeof(g_visibility)); - Write(¶llaxvisibility, sizeof(parallaxvisibility)); Write(pSky->tileofs, sizeof(pSky->tileofs)); Write(&pSky->lognumtiles, sizeof(pSky->lognumtiles)); - Write(headspritesect, sizeof(headspritesect)); - Write(headspritestat, sizeof(headspritestat)); - Write(prevspritesect, sizeof(prevspritesect)); - Write(prevspritestat, sizeof(prevspritestat)); - Write(nextspritesect, sizeof(nextspritesect)); - Write(nextspritestat, sizeof(nextspritestat)); - Write(show2dsector, sizeof(show2dsector)); - Write(show2dwall, sizeof(show2dwall)); - Write(show2dsprite, sizeof(show2dsprite)); - Write(&automapping, sizeof(automapping)); Write(gotpic, sizeof(gotpic)); Write(gotsector, sizeof(gotsector)); Write(&gFrameClock, sizeof(gFrameClock)); @@ -407,7 +353,6 @@ void MyLoadSave::Save(void) Write(&nGameClock, sizeof(nGameClock)); Write(&gLevelTime, sizeof(gLevelTime)); Write(&gPaused, sizeof(gPaused)); - Write(&gbAdultContent, sizeof(gbAdultContent)); Write(baseWall, sizeof(baseWall[0])*numwalls); Write(baseSprite, sizeof(baseSprite[0])*nNumSprites); Write(baseFloor, sizeof(baseFloor[0])*numsectors); @@ -451,9 +396,6 @@ void MyLoadSave::Save(void) Write(&gSongId, sizeof(gSkyCount)); Write(&gFogMode, sizeof(gFogMode)); Write(&gModernMap, sizeof(gModernMap)); -#ifdef YAX_ENABLE - Write(&numyaxbunches, sizeof(numyaxbunches)); -#endif } void LoadSavedInfo(void) diff --git a/source/common/console/d_event.cpp b/source/common/console/d_event.cpp index 4d4c5ff7f..e6e8f0307 100644 --- a/source/common/console/d_event.cpp +++ b/source/common/console/d_event.cpp @@ -100,9 +100,10 @@ bool G_Responder (event_t *ev) void D_ProcessEvents (void) { event_t *ev; - for (; eventtail != eventhead ; eventtail = (eventtail+1)&(NUM_EVENTS-1)) + while (eventtail != eventhead) { ev = &events[eventtail]; + eventtail = (eventtail + 1) & (NUM_EVENTS - 1); if (ev->type == EV_None) continue; /*if (ev->type == EV_DeviceChange) diff --git a/source/common/menu/savegamemanager.cpp b/source/common/menu/savegamemanager.cpp index 4ab81d50c..6b196f3c6 100644 --- a/source/common/menu/savegamemanager.cpp +++ b/source/common/menu/savegamemanager.cpp @@ -58,9 +58,12 @@ FSavegameManager savegameManager; void FSavegameManager::LoadGame(FSaveGameNode* node) { - yax_update(1); // make sure it's all reset before loading a new map. - if (gi->LoadGame(node)) + if (OpenSaveGameForRead(node->Filename)) { + if (gi->LoadGame(node)) + { + // do something here? + } } } diff --git a/source/common/savegamehelp.cpp b/source/common/savegamehelp.cpp index 8fa337b18..663bb2718 100644 --- a/source/common/savegamehelp.cpp +++ b/source/common/savegamehelp.cpp @@ -50,6 +50,8 @@ static CompositeSavegameWriter savewriter; static FResourceFile *savereader; +void LoadEngineState(); +void SaveEngineState(); //============================================================================= // @@ -77,6 +79,7 @@ bool OpenSaveGameForRead(const char *name) SECRET_Load(); MUS_Restore(); quoteMgr.ReadFromSavegame(); + LoadEngineState(); auto file = ReadSavegameChunk("info.json"); if (!file.isOpen()) @@ -184,6 +187,7 @@ bool OpenSaveGameForWrite(const char* filename, const char *name) SECRET_Save(); MUS_Save(); quoteMgr.WriteToSavegame(); + SaveEngineState(); auto picfile = WriteSavegameChunk("savepic.png"); screen->WriteSavePic(picfile, 240, 180); return true; @@ -353,20 +357,59 @@ FString G_BuildSaveName (const char *prefix) #include "build.h" #include "mmulti.h" + +static void sv_prespriteextsave() +{ + for (int i = 0; i < MAXSPRITES; i++) + if (spriteext[i].mdanimtims) + { + spriteext[i].mdanimtims -= mdtims; + if (spriteext[i].mdanimtims == 0) + spriteext[i].mdanimtims++; + } +} +static void sv_postspriteext() +{ + for (int i = 0; i < MAXSPRITES; i++) + if (spriteext[i].mdanimtims) + spriteext[i].mdanimtims += mdtims; +} + + +static const int magic = 0xbeefcafe; +void WriteMagic(FileWriter *fw) +{ + fw->Write(&magic, 4); +} + +void CheckMagic(FileReader& fr) +{ + int m = 0; + fr.Read(&m, 4); + assert(m == magic); +#ifndef _DEBUG + if (m != magic) I_Error("Savegame corrupt"); +#endif +} + void SaveEngineState() { auto fw = WriteSavegameChunk("engine.bin"); fw->Write(&numsectors, sizeof(numsectors)); fw->Write(sector, sizeof(sectortype) * numsectors); + WriteMagic(fw); fw->Write(&numwalls, sizeof(numwalls)); fw->Write(wall, sizeof(walltype) * numwalls); + WriteMagic(fw); fw->Write(sprite, sizeof(spritetype) * MAXSPRITES); + WriteMagic(fw); fw->Write(headspritesect, sizeof(headspritesect)); fw->Write(prevspritesect, sizeof(prevspritesect)); fw->Write(nextspritesect, sizeof(nextspritesect)); fw->Write(headspritestat, sizeof(headspritestat)); fw->Write(prevspritestat, sizeof(prevspritestat)); fw->Write(nextspritestat, sizeof(nextspritestat)); + WriteMagic(fw); fw->Write(&tailspritefree, sizeof(tailspritefree)); fw->Write(&myconnectindex, sizeof(myconnectindex)); @@ -375,16 +418,35 @@ void SaveEngineState() fw->Write(&numframes, sizeof(numframes)); fw->Write(&randomseed, sizeof(randomseed)); fw->Write(&numshades, sizeof(numshades)); + fw->Write(&automapping, sizeof(automapping)); + fw->Write(&showinvisibility, sizeof(showinvisibility)); + WriteMagic(fw); fw->Write(&g_visibility, sizeof(g_visibility)); fw->Write(¶llaxtype, sizeof(parallaxtype)); + fw->Write(¶llaxvisibility, sizeof(parallaxvisibility)); fw->Write(¶llaxyoffs_override, sizeof(parallaxyoffs_override)); fw->Write(¶llaxyscale_override, sizeof(parallaxyscale_override)); fw->Write(&pskybits_override, sizeof(pskybits_override)); + WriteMagic(fw); fw->Write(show2dwall, sizeof(show2dwall)); fw->Write(show2dsprite, sizeof(show2dsprite)); fw->Write(show2dsector, sizeof(show2dsector)); + WriteMagic(fw); + + fw->Write(&numyaxbunches, sizeof(numyaxbunches)); + fw->Write(yax_bunchnum, sizeof(yax_bunchnum)); + fw->Write(yax_nextwall, sizeof(yax_nextwall)); + WriteMagic(fw); + + fw->Write(&Numsprites, sizeof(Numsprites)); + sv_prespriteextsave(); + fw->Write(spriteext, sizeof(spriteext_t) * MAXSPRITES); + fw->Write(wallext, sizeof(wallext_t) * MAXWALLS); + sv_postspriteext(); + WriteMagic(fw); + } void LoadEngineState() @@ -392,17 +454,25 @@ void LoadEngineState() auto fr = ReadSavegameChunk("engine.bin"); if (fr.isOpen()) { + memset(sector, 0, sizeof(sector[0]) * MAXSECTORS); + memset(wall, 0, sizeof(wall[0]) * MAXWALLS); + memset(sprite, 0, sizeof(sprite[0]) * MAXSPRITES); + fr.Read(&numsectors, sizeof(numsectors)); fr.Read(sector, sizeof(sectortype) * numsectors); + CheckMagic(fr); fr.Read(&numwalls, sizeof(numwalls)); fr.Read(wall, sizeof(walltype) * numwalls); + CheckMagic(fr); fr.Read(sprite, sizeof(spritetype) * MAXSPRITES); + CheckMagic(fr); fr.Read(headspritesect, sizeof(headspritesect)); fr.Read(prevspritesect, sizeof(prevspritesect)); fr.Read(nextspritesect, sizeof(nextspritesect)); fr.Read(headspritestat, sizeof(headspritestat)); fr.Read(prevspritestat, sizeof(prevspritestat)); fr.Read(nextspritestat, sizeof(nextspritestat)); + CheckMagic(fr); fr.Read(&tailspritefree, sizeof(tailspritefree)); fr.Read(&myconnectindex, sizeof(myconnectindex)); @@ -411,16 +481,35 @@ void LoadEngineState() fr.Read(&numframes, sizeof(numframes)); fr.Read(&randomseed, sizeof(randomseed)); fr.Read(&numshades, sizeof(numshades)); + fr.Read(&automapping, sizeof(automapping)); + fr.Read(&showinvisibility, sizeof(showinvisibility)); + CheckMagic(fr); fr.Read(&g_visibility, sizeof(g_visibility)); fr.Read(¶llaxtype, sizeof(parallaxtype)); + fr.Read(¶llaxvisibility, sizeof(parallaxvisibility)); fr.Read(¶llaxyoffs_override, sizeof(parallaxyoffs_override)); fr.Read(¶llaxyscale_override, sizeof(parallaxyscale_override)); fr.Read(&pskybits_override, sizeof(pskybits_override)); + CheckMagic(fr); fr.Read(show2dwall, sizeof(show2dwall)); fr.Read(show2dsprite, sizeof(show2dsprite)); fr.Read(show2dsector, sizeof(show2dsector)); + CheckMagic(fr); + + fr.Read(&numyaxbunches, sizeof(numyaxbunches)); + fr.Read(yax_bunchnum, sizeof(yax_bunchnum)); + fr.Read(yax_nextwall, sizeof(yax_nextwall)); + yax_update(numyaxbunches > 0 ? 2 : 1); + CheckMagic(fr); + + fr.Read(&Numsprites, sizeof(Numsprites)); + fr.Read(spriteext, sizeof(spriteext_t) * MAXSPRITES); + fr.Read(wallext, sizeof(wallext_t) * MAXWALLS); + sv_postspriteext(); + CheckMagic(fr); + fr.Close(); } } \ No newline at end of file diff --git a/source/common/version.h b/source/common/version.h index 162865c68..63e30c07e 100644 --- a/source/common/version.h +++ b/source/common/version.h @@ -66,17 +66,17 @@ const char *GetVersionString(); #define SAVESIG_SW GAMENAME ".ShadowWarrior" #define SAVESIG_PS GAMENAME ".Exhumed" -#define MINSAVEVER_DN3D 1 -#define MINSAVEVER_BLD 1 -#define MINSAVEVER_RR 1 -#define MINSAVEVER_SW 1 -#define MINSAVEVER_PS 1 +#define MINSAVEVER_DN3D 2 +#define MINSAVEVER_BLD 2 +#define MINSAVEVER_RR 2 +#define MINSAVEVER_SW 2 +#define MINSAVEVER_PS 2 -#define SAVEVER_DN3D 1 -#define SAVEVER_BLD 1 -#define SAVEVER_RR 1 -#define SAVEVER_SW 1 -#define SAVEVER_PS 1 +#define SAVEVER_DN3D 2 +#define SAVEVER_BLD 2 +#define SAVEVER_RR 2 +#define SAVEVER_SW 2 +#define SAVEVER_PS 2 #if defined(__APPLE__) || defined(_WIN32) #define GAME_DIR GAMENAME diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 81c43fc57..54d1090a6 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -5270,8 +5270,6 @@ static void G_FreeHashAnim(const char * /*string*/, intptr_t key) static void G_Cleanup(void) { - //ReadSaveGameHeaders(); // for culling - int32_t i; for (i=(MAXLEVELS*(MAXVOLUMES+1))-1; i>=0; i--) // +1 volume for "intro", "briefing" music diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 70ee7f35c..79b3b6dd8 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -6715,7 +6715,7 @@ void G_RestoreMapState(void) #endif #endif #ifdef YAX_ENABLE - sv_postyaxload(); + yax_update(numyaxbunches > 0 ? 2 : 1); #endif G_ResetInterpolations(); diff --git a/source/duke3d/src/savegame.cpp b/source/duke3d/src/savegame.cpp index ec2937e02..ab4fe7627 100644 --- a/source/duke3d/src/savegame.cpp +++ b/source/duke3d/src/savegame.cpp @@ -143,12 +143,8 @@ int32_t g_fakeSaveID = -1; bool g_saveRequested; -static FileReader *OpenSavegame(const char *fn) +static FileReader *OpenSavegame() { - if (!OpenSaveGameForRead(fn)) - { - return nullptr; - } auto file = ReadSavegameChunk("snapshot.dat"); if (!file.isOpen()) { @@ -158,28 +154,6 @@ static FileReader *OpenSavegame(const char *fn) return new FileReader(std::move(file)); } -int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh) -{ - FileReader ssfil; - auto fil = OpenSavegame(fn); - if (!fil) - return -1; - - int32_t i = sv_loadheader(*fil, 0, saveh); - if (i < 0) - goto corrupt; - - delete fil; - FinishSavegameRead(); - return 0; - -corrupt: - delete fil; - FinishSavegameRead(); - return 1; -} - - static void sv_postudload(); // XXX: keyboard input 'blocked' after load fail? (at least ESC?) @@ -193,7 +167,7 @@ int32_t G_LoadPlayer(FSaveGameNode *sv) int level = -1; int skill = -1; - auto fil = OpenSavegame(sv->Filename); + auto fil = OpenSavegame(); if (!fil) return -1; { @@ -422,7 +396,7 @@ int32_t G_LoadPlayer(FSaveGameNode *sv) return 0; } - auto fil = OpenSavegame(sv->Filename); + auto fil = OpenSavegame(); if (!fil) return -1; @@ -1151,37 +1125,6 @@ static char svgm_secwsp_string [] = "blK:swsp"; static const dataspec_t svgm_secwsp[] = { { DS_STRING, (void *)svgm_secwsp_string, 0, 1 }, - { DS_NOCHK, &numwalls, sizeof(numwalls), 1 }, - { DS_MAINAR|DS_CNT(numwalls), &wall, sizeof(walltype), (intptr_t)&numwalls }, - { DS_NOCHK, &numsectors, sizeof(numsectors), 1 }, - { DS_MAINAR|DS_CNT(numsectors), §or, sizeof(sectortype), (intptr_t)&numsectors }, - { DS_MAINAR, &sprite, sizeof(spritetype), MAXSPRITES }, -#ifdef YAX_ENABLE - { DS_NOCHK, &numyaxbunches, sizeof(numyaxbunches), 1 }, -# if !defined NEW_MAP_FORMAT - { DS_CNT(numsectors), yax_bunchnum, sizeof(yax_bunchnum[0]), (intptr_t)&numsectors }, - { DS_CNT(numwalls), yax_nextwall, sizeof(yax_nextwall[0]), (intptr_t)&numwalls }, -# endif - { DS_LOADFN|DS_PROTECTFN, (void *)&sv_postyaxload, 0, 1 }, -#endif - { 0, &Numsprites, sizeof(Numsprites), 1 }, - { 0, &tailspritefree, sizeof(tailspritefree), 1 }, - { 0, &headspritesect[0], sizeof(headspritesect[0]), MAXSECTORS+1 }, - { 0, &prevspritesect[0], sizeof(prevspritesect[0]), MAXSPRITES }, - { 0, &nextspritesect[0], sizeof(nextspritesect[0]), MAXSPRITES }, - { 0, &headspritestat[0], sizeof(headspritestat[0]), MAXSTATUS+1 }, - { 0, &prevspritestat[0], sizeof(prevspritestat[0]), MAXSPRITES }, - { 0, &nextspritestat[0], sizeof(nextspritestat[0]), MAXSPRITES }, -#ifdef USE_OPENGL - { DS_SAVEFN, (void *)&sv_prespriteextsave, 0, 1 }, -#endif - { DS_MAINAR, &spriteext, sizeof(spriteext_t), MAXSPRITES }, -#ifndef NEW_MAP_FORMAT - { DS_MAINAR, &wallext, sizeof(wallext_t), MAXWALLS }, -#endif -#ifdef USE_OPENGL - { DS_SAVEFN|DS_LOADFN, (void *)&sv_postspriteext, 0, 1 }, -#endif { DS_NOCHK, &g_cyclerCnt, sizeof(g_cyclerCnt), 1 }, { DS_CNT(g_cyclerCnt), &g_cyclers[0][0], sizeof(g_cyclers[0]), (intptr_t)&g_cyclerCnt }, { DS_NOCHK, &g_animWallCnt, sizeof(g_animWallCnt), 1 }, @@ -1401,18 +1344,6 @@ int32_t sv_saveandmakesnapshot(FileWriter &fil, int8_t spot) fil.Write(&h, sizeof(savehead_t)); } - - // write header -#if 0 // not usable anymore - if (spot >= 0 && tileData(TILE_SAVESHOT)) - { - auto fw = WriteSavegameChunk("screenshot.dat"); - fw->Write(tileData(TILE_SAVESHOT), 320*200); - - } -#endif - - if (spot >= 0) { // savegame @@ -1643,32 +1574,6 @@ static void sv_postudload() } //static int32_t lockclock_dummy; -#ifdef USE_OPENGL -static void sv_prespriteextsave() -{ - for (int i=0; i0 ? 2 : 1); -} -#endif - static void sv_postactordata() { #ifdef POLYMER diff --git a/source/duke3d/src/savegame.h b/source/duke3d/src/savegame.h index 9f4047b59..535e6ab4a 100644 --- a/source/duke3d/src/savegame.h +++ b/source/duke3d/src/savegame.h @@ -70,8 +70,6 @@ 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_saveandmakesnapshot(FileWriter &fil, int8_t spot); void sv_freemem(); -int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh); -void ReadSaveGameHeaders(void); #ifdef YAX_ENABLE extern void sv_postyaxload(void); diff --git a/source/exhumed/src/save.cpp b/source/exhumed/src/save.cpp index 81c96a0aa..ffb36ee4d 100644 --- a/source/exhumed/src/save.cpp +++ b/source/exhumed/src/save.cpp @@ -40,7 +40,6 @@ static TArray sghelpers(TArray::NoInit); bool GameInterface::SaveGame(FSaveGameNode* sv) { - SaveEngineState(); for (auto sgh : sghelpers) sgh->Save(); SaveTextureState(); FinishSavegameWrite(); @@ -49,8 +48,6 @@ bool GameInterface::SaveGame(FSaveGameNode* sv) bool GameInterface::LoadGame(FSaveGameNode* sv) { - OpenSaveGameForRead(sv->Filename); - LoadEngineState(); for (auto sgh : sghelpers) sgh->Load(); LoadTextureState(); diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index cca7fa239..332f750ac 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -6708,8 +6708,6 @@ static void G_FreeHashAnim(const char * /*string*/, intptr_t key) static void G_Cleanup(void) { - ReadSaveGameHeaders(); // for culling - int32_t i; for (i=(MAXLEVELS*(MAXVOLUMES+1))-1; i>=0; i--) // +1 volume for "intro", "briefing" music @@ -7311,8 +7309,6 @@ int GameInterface::app_main() Menu_Init(); } - ReadSaveGameHeaders(); - FX_StopAllSounds(); S_ClearSoundLocks(); app_loop(); diff --git a/source/rr/src/savegame.cpp b/source/rr/src/savegame.cpp index c1c63fe6e..618e64e00 100644 --- a/source/rr/src/savegame.cpp +++ b/source/rr/src/savegame.cpp @@ -138,12 +138,8 @@ void G_ResetInterpolations(void) } -static FileReader *OpenSavegame(const char *fn) +static FileReader *OpenSavegame() { - if (!OpenSaveGameForRead(fn)) - { - return nullptr; - } auto file = ReadSavegameChunk("snapshot.dat"); if (!file.isOpen()) { @@ -154,39 +150,13 @@ static FileReader *OpenSavegame(const char *fn) } -void ReadSaveGameHeaders(void) -{ -} - -int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh) -{ - FileReader ssfil; - auto fil = OpenSavegame(fn); - if (!fil) - return -1; - - int32_t i = sv_loadheader(*fil, 0, saveh); - if (i < 0) - goto corrupt; - - delete fil; - FinishSavegameRead(); - return 0; - -corrupt: - delete fil; - FinishSavegameRead(); - return 1; -} - - static void sv_postudload(); // XXX: keyboard input 'blocked' after load fail? (at least ESC?) int32_t G_LoadPlayer(const char *path) { - auto fil = OpenSavegame(path); + auto fil = OpenSavegame(); if (!fil) return -1; @@ -875,37 +845,6 @@ static char svgm_secwsp_string [] = "blK:swsp"; static const dataspec_t svgm_secwsp[] = { { DS_STRING, (void *)svgm_secwsp_string, 0, 1 }, - { DS_NOCHK, &numwalls, sizeof(numwalls), 1 }, - { DS_MAINAR|DS_CNT(numwalls), &wall, sizeof(walltype), (intptr_t)&numwalls }, - { DS_NOCHK, &numsectors, sizeof(numsectors), 1 }, - { DS_MAINAR|DS_CNT(numsectors), §or, sizeof(sectortype), (intptr_t)&numsectors }, - { DS_MAINAR, &sprite, sizeof(spritetype), MAXSPRITES }, -#ifdef YAX_ENABLE - { DS_NOCHK, &numyaxbunches, sizeof(numyaxbunches), 1 }, -# if !defined NEW_MAP_FORMAT - { DS_CNT(numsectors), yax_bunchnum, sizeof(yax_bunchnum[0]), (intptr_t)&numsectors }, - { DS_CNT(numwalls), yax_nextwall, sizeof(yax_nextwall[0]), (intptr_t)&numwalls }, -# endif - { DS_LOADFN|DS_PROTECTFN, (void *)&sv_postyaxload, 0, 1 }, -#endif - { 0, &Numsprites, sizeof(Numsprites), 1 }, - { 0, &tailspritefree, sizeof(tailspritefree), 1 }, - { 0, &headspritesect[0], sizeof(headspritesect[0]), MAXSECTORS+1 }, - { 0, &prevspritesect[0], sizeof(prevspritesect[0]), MAXSPRITES }, - { 0, &nextspritesect[0], sizeof(nextspritesect[0]), MAXSPRITES }, - { 0, &headspritestat[0], sizeof(headspritestat[0]), MAXSTATUS+1 }, - { 0, &prevspritestat[0], sizeof(prevspritestat[0]), MAXSPRITES }, - { 0, &nextspritestat[0], sizeof(nextspritestat[0]), MAXSPRITES }, -#ifdef USE_OPENGL - { DS_SAVEFN, (void *)&sv_prespriteextsave, 0, 1 }, -#endif - { DS_MAINAR, &spriteext, sizeof(spriteext_t), MAXSPRITES }, -#ifndef NEW_MAP_FORMAT - { DS_MAINAR, &wallext, sizeof(wallext_t), MAXWALLS }, -#endif -#ifdef USE_OPENGL - { DS_SAVEFN|DS_LOADFN, (void *)&sv_postspriteext, 0, 1 }, -#endif { DS_NOCHK, &g_cyclerCnt, sizeof(g_cyclerCnt), 1 }, { DS_CNT(g_cyclerCnt), &g_cyclers[0][0], sizeof(g_cyclers[0]), (intptr_t)&g_cyclerCnt }, { DS_NOCHK, &g_animWallCnt, sizeof(g_animWallCnt), 1 }, @@ -1349,31 +1288,6 @@ static void sv_postudload() } //static int32_t lockclock_dummy; -#ifdef USE_OPENGL -static void sv_prespriteextsave() -{ - for (int i=0; i0 ? 2 : 1); -} -#endif static void sv_postactordata() { diff --git a/source/rr/src/savegame.h b/source/rr/src/savegame.h index ea636988a..2b5960f59 100644 --- a/source/rr/src/savegame.h +++ b/source/rr/src/savegame.h @@ -61,12 +61,6 @@ 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_saveandmakesnapshot(FileWriter &fil, int8_t spot, bool isAutoSave = false); void sv_freemem(); -int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh); -void ReadSaveGameHeaders(void); - -#ifdef YAX_ENABLE -extern void sv_postyaxload(void); -#endif // XXX: The 'bitptr' decl really belongs into gamedef.h, but we don't want to // pull all of it in savegame.c? diff --git a/source/sw/src/save.cpp b/source/sw/src/save.cpp index 553c94f65..d2faa8ad0 100644 --- a/source/sw/src/save.cpp +++ b/source/sw/src/save.cpp @@ -360,9 +360,6 @@ bool GameInterface::SaveGame(FSaveGameNode *sv) } #endif - MWRITE(&numsectors,sizeof(numsectors),1,fil); - MWRITE(sector,sizeof(SECTOR), numsectors, fil); - //Sector User information for (i = 0; i < numsectors; i++) { @@ -383,29 +380,6 @@ bool GameInterface::SaveGame(FSaveGameNode *sv) } } - MWRITE(&numwalls,sizeof(numwalls),1,fil); - MWRITE(wall,sizeof(WALL),numwalls,fil); - - for (i = 0; i < MAXSPRITES; i++) - { - if (sprite[i].statnum != MAXSTATUS) - { - MWRITE(&i,sizeof(i),1,fil); - - MWRITE(&sprite[i],sizeof(SPRITE),1,fil); - } - } - i = -1; - MWRITE(&i,sizeof(i),1,fil); - - MWRITE(headspritesect,sizeof(headspritesect),1,fil); - MWRITE(prevspritesect,sizeof(prevspritesect),1,fil); - MWRITE(nextspritesect,sizeof(nextspritesect),1,fil); - MWRITE(headspritestat,sizeof(headspritestat),1,fil); - MWRITE(prevspritestat,sizeof(prevspritestat),1,fil); - MWRITE(nextspritestat,sizeof(nextspritestat),1,fil); - MWRITE(&tailspritefree,sizeof(tailspritefree),1,fil); - //User information for (i = 0; i < MAXSPRITES; i++) { @@ -615,17 +589,8 @@ bool GameInterface::SaveGame(FSaveGameNode *sv) #endif MWRITE(&totalclock,sizeof(totalclock),1,fil); - MWRITE(&numframes,sizeof(numframes),1,fil); - MWRITE(&randomseed,sizeof(randomseed),1,fil); - MWRITE(&numshades,sizeof(numshades),1,fil); - + MWRITE(&NormalVisibility,sizeof(NormalVisibility),1,fil); - MWRITE(&g_visibility,sizeof(g_visibility),1,fil); - MWRITE(¶llaxtype,sizeof(parallaxtype),1,fil); - MWRITE(¶llaxyoffs_override,sizeof(parallaxyoffs_override),1,fil); - MWRITE(¶llaxyscale_override,sizeof(parallaxyscale_override),1,fil); - MWRITE(&pskybits_override,sizeof(pskybits_override),1,fil); - MWRITE(&BorderInfo,sizeof(BorderInfo),1,fil); MWRITE(&MoveSkip2,sizeof(MoveSkip2),1,fil); MWRITE(&MoveSkip4,sizeof(MoveSkip4),1,fil); @@ -692,7 +657,6 @@ bool GameInterface::SaveGame(FSaveGameNode *sv) // game settings MWRITE(&gNet,sizeof(gNet),1,fil); - MWRITE(palette,sizeof(palette),1,fil); MWRITE(palette_data,sizeof(palette_data),1,fil); MWRITE(&gs,sizeof(gs),1,fil); for (int i = 0; i < MAXTILES; i++) @@ -702,10 +666,6 @@ bool GameInterface::SaveGame(FSaveGameNode *sv) MWRITE(&LevelSecrets,sizeof(LevelSecrets),1,fil); - MWRITE(show2dwall,sizeof(show2dwall),1,fil); - MWRITE(show2dsprite,sizeof(show2dsprite),1,fil); - MWRITE(show2dsector,sizeof(show2dsector),1,fil); - MWRITE(&Bunny_Count,sizeof(Bunny_Count),1,fil); MWRITE(UserMapName,sizeof(UserMapName),1,fil); @@ -754,8 +714,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) Saveable_Init(); - OpenSaveGameForRead(sv->Filename); - auto filr = ReadSavegameChunk("snapshot.sw"); if (!filr.isOpen()) return false; fil = &filr; @@ -853,9 +811,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) } #endif - MREAD(&numsectors,sizeof(numsectors),1,fil); - MREAD(sector,sizeof(SECTOR),numsectors,fil); - //Sector User information for (i = 0; i < numsectors; i++) { @@ -867,25 +822,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) } } - MREAD(&numwalls,sizeof(numwalls),1,fil); - MREAD(wall,sizeof(WALL),numwalls,fil); - - //Store all sprites to preserve indeces - MREAD(&i, sizeof(i),1,fil); - while (i != -1) - { - MREAD(&sprite[i], sizeof(SPRITE),1,fil); - MREAD(&i, sizeof(i),1,fil); - } - - MREAD(headspritesect,sizeof(headspritesect),1,fil); - MREAD(prevspritesect,sizeof(prevspritesect),1,fil); - MREAD(nextspritesect,sizeof(nextspritesect),1,fil); - MREAD(headspritestat,sizeof(headspritestat),1,fil); - MREAD(prevspritestat,sizeof(prevspritestat),1,fil); - MREAD(nextspritestat,sizeof(nextspritestat),1,fil); - MREAD(&tailspritefree,sizeof(tailspritefree),1,fil); - //User information memset(User, 0, sizeof(User)); @@ -1047,16 +983,8 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) #endif MREAD(&totalclock,sizeof(totalclock),1,fil); - MREAD(&numframes,sizeof(numframes),1,fil); - MREAD(&randomseed,sizeof(randomseed),1,fil); - MREAD(&numshades,sizeof(numshades),1,fil); MREAD(&NormalVisibility,sizeof(NormalVisibility),1,fil); - MREAD(&g_visibility,sizeof(g_visibility),1,fil); - MREAD(¶llaxtype,sizeof(parallaxtype),1,fil); - MREAD(¶llaxyoffs_override,sizeof(parallaxyoffs_override),1,fil); - MREAD(¶llaxyscale_override,sizeof(parallaxyscale_override),1,fil); - MREAD(&pskybits_override,sizeof(pskybits_override),1,fil); MREAD(&BorderInfo,sizeof(BorderInfo),1,fil); MREAD(&MoveSkip2,sizeof(MoveSkip2),1,fil); @@ -1127,7 +1055,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) // game settings MREAD(&gNet,sizeof(gNet),1,fil); - MREAD(palette,sizeof(palette),1,fil); MREAD(palette_data,sizeof(palette_data),1,fil); MREAD(&gs,sizeof(gs),1,fil); @@ -1139,10 +1066,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) MREAD(&LevelSecrets,sizeof(LevelSecrets),1,fil); - MREAD(show2dwall,sizeof(show2dwall),1,fil); - MREAD(show2dsprite,sizeof(show2dsprite),1,fil); - MREAD(show2dsector,sizeof(show2dsector),1,fil); - MREAD(&Bunny_Count,sizeof(Bunny_Count),1,fil); MREAD(UserMapName,sizeof(UserMapName),1,fil);