2019-11-14 21:07:43 +01:00
|
|
|
#pragma once
|
|
|
|
|
2020-04-11 23:54:33 +02:00
|
|
|
#include "resourcefile.h"
|
2020-11-21 21:31:50 +01:00
|
|
|
#include "build.h"
|
2021-11-11 20:20:00 +01:00
|
|
|
#include "gamefuncs.h"
|
2021-11-26 13:00:33 +01:00
|
|
|
#include "coreactor.h"
|
2020-11-21 21:31:50 +01:00
|
|
|
|
2019-11-27 00:41:26 +01:00
|
|
|
// Savegame utilities
|
|
|
|
class FileReader;
|
2021-05-13 13:44:58 +02:00
|
|
|
extern int SaveVersion;
|
2019-11-27 00:41:26 +01:00
|
|
|
|
|
|
|
FString G_BuildSaveName (const char *prefix);
|
2019-12-10 22:22:59 +01:00
|
|
|
int G_ValidateSavegame(FileReader &fr, FString *savetitle, bool formenu);
|
2019-11-27 00:41:26 +01:00
|
|
|
|
2021-05-12 00:31:49 +02:00
|
|
|
void G_LoadGame(const char* filename, bool hidecon = false);
|
2021-05-12 00:21:26 +02:00
|
|
|
void G_SaveGame(const char* fn, const char* desc);
|
|
|
|
void G_DoSaveGame(bool okForQuicksave, bool forceQuicksave, const char* filename, const char* description);
|
2021-05-12 00:31:49 +02:00
|
|
|
void G_DoLoadGame();
|
2020-10-07 18:32:57 +02:00
|
|
|
|
2020-10-04 18:31:48 +02:00
|
|
|
void M_Autosave();
|
2020-01-21 19:22:38 +01:00
|
|
|
|
2019-11-27 00:41:26 +01:00
|
|
|
#define SAVEGAME_EXT ".dsave"
|
2019-11-30 19:23:54 +01:00
|
|
|
|
2021-04-02 11:55:23 +02:00
|
|
|
|
2021-11-26 13:00:33 +01:00
|
|
|
template<> inline FSerializer& Serialize(FSerializer& arc, const char* keyname, sectortype*& w, sectortype** def)
|
2021-04-02 11:55:23 +02:00
|
|
|
{
|
2022-05-21 13:57:47 +02:00
|
|
|
assert(arc.isReading() || w == nullptr || (w >= §or[0] && w <= §or.Last()));
|
2021-11-11 20:20:00 +01:00
|
|
|
int ndx = w ? sectnum(w) : -1;
|
2021-04-02 11:55:23 +02:00
|
|
|
arc(keyname, ndx);
|
2022-05-21 13:57:47 +02:00
|
|
|
w = !validSectorIndex(ndx) ? nullptr : §or[ndx];
|
2021-04-02 11:55:23 +02:00
|
|
|
return arc;
|
|
|
|
}
|
|
|
|
|
2021-11-26 13:00:33 +01:00
|
|
|
template<> inline FSerializer& Serialize(FSerializer& arc, const char* keyname, walltype*& w, walltype** def)
|
2021-04-02 11:55:23 +02:00
|
|
|
{
|
2021-11-11 20:20:00 +01:00
|
|
|
int ndx = w ? wallnum(w) : -1;
|
2021-04-02 11:55:23 +02:00
|
|
|
arc(keyname, ndx);
|
2022-05-21 13:57:47 +02:00
|
|
|
w = !validWallIndex(ndx) ? nullptr : &wall[ndx];
|
2021-04-02 11:55:23 +02:00
|
|
|
return arc;
|
|
|
|
}
|
|
|
|
|
2021-11-26 13:00:33 +01:00
|
|
|
template<class T>
|
|
|
|
inline FSerializer& Serialize(FSerializer& arc, const char* keyname, THitInfo<T>& w, THitInfo<T>* def)
|
|
|
|
{
|
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc("sect", w.hitSector)
|
|
|
|
("sprite", w.hitActor)
|
|
|
|
("wall", w.hitWall)
|
2022-08-17 18:53:45 +02:00
|
|
|
("x", w.hitpos.X)
|
|
|
|
("y", w.hitpos.Y)
|
|
|
|
("z", w.hitpos.Z)
|
2021-11-26 13:00:33 +01:00
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
|
|
|
}
|
|
|
|
|
2021-11-26 13:41:15 +01:00
|
|
|
template<class T>
|
|
|
|
inline FSerializer& Serialize(FSerializer& arc, const char* keyname, TCollision<T>& w, TCollision<T>* def)
|
|
|
|
{
|
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc("type", w.type);
|
|
|
|
if (w.type == kHitWall) arc("index", w.hitWall);
|
|
|
|
else if (w.type == kHitSprite) arc("index", w.hitActor);
|
|
|
|
else if (w.type == kHitSector) arc("index", w.hitSector);
|
|
|
|
else if (arc.isReading()) w.hitSector = nullptr;
|
|
|
|
arc.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
|
|
|
}
|