From dc0d2012752ff1d4cae342ee46063be14bad1db0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 27 Aug 2021 18:21:01 +0200 Subject: [PATCH] - Blood: added serialization for the tracking conditions array. --- source/games/blood/src/nnexts.cpp | 32 ++++++++++++++++++++++++++++++- source/games/blood/src/nnexts.h | 10 +++++----- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index c8539a6ec..6fed49f2d 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1919,7 +1919,7 @@ void trPlayerCtrlLink(XSPRITE* pXSource, PLAYER* pPlayer, bool checkCondition) { for (unsigned k = 0; k < pCond->length; k++) { if (pCond->obj[k].type != OBJ_SPRITE || pCond->obj[k].index != pXSource->reference) continue; pCond->obj[k].index = pPlayer->nSprite; - pCond->obj[k].cmd = pPlayer->pXSprite->command; + pCond->obj[k].cmd = (uint8_t)pPlayer->pXSprite->command; break; } @@ -7912,6 +7912,34 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SPRITEMASS& w, SPR return arc; } +FSerializer& Serialize(FSerializer& arc, const char* keyname, OBJECTS_TO_TRACK& w, OBJECTS_TO_TRACK* def) +{ + static OBJECTS_TO_TRACK nul; + if (arc.isReading()) w = {}; + if (arc.BeginObject(keyname)) + { + arc("type", w.type, &nul.type) + ("index", w.index, &nul.index) + ("xrepeat", w.cmd, &nul.cmd) + .EndObject(); + } + return arc; +} + +FSerializer& Serialize(FSerializer& arc, const char* keyname, TRCONDITION& w, TRCONDITION* def) +{ + static TRCONDITION nul; + if (arc.isReading()) w = {}; + if (arc.BeginObject(keyname)) + { + arc("length", w.length, &nul.length) + ("xindex", w.xindex, &nul.xindex) + .Array("obj", w.obj, w.length) + .EndObject(); + } + return arc; +} + void SerializeNNExts(FSerializer& arc) { if (arc.BeginObject("nnexts")) @@ -7938,6 +7966,8 @@ void SerializeNNExts(FSerializer& arc) ("impactspritescount", gImpactSpritesCount) .Array("impactspriteslist", gImpactSpritesList, gImpactSpritesCount) ("eventredirects", gEventRedirectsUsed) + ("trconditioncount", gTrackingCondsCount) + .Array("trcondition", gCondition, gTrackingCondsCount) .EndObject(); } } diff --git a/source/games/blood/src/nnexts.h b/source/games/blood/src/nnexts.h index 044758c2a..9f7abfd70 100644 --- a/source/games/blood/src/nnexts.h +++ b/source/games/blood/src/nnexts.h @@ -235,14 +235,14 @@ struct TRPLAYERCTRL { // this one for controlling the player using triggers (mov }; struct OBJECTS_TO_TRACK { - signed int type: 3; - unsigned int index: 16; - unsigned int cmd: 8; + int8_t type; + uint8_t cmd; + int index; }; struct TRCONDITION { - signed int xindex: 16; - unsigned int length: 8; + signed int xindex; + unsigned int length; OBJECTS_TO_TRACK obj[kMaxTracedObjects]; };