From 27dfefef6c23cd815c2c98547585c1998976512f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 21 Nov 2020 19:39:24 +0100 Subject: [PATCH] - JSON serializer for warp.cpp --- source/blood/src/loadsave.cpp | 4 ++-- source/blood/src/warp.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/source/blood/src/loadsave.cpp b/source/blood/src/loadsave.cpp index 1a4aac992..cd818002b 100644 --- a/source/blood/src/loadsave.cpp +++ b/source/blood/src/loadsave.cpp @@ -729,7 +729,6 @@ void MirrorLoadSaveConstruct(void); void PlayerLoadSaveConstruct(void); void TriggersLoadSaveConstruct(void); void ViewLoadSaveConstruct(void); -void WarpLoadSaveConstruct(void); #ifdef NOONE_EXTENSIONS void NNLoadSaveConstruct(void); #endif @@ -747,7 +746,6 @@ void LoadSaveSetup(void) PlayerLoadSaveConstruct(); TriggersLoadSaveConstruct(); ViewLoadSaveConstruct(); - WarpLoadSaveConstruct(); #ifdef NOONE_EXTENSIONS NNLoadSaveConstruct(); #endif @@ -756,6 +754,7 @@ void LoadSaveSetup(void) void SerializeEvents(FSerializer& arc); void SerializeSequences(FSerializer& arc); +void SerializeWarp(FSerializer& arc); void GameInterface::SerializeGameState(FSerializer& arc) { @@ -770,6 +769,7 @@ void GameInterface::SerializeGameState(FSerializer& arc) SerializeEvents(arc); SerializeSequences(arc); + SerializeWarp(arc); } diff --git a/source/blood/src/warp.cpp b/source/blood/src/warp.cpp index e21935f5a..fcf69048a 100644 --- a/source/blood/src/warp.cpp +++ b/source/blood/src/warp.cpp @@ -302,6 +302,40 @@ int CheckLink(int *x, int *y, int *z, int *nSector) return 0; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +FSerializer& Serialize(FSerializer& arc, const char* keyname, ZONE& w, ZONE* def) +{ + if (arc.BeginObject(keyname)) + { + arc("x", w.x) + ("y", w.y) + ("z", w.z) + ("sector", w.sectnum) + ("angle", w.ang) + .EndObject(); + } + return arc; +} + +void SerializeWarp(FSerializer& arc) +{ + if (arc.BeginObject("warp")) + { + arc.Array("startzone", gStartZone, kMaxPlayers) + .Array("upperlink", gUpperLink, numsectors) + .Array("lowerlink", gLowerLink, numsectors) + .EndObject(); + } +} + + + + class WarpLoadSave : public LoadSave { public: