- store owner outside the sprite.

This commit is contained in:
Christoph Oelckers 2021-11-19 21:19:18 +01:00
parent 10e6486744
commit b9602bbb05
2 changed files with 8 additions and 6 deletions

View file

@ -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()

View file

@ -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)