mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-28 12:30:46 +00:00
- SW: save tracks as JSON.
This commit is contained in:
parent
bb8309831c
commit
b85da221d7
2 changed files with 60 additions and 67 deletions
|
@ -1679,8 +1679,8 @@ typedef struct TRACK
|
||||||
{
|
{
|
||||||
TRACK_POINTp TrackPoint;
|
TRACK_POINTp TrackPoint;
|
||||||
int ttflags;
|
int ttflags;
|
||||||
short flags;
|
int flags;
|
||||||
short NumPoints;
|
int NumPoints;
|
||||||
|
|
||||||
void FreeTrackPoints()
|
void FreeTrackPoints()
|
||||||
{
|
{
|
||||||
|
@ -2267,8 +2267,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;
|
|
||||||
void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); }
|
void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); }
|
||||||
FString GetCoordString() override;
|
FString GetCoordString() override;
|
||||||
ReservedSpace GetReservedScreenSpace(int viewsize) override;
|
ReservedSpace GetReservedScreenSpace(int viewsize) override;
|
||||||
|
|
|
@ -1169,6 +1169,59 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, GAME_SET& w, GAME_
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, TRACK_POINT& w, TRACK_POINT* def)
|
||||||
|
{
|
||||||
|
static TRACK_POINT nul;
|
||||||
|
if (!def)
|
||||||
|
{
|
||||||
|
def = &nul;
|
||||||
|
if (arc.isReading()) w = {};
|
||||||
|
}
|
||||||
|
if (arc.BeginObject(keyname))
|
||||||
|
{
|
||||||
|
arc("x", w.x, def->x)
|
||||||
|
("y", w.y, def->y)
|
||||||
|
("z", w.z, def->z)
|
||||||
|
("ang", w.ang, def->ang)
|
||||||
|
("tag_low", w.tag_low, def->tag_low)
|
||||||
|
("tag_high", w.tag_high, def->tag_high)
|
||||||
|
("filler", w.filler, def->filler)
|
||||||
|
.EndObject();
|
||||||
|
}
|
||||||
|
return arc;
|
||||||
|
}
|
||||||
|
|
||||||
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, TRACK& w, TRACK* def)
|
||||||
|
{
|
||||||
|
static int nul;
|
||||||
|
if (!def)
|
||||||
|
{
|
||||||
|
if (arc.isReading()) w.flags = w.ttflags = 0;
|
||||||
|
}
|
||||||
|
if (arc.BeginObject(keyname))
|
||||||
|
{
|
||||||
|
arc("numpoints", w.NumPoints, nul)
|
||||||
|
("flags", w.flags, nul)
|
||||||
|
("ttflag", w.ttflags, nul);
|
||||||
|
|
||||||
|
if (arc.isReading())
|
||||||
|
{
|
||||||
|
if (w.TrackPoint) FreeMem(w.TrackPoint);
|
||||||
|
int size = w.NumPoints ? w.NumPoints : 1;
|
||||||
|
w.TrackPoint = (TRACK_POINT*)CallocMem(sizeof(TRACK_POINT), size);
|
||||||
|
}
|
||||||
|
if (w.NumPoints > 0) arc.Array("points", w.TrackPoint, w.NumPoints)
|
||||||
|
.EndObject();
|
||||||
|
}
|
||||||
|
return arc;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void GameInterface::SerializeGameState(FSerializer& arc)
|
void GameInterface::SerializeGameState(FSerializer& arc)
|
||||||
{
|
{
|
||||||
Saveable_Init();
|
Saveable_Init();
|
||||||
|
@ -1220,75 +1273,19 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
||||||
("sumowasseen", sumowasseen)
|
("sumowasseen", sumowasseen)
|
||||||
("zillawasseen", zillawasseen)
|
("zillawasseen", zillawasseen)
|
||||||
.Array("BossSpriteNum", BossSpriteNum, 3)
|
.Array("BossSpriteNum", BossSpriteNum, 3)
|
||||||
|
.Array("tracks", Track, countof(Track))
|
||||||
;
|
;
|
||||||
postSerializePanelSprites(arc);
|
postSerializePanelSprites(arc);
|
||||||
arc.EndObject();
|
arc.EndObject();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
if (arc.isReading())
|
||||||
|
|
||||||
bool GameInterface::SaveGame()
|
|
||||||
{
|
|
||||||
|
|
||||||
// workaround until the level info here has been transitioned.
|
|
||||||
auto fil = WriteSavegameChunk("snapshot.sw");
|
|
||||||
|
|
||||||
|
|
||||||
MWRITE(Track, sizeof(Track),1,fil);
|
|
||||||
for (int i = 0; i < MAX_TRACKS; i++)
|
|
||||||
{
|
{
|
||||||
ASSERT(Track[i].TrackPoint);
|
|
||||||
if (Track[i].NumPoints == 0)
|
|
||||||
MWRITE(Track[i].TrackPoint, sizeof(TRACK_POINT),1,fil);
|
|
||||||
else
|
|
||||||
MWRITE(Track[i].TrackPoint, Track[i].NumPoints * sizeof(TRACK_POINT),1,fil);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GameInterface::LoadGame()
|
|
||||||
{
|
|
||||||
MFILE_READ fil;
|
|
||||||
int i,j,saveisshot=0;
|
|
||||||
short ndx,SpriteNum,sectnum;
|
|
||||||
PLAYERp pp = NULL;
|
|
||||||
USERp u;
|
|
||||||
SECTOR_OBJECTp sop;
|
|
||||||
SECT_USERp sectu;
|
|
||||||
ANIMp a;
|
|
||||||
PANEL_SPRITEp psp,next;
|
|
||||||
|
|
||||||
|
|
||||||
auto filr = ReadSavegameChunk("snapshot.sw");
|
|
||||||
if (!filr.isOpen()) return false;
|
|
||||||
fil = &filr;
|
|
||||||
|
|
||||||
MREAD(Track, sizeof(Track),1,fil);
|
|
||||||
for (i = 0; i < MAX_TRACKS; i++)
|
|
||||||
{
|
|
||||||
if (Track[i].NumPoints == 0)
|
|
||||||
{
|
|
||||||
Track[i].TrackPoint = (TRACK_POINTp)CallocMem(sizeof(TRACK_POINT), 1);
|
|
||||||
MREAD(Track[i].TrackPoint, sizeof(TRACK_POINT),1,fil);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Track[i].TrackPoint = (TRACK_POINTp)CallocMem(Track[i].NumPoints * sizeof(TRACK_POINT), 1);
|
|
||||||
MREAD(Track[i].TrackPoint, Track[i].NumPoints * sizeof(TRACK_POINT),1,fil);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DoTheCache();
|
DoTheCache();
|
||||||
|
|
||||||
{
|
|
||||||
int SavePlayClock = PlayClock;
|
int SavePlayClock = PlayClock;
|
||||||
InitTimingVars();
|
InitTimingVars();
|
||||||
PlayClock = SavePlayClock;
|
PlayClock = SavePlayClock;
|
||||||
}
|
|
||||||
InitNetVars();
|
InitNetVars();
|
||||||
|
|
||||||
screenpeek = myconnectindex;
|
screenpeek = myconnectindex;
|
||||||
|
@ -1300,12 +1297,10 @@ bool GameInterface::LoadGame()
|
||||||
// this is not a new game
|
// this is not a new game
|
||||||
ShadowWarrior::NewGame = false;
|
ShadowWarrior::NewGame = false;
|
||||||
|
|
||||||
|
DoPlayerDivePalette(Player + myconnectindex);
|
||||||
DoPlayerDivePalette(Player+myconnectindex);
|
DoPlayerNightVisionPalette(Player + myconnectindex);
|
||||||
DoPlayerNightVisionPalette(Player+myconnectindex);
|
|
||||||
|
|
||||||
InitLevelGlobals();
|
InitLevelGlobals();
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
END_SW_NS
|
END_SW_NS
|
||||||
|
|
Loading…
Reference in a new issue