-proper owner storage for Duke.

This commit is contained in:
Christoph Oelckers 2021-11-19 21:26:52 +01:00
parent b9602bbb05
commit fa48b740c0
3 changed files with 11 additions and 14 deletions

View file

@ -1259,10 +1259,6 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
if (bSet) act->extra = lValue;
else SetGameVarID(lVar2, act->extra, sActor, sPlayer);
break;
case ACTOR_HTOWNER:
if (bSet) act->owner = lValue;
else SetGameVarID(lVar2, act->owner, sActor, sPlayer);
break;
case ACTOR_HTMOVFLAG:
if (bSet) act->movflag = lValue;
else SetGameVarID(lVar2, act->movflag, sActor, sPlayer);

View file

@ -293,7 +293,8 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, DDukeActor& w, DDu
("picnum", w.picnum, def->picnum)
("ang", w.ang, def->ang)
("extra", w.extra, def->extra)
("owner", w.owner, def->owner)
("owneractor", w.ownerActor, def->ownerActor)
("owner", w.hitOwnerActor, def->hitOwnerActor)
("movflag", w.movflag, def->movflag)
("tempang", w.tempang, def->tempang)
("actorstayput", w.actorstayput, def->actorstayput)

View file

@ -24,7 +24,7 @@ struct DDukeActor
{
uint8_t cgg;
uint8_t spriteextra; // moved here for easier maintenance. This was originally a hacked in field in the sprite structure called 'filler'.
short owner; // todo: make a pointer.
DDukeActor* ownerActor, * hitOwnerActor;
short picnum, ang, extra, movflag;
short tempang, dispicnum;
short timetosleep;
@ -50,36 +50,36 @@ struct DDukeActor
void clear()
{
actorstayput = nullptr;
ownerActor = nullptr;
hitOwnerActor = nullptr;
cgg = spriteextra = 0;
picnum = ang = extra = owner = movflag = tempang = dispicnum = timetosleep = 0;
picnum = ang = extra = movflag = tempang = dispicnum = timetosleep = 0;
floorz = ceilingz = lastvx = lastvy = aflags = saved_ammo = 0;
memset(temp_data, 0, sizeof(temp_data));
}
int GetSpriteIndex() const { return int(this - array()); }
// Wrapper around some ugliness. The 'owner' field gets abused by some actors, so better wrap its real use in access functions to keep things in order.
// This once was stored in the owner field of the sprite
inline DDukeActor* GetOwner()
{
return s->owner < 0 ? nullptr : &array()[s->owner];
return ownerActor;
}
inline void SetOwner(DDukeActor* a)
{
s->owner = a? a->GetSpriteIndex() : -1;
ownerActor = a;
}
// same for the 'hittype' owner - which is normally the shooter in an attack.
inline DDukeActor* GetHitOwner()
{
return owner < 0 ? nullptr : &array()[owner];
return hitOwnerActor;
}
inline void SetHitOwner(DDukeActor* a)
{
owner = a ? a->GetSpriteIndex() : -1;
hitOwnerActor = a;
}
// This used the Owner field - better move this to something more safe.
inline bool IsActiveCrane()
{
return s->owner == -2;