From 4c3435bacf69363f870b6d61c8dacc36fbed07f8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 2 Nov 2020 22:39:41 +0100 Subject: [PATCH] - moved some non-owner info out of the owner field. This only handles items where both reading and writing can be located. --- source/games/duke/src/actors.cpp | 6 +++--- source/games/duke/src/spawn.cpp | 9 +++++---- source/games/duke/src/types.h | 13 +++++++++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 584b1269f..390820a4d 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -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; diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index e9f18fc95..da8f4d2c3 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -168,7 +168,8 @@ int initspriteforspawn(DDukeActor* actj, int pn, const std::initializer_listbposy = 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]) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 18e204466..7ae22fc8c 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -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