- moved some non-owner info out of the owner field.

This only handles items where both reading and writing can be located.
This commit is contained in:
Christoph Oelckers 2020-11-02 22:39:41 +01:00
parent 15fc884909
commit 4c3435bacf
3 changed files with 17 additions and 11 deletions

View file

@ -3308,7 +3308,7 @@ void handle_se03(DDukeActor *actor)
if (t[4] == 0) return;
int x, p = findplayer(actor, &x);
int palvals = s->owner; // this type hijacks the Owner field!!!
int palvals = actor->palvals;
// if(t[5] > 0) { t[5]--; break; }
@ -3360,7 +3360,7 @@ void handle_se04(DDukeActor *actor)
int sh = s->hitag;
int j;
int palvals = s->owner; // this type hijacks the Owner field!!!
int palvals = actor->palvals;
if ((global_random / (sh + 1) & 31) < 4)
{
@ -3814,7 +3814,7 @@ void handle_se13(DDukeActor* actor)
if (s->ang == 512)
{
if (s->owner) // hijacked!
if (actor->spriteextra)
{
if (abs(t[0] - sc->ceilingz) >= j)
sc->ceilingz += sgn(t[0] - sc->ceilingz) * j;

View file

@ -168,7 +168,8 @@ int initspriteforspawn(DDukeActor* actj, int pn, const std::initializer_list<int
act->bposy = sp->y;
act->bposz = sp->z;
sp->owner = act->owner = i;
act->SetOwner(act);
act->SetHitOwner(act);
act->cgg = 0;
act->movflag = 0;
act->tempang = 0;
@ -722,7 +723,7 @@ void spawneffector(DDukeActor* actor)
t[1] = sector[sect].floorz;
bool ceiling = (abs(t[0] - sp->z) < abs(t[1] - sp->z));
sp->owner = ceiling; // hijack
actor->spriteextra = ceiling;
if (sp->ang == 512)
{
@ -845,7 +846,7 @@ void spawneffector(DDukeActor* actor)
sector[sect].floorshade = sp->shade;
sector[sect].ceilingshade = sp->shade;
sp->owner = (sector[sect].ceilingpal << 8) | sector[sect].floorpal; // hijack
actor->palvals = (sector[sect].ceilingpal << 8) | sector[sect].floorpal;
//fix all the walls;
@ -897,7 +898,7 @@ void spawneffector(DDukeActor* actor)
startwall = sector[sect].wallptr;
endwall = startwall + sector[sect].wallnum;
sp->owner = (sector[sect].ceilingpal << 8) | sector[sect].floorpal; // hijack
actor->palvals = (sector[sect].ceilingpal << 8) | sector[sect].floorpal;
for (s = startwall; s < endwall; s++)
if (wall[s].shade > t[3])

View file

@ -28,7 +28,12 @@ struct weaponhit
short picnum, ang, extra, owner, movflag;
short tempang, actorstayput, dispicnum;
short timetosleep;
int floorz, ceilingz, lastvx, lastvy, bposx, bposy, bposz, aflags, saved_ammo;
int floorz, ceilingz, lastvx, lastvy, bposx, bposy, bposz, aflags;
union
{
int saved_ammo;
int palvals;
};
int temp_data[6];
weaponhit* temp_actor, *seek_actor;
spritetype& s; // direct reference to the corresponding sprite.
@ -69,15 +74,15 @@ struct weaponhit
owner = a->GetIndex();
}
// The crane is a good example of an actor hijacking the 'owner' field for something other than an actual owner. Abstract this away.
// This used the owner field - better move this to something more safe.
inline bool IsActiveCrane()
{
return s.owner == -2;
return palvals == -2;
}
inline void SetActiveCrane(bool yes)
{
s.owner = yes ? -2 : -1;
palvals = yes ? -2 : -1;
}
int PlayerIndex() const