mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-14 11:50:49 +00:00
- cleaned out the remains of the old savegame code.
This commit is contained in:
parent
67dff2a863
commit
1d6d58538c
4 changed files with 34 additions and 113 deletions
|
@ -268,13 +268,6 @@ void FuncMummy(int nSector, int edx, int nRun);
|
||||||
|
|
||||||
// object
|
// object
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
kMaxPoints = 1024,
|
|
||||||
kMaxSlides = 128,
|
|
||||||
kMaxElevs = 1024
|
|
||||||
};
|
|
||||||
|
|
||||||
enum kStatus
|
enum kStatus
|
||||||
{
|
{
|
||||||
kStatDestructibleSprite = 97,
|
kStatDestructibleSprite = 97,
|
||||||
|
@ -487,12 +480,6 @@ void FuncSpider(int a, int b, int nRun);
|
||||||
|
|
||||||
// switch
|
// switch
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
kMaxLinks = 1024,
|
|
||||||
kMaxSwitches = 1024
|
|
||||||
};
|
|
||||||
|
|
||||||
void InitLink();
|
void InitLink();
|
||||||
void InitSwitch();
|
void InitSwitch();
|
||||||
|
|
||||||
|
|
|
@ -223,19 +223,6 @@ const uint32_t kSpiritX = 106;
|
||||||
const uint32_t kSpiritY = 97;
|
const uint32_t kSpiritY = 97;
|
||||||
const uint32_t WorktileSize = kSpiritX * 2 * kSpiritY * 2;
|
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
|
struct GameInterface : ::GameInterface
|
||||||
{
|
{
|
||||||
|
@ -248,8 +235,6 @@ struct GameInterface : ::GameInterface
|
||||||
bool StartGame(FNewGameStartup& gs) override;
|
bool StartGame(FNewGameStartup& gs) override;
|
||||||
FSavegameInfo GetSaveSig() override;
|
FSavegameInfo GetSaveSig() override;
|
||||||
void SerializeGameState(FSerializer& arc);
|
void SerializeGameState(FSerializer& arc);
|
||||||
bool LoadGame() override;
|
|
||||||
bool SaveGame() override;
|
|
||||||
bool CanSave() override;
|
bool CanSave() override;
|
||||||
ReservedSpace GetReservedScreenSpace(int viewsize) override { return { 0, 24 }; }
|
ReservedSpace GetReservedScreenSpace(int viewsize) override { return { 0, 24 }; }
|
||||||
void QuitToTitle() override;
|
void QuitToTitle() override;
|
||||||
|
|
|
@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "statistics.h"
|
#include "statistics.h"
|
||||||
#include "v_draw.h"
|
#include "v_draw.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "mapinfo.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
@ -75,6 +76,7 @@ unsigned int menu_RandomBit2()
|
||||||
|
|
||||||
void InitEnergyTile()
|
void InitEnergyTile()
|
||||||
{
|
{
|
||||||
|
word_9AB5B = 0;
|
||||||
memset(energytile, 96, sizeof(energytile));
|
memset(energytile, 96, sizeof(energytile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,60 +63,44 @@ void SerializeSet(FSerializer& arc);
|
||||||
void SerializeSpider(FSerializer& arc);
|
void SerializeSpider(FSerializer& arc);
|
||||||
void SerializeWasp(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)
|
void GameInterface::SerializeGameState(FSerializer& arc)
|
||||||
{
|
{
|
||||||
if (arc.BeginObject("exhumed"))
|
if (arc.BeginObject("exhumed"))
|
||||||
{
|
{
|
||||||
SerializeState(arc);
|
SerializeState(arc);
|
||||||
SerializeAnim(arc);
|
SerializeAnim(arc);
|
||||||
SerializeBubbles(arc);
|
SerializeBubbles(arc);
|
||||||
SerializeBullet(arc);
|
SerializeBullet(arc);
|
||||||
SerializeGrenade(arc);
|
SerializeGrenade(arc);
|
||||||
SerializeGun(arc);
|
SerializeGun(arc);
|
||||||
SerializeInit(arc);
|
SerializeInit(arc);
|
||||||
SerializeItems(arc);
|
SerializeItems(arc);
|
||||||
SerializeMove(arc);
|
SerializeMove(arc);
|
||||||
SerializeLighting(arc);
|
SerializeLighting(arc);
|
||||||
SerializeObjects(arc);
|
SerializeObjects(arc);
|
||||||
SerializePlayer(arc);
|
SerializePlayer(arc);
|
||||||
SerializeRa(arc);
|
SerializeRa(arc);
|
||||||
SerializeRand(arc);
|
SerializeRand(arc);
|
||||||
SerializeRunList(arc);
|
SerializeRunList(arc);
|
||||||
SerializeSequence(arc);
|
SerializeSequence(arc);
|
||||||
SerializeSnake(arc);
|
SerializeSnake(arc);
|
||||||
SerializeSwitch(arc);
|
SerializeSwitch(arc);
|
||||||
SerializeView(arc);
|
SerializeView(arc);
|
||||||
|
|
||||||
SerializeAnubis(arc);
|
SerializeAnubis(arc);
|
||||||
SerializeFish(arc);
|
SerializeFish(arc);
|
||||||
SerializeLavadude(arc);
|
SerializeLavadude(arc);
|
||||||
SerializeLion(arc);
|
SerializeLion(arc);
|
||||||
SerializeMummy(arc);
|
SerializeMummy(arc);
|
||||||
SerializeQueen(arc);
|
SerializeQueen(arc);
|
||||||
SerializeRat(arc);
|
SerializeRat(arc);
|
||||||
SerializeRex(arc);
|
SerializeRex(arc);
|
||||||
SerializeRoach(arc);
|
SerializeRoach(arc);
|
||||||
SerializeScorpion(arc);
|
SerializeScorpion(arc);
|
||||||
SerializeSet(arc);
|
SerializeSet(arc);
|
||||||
SerializeSpider(arc);
|
SerializeSpider(arc);
|
||||||
SerializeWasp(arc);
|
SerializeWasp(arc);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool GameInterface::LoadGame()
|
|
||||||
{
|
|
||||||
|
|
||||||
for (auto sgh : sghelpers) sgh->Load();
|
|
||||||
FinishSavegameRead();
|
|
||||||
|
|
||||||
// reset the sky in case it hasn't been done yet.
|
// reset the sky in case it hasn't been done yet.
|
||||||
psky_t* pSky = tileSetupSky(DEFAULTPSKY);
|
psky_t* pSky = tileSetupSky(DEFAULTPSKY);
|
||||||
pSky->tileofs[0] = 0;
|
pSky->tileofs[0] = 0;
|
||||||
|
@ -146,43 +130,6 @@ bool GameInterface::LoadGame()
|
||||||
}
|
}
|
||||||
|
|
||||||
Mus_ResumeSaved();
|
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
|
END_PS_NS
|
||||||
|
|
Loading…
Reference in a new issue