From b9602bbb0586ced8d1bd226ff664e129394b5b95 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 Nov 2021 21:19:18 +0100 Subject: [PATCH] - store owner outside the sprite. --- source/games/blood/src/bloodactor.h | 9 +++++---- source/games/blood/src/loadsave.cpp | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/source/games/blood/src/bloodactor.h b/source/games/blood/src/bloodactor.h index fd4fbdd40..35f83868d 100644 --- a/source/games/blood/src/bloodactor.h +++ b/source/games/blood/src/bloodactor.h @@ -120,6 +120,7 @@ public: SPRITEMASS spriteMass; GENDUDEEXTRA genDudeExtra; DBloodActor* prevmarker; // needed by the nnext marker code. This originally hijacked targetX in XSPRITE + DBloodActor* ownerActor; // was previously stored in the sprite's owner field. POINT3D basePoint; ConditionElement condition[2]; bool explosionhackflag; // this originally hijacked the target field which is not safe when working with pointers. @@ -157,13 +158,12 @@ public: void SetOwner(DBloodActor* own) { - s().owner = own ? own->GetSpriteIndex() : -1; + ownerActor = own; } DBloodActor* GetOwner() { - if (s().owner == -1 || s().owner == kMaxSprites - 1) return nullptr; - return base() + s().owner; + return ownerActor; } void SetTarget(DBloodActor* own) @@ -200,12 +200,13 @@ public: void SetSpecialOwner() // nnext hackery { + ownerActor = nullptr; s().owner = kMaxSprites - 1; } bool GetSpecialOwner() { - return (s().owner == kMaxSprites - 1); + return ownerActor == nullptr && (s().owner == kMaxSprites - 1); } bool IsPlayerActor() diff --git a/source/games/blood/src/loadsave.cpp b/source/games/blood/src/loadsave.cpp index 546d09958..ca28c6ca8 100644 --- a/source/games/blood/src/loadsave.cpp +++ b/source/games/blood/src/loadsave.cpp @@ -491,12 +491,13 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, DBloodActor& w, DB // The rest is only relevant if the actor has an xsprite. if (w.hasX()) { - arc ("xsprite", w.xsprite, def->xsprite) + arc("xsprite", w.xsprite, def->xsprite) ("dudeslope", w.dudeSlope, def->dudeSlope) ("dudeextra", w.dudeExtra, def->dudeExtra) ("explosionflag", w.explosionhackflag, def->explosionhackflag) ("spritehit", w.hit, def->hit) - ("basepoint", w.basePoint, def->basePoint); + ("basepoint", w.basePoint, def->basePoint) + ("owneractor", w.ownerActor, def->ownerActor); #ifdef NOONE_EXTENSIONS if (gModernMap)