- cleaned out the remains of the old savegame code.

This commit is contained in:
Christoph Oelckers 2020-11-30 14:16:46 +01:00
parent 67dff2a863
commit 1d6d58538c
4 changed files with 34 additions and 113 deletions

View file

@ -268,13 +268,6 @@ void FuncMummy(int nSector, int edx, int nRun);
// object
enum
{
kMaxPoints = 1024,
kMaxSlides = 128,
kMaxElevs = 1024
};
enum kStatus
{
kStatDestructibleSprite = 97,
@ -487,12 +480,6 @@ void FuncSpider(int a, int b, int nRun);
// switch
enum
{
kMaxLinks = 1024,
kMaxSwitches = 1024
};
void InitLink();
void InitSwitch();

View file

@ -223,19 +223,6 @@ const uint32_t kSpiritX = 106;
const uint32_t kSpiritY = 97;
const uint32_t WorktileSize = kSpiritX * 2 * kSpiritY * 2;
struct SavegameHelper
{
FString Name;
TArray<std::pair<void*, size_t>> Elements;
SavegameHelper(const char* name, ...);
void Load();
void Save();
};
#define SV(v) &v, sizeof(v)
#define SA(a) &a, sizeof(a)
struct GameInterface : ::GameInterface
{
@ -248,8 +235,6 @@ struct GameInterface : ::GameInterface
bool StartGame(FNewGameStartup& gs) override;
FSavegameInfo GetSaveSig() override;
void SerializeGameState(FSerializer& arc);
bool LoadGame() override;
bool SaveGame() override;
bool CanSave() override;
ReservedSpace GetReservedScreenSpace(int viewsize) override { return { 0, 24 }; }
void QuitToTitle() override;

View file

@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "statistics.h"
#include "v_draw.h"
#include <string>
#include "mapinfo.h"
#include <assert.h>
@ -75,6 +76,7 @@ unsigned int menu_RandomBit2()
void InitEnergyTile()
{
word_9AB5B = 0;
memset(energytile, 96, sizeof(energytile));
}

View file

@ -63,14 +63,6 @@ void SerializeSet(FSerializer& arc);
void SerializeSpider(FSerializer& arc);
void SerializeWasp(FSerializer& arc);
static TArray<SavegameHelper*> sghelpers(TArray<SavegameHelper*>::NoInit);
bool GameInterface::SaveGame()
{
for (auto sgh : sghelpers) sgh->Save();
return 1; // CHECKME
}
void GameInterface::SerializeGameState(FSerializer& arc)
{
if (arc.BeginObject("exhumed"))
@ -109,14 +101,6 @@ void GameInterface::SerializeGameState(FSerializer& arc)
SerializeSpider(arc);
SerializeWasp(arc);
}
}
bool GameInterface::LoadGame()
{
for (auto sgh : sghelpers) sgh->Load();
FinishSavegameRead();
// reset the sky in case it hasn't been done yet.
psky_t* pSky = tileSetupSky(DEFAULTPSKY);
pSky->tileofs[0] = 0;
@ -146,43 +130,6 @@ bool GameInterface::LoadGame()
}
Mus_ResumeSaved();
return 1; // CHECKME
}
SavegameHelper::SavegameHelper(const char* name, ...)
{
Name = name;
sghelpers.Push(this);
va_list ap;
va_start(ap, name);
for(;;)
{
void* addr = va_arg(ap, void*);
if (!addr) break;
size_t size = va_arg(ap, size_t);
Elements.Push(std::make_pair(addr, size));
}
}
void SavegameHelper::Load()
{
auto fr = ReadSavegameChunk(Name);
if (!fr.isOpen()) return;
for (auto& entry : Elements)
{
auto read = fr.Read(entry.first, entry.second);
if (read != entry.second) I_Error("Save game read error in %s", Name.GetChars());
}
}
void SavegameHelper::Save()
{
auto fw = WriteSavegameChunk(Name);
for (auto& entry : Elements)
{
auto write = fw->Write(entry.first, entry.second);
if (write != entry.second) I_Error("Save game write error in %s", Name.GetChars());
}
}
END_PS_NS