- Duke: Manual sweep for last replacements of GetActor() calls for stack pointer.

This commit is contained in:
Mitchell Richters 2023-10-04 12:13:42 +11:00 committed by Christoph Oelckers
parent 66a77ea860
commit 63605f034d
6 changed files with 61 additions and 49 deletions

View file

@ -48,8 +48,9 @@ void drawshadows(tspriteArray& tsprites, tspritetype* t, DDukeActor* h)
else
floorz = h->floorz;
const auto spactpos = getPlayer(screenpeek)->GetActor()->getPosWithOffsetZ();
if (h->spr.pos.Z - floorz < 8 && getPlayer(screenpeek)->GetActor()->getOffsetZ() < floorz)
if (h->spr.pos.Z - floorz < 8 && spactpos.Z < floorz)
{
auto shadowspr = tsprites.newTSprite();
*shadowspr = *t;
@ -74,7 +75,7 @@ void drawshadows(tspriteArray& tsprites, tspritetype* t, DDukeActor* h)
else
{
// Alter the shadow's position so that it appears behind the sprite itself.
auto look = (shadowspr->pos.XY() - getPlayer(screenpeek)->GetActor()->spr.pos.XY()).Angle();
auto look = (shadowspr->pos.XY() - spactpos.XY()).Angle();
shadowspr->pos.XY() += look.ToVector() * 2;
}
}

View file

@ -87,8 +87,9 @@ void incur_damage_r(DDukePlayer* p)
void selectweapon_r(DDukePlayer* const p, int weap)
{
const auto pact = p->GetActor();
int i, j, k;
if (p->last_pissed_time <= (26 * 218) && p->show_empty_weapon == 0 && p->kickback_pic == 0 && p->quick_kick == 0 && p->GetActor()->spr.scale.X > 0.125 && p->access_incs == 0 && p->knee_incs == 0)
if (p->last_pissed_time <= (26 * 218) && p->show_empty_weapon == 0 && p->kickback_pic == 0 && p->quick_kick == 0 && pact->spr.scale.X > 0.125 && p->access_incs == 0 && p->knee_incs == 0)
{
if ((p->weapon_pos == 0 || (p->holster_weapon && p->weapon_pos == -9)))
{
@ -195,7 +196,7 @@ void selectweapon_r(DDukePlayer* const p, int weap)
DukeStatIterator it(STAT_ACTOR);
while (auto act = it.Next())
{
if (act->GetClass() == RedneckDynamiteClass && act->GetOwner() == p->GetActor())
if (act->GetClass() == RedneckDynamiteClass && act->GetOwner() == pact)
{
p->gotweapon[DYNAMITE_WEAPON] = true;
j = THROWINGDYNAMITE_WEAPON;
@ -425,7 +426,7 @@ int doincrements_r(DDukePlayer* p)
{
p->noise_radius = 1024;
madenoise(getPlayer(screenpeek));
p->vel.XY() += p->GetActor()->spr.Angles.Yaw.ToVector();
p->vel.XY() += pact->spr.Angles.Yaw.ToVector();
}
p->eat -= 4;
if (p->eat < 0)
@ -494,11 +495,11 @@ int doincrements_r(DDukePlayer* p)
S_PlayActorSound(DUKE_TAKEPILLS, pact);
}
if (p->access_incs && p->GetActor()->spr.pal != 1)
if (p->access_incs && pact->spr.pal != 1)
{
p->oaccess_incs = p->access_incs;
p->access_incs++;
if (p->GetActor()->spr.extra <= 0)
if (pact->spr.extra <= 0)
p->access_incs = 12;
if (p->access_incs == 12)
{
@ -603,19 +604,21 @@ void checkweapons_r(DDukePlayer* p)
&RedneckPowderKegClass, &RedneckTitgunClass, &RedneckDynamiteClass, &RedneckRipsawClass, &RedneckBowlingBallClass,
nullptr, nullptr, nullptr, &RedneckCrossbowClass };
const auto pact = p->GetActor();
if (isRRRA())
{
if (p->OnMotorcycle && numplayers > 1)
{
auto j = spawn(p->GetActor(), RedneckEmptyBikeClass);
auto j = spawn(pact, RedneckEmptyBikeClass);
if (j)
{
j->spr.Angles.Yaw = p->GetActor()->spr.Angles.Yaw;
j->spr.Angles.Yaw = pact->spr.Angles.Yaw;
j->saved_ammo = p->ammo_amount[MOTORCYCLE_WEAPON];
}
p->OnMotorcycle = 0;
p->gotweapon[MOTORCYCLE_WEAPON] = false;
p->GetActor()->spr.Angles.Pitch = nullAngle;
pact->spr.Angles.Pitch = nullAngle;
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = nullAngle;
@ -626,15 +629,15 @@ void checkweapons_r(DDukePlayer* p)
}
else if (p->OnBoat && numplayers > 1)
{
auto j = spawn(p->GetActor(), RedneckEmptyBoatClass);
auto j = spawn(pact, RedneckEmptyBoatClass);
if (j)
{
j->spr.Angles.Yaw = p->GetActor()->spr.Angles.Yaw;
j->spr.Angles.Yaw = pact->spr.Angles.Yaw;
j->saved_ammo = p->ammo_amount[BOAT_WEAPON];
}
p->OnBoat = 0;
p->gotweapon[BOAT_WEAPON] = false;
p->GetActor()->spr.Angles.Pitch = nullAngle;
pact->spr.Angles.Pitch = nullAngle;
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = nullAngle;
@ -650,7 +653,7 @@ void checkweapons_r(DDukePlayer* p)
if (krand() & 1)
{
auto weap = weapon_sprites[p->curr_weapon];
if (weap && *weap) spawn(p->GetActor(), *weap);
if (weap && *weap) spawn(pact, *weap);
}
else switch (p->curr_weapon)
{
@ -659,7 +662,7 @@ void checkweapons_r(DDukePlayer* p)
[[fallthrough]];
case DYNAMITE_WEAPON:
case CROSSBOW_WEAPON:
spawn(p->GetActor(), DukeExplosion2Class);
spawn(pact, DukeExplosion2Class);
break;
}
}
@ -668,7 +671,7 @@ void checkweapons_r(DDukePlayer* p)
{
if (p->keys[i] == 1)
{
auto j = spawn(p->GetActor(), RedneckDoorkeyClass);
auto j = spawn(pact, RedneckDoorkeyClass);
if (j) switch (i)
{
case 1:
@ -2080,7 +2083,7 @@ static void operateweapon(DDukePlayer* const p, ESyncBits actions, sectortype* p
zvel -= 4;
}
CreateActor(p->cursector, pact->getPosWithOffsetZ() + pact->spr.Angles.Yaw.ToVector() * 16, RedneckPowderKegClass, -16, DVector2(0.140625, 0.140625), p->GetActor()->spr.Angles.Yaw, vel * 2, zvel, pact, 1);
CreateActor(p->cursector, pact->getPosWithOffsetZ() + pact->spr.Angles.Yaw.ToVector() * 16, RedneckPowderKegClass, -16, DVector2(0.140625, 0.140625), pact->spr.Angles.Yaw, vel * 2, zvel, pact, 1);
}
p->kickback_pic++;
if (p->kickback_pic > 20)
@ -2929,6 +2932,8 @@ HORIZONLY:
void OnMotorcycle(DDukePlayer *p)
{
const auto pact = p->GetActor();
if (!p->OnMotorcycle && p->cursector->lotag != ST_2_UNDERWATER)
{
p->over_shoulder_on = 0;
@ -2938,10 +2943,10 @@ void OnMotorcycle(DDukePlayer *p)
p->gotweapon[MOTORCYCLE_WEAPON] = true;
p->vel.X = 0;
p->vel.Y = 0;
p->GetActor()->spr.Angles.Pitch = nullAngle;
pact->spr.Angles.Pitch = nullAngle;
}
if (!S_CheckActorSoundPlaying(p->GetActor(),186))
S_PlayActorSound(186, p->GetActor());
if (!S_CheckActorSoundPlaying(pact, 186))
S_PlayActorSound(186, pact);
}
//---------------------------------------------------------------------------
@ -2969,7 +2974,7 @@ void OffMotorcycle(DDukePlayer *p)
p->gotweapon[MOTORCYCLE_WEAPON] = false;
p->curr_weapon = p->last_full_weapon;
checkavailweapon(p);
p->GetActor()->spr.Angles.Pitch = nullAngle;
pact->spr.Angles.Pitch = nullAngle;
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = nullAngle;
@ -2977,12 +2982,12 @@ void OffMotorcycle(DDukePlayer *p)
p->VBumpTarget = 0;
p->VBumpNow = 0;
p->TurbCount = 0;
p->vel.XY() = p->GetActor()->spr.Angles.Yaw.ToVector() / 2048.;
p->vel.XY() = pact->spr.Angles.Yaw.ToVector() / 2048.;
p->moto_underwater = 0;
auto spawned = spawn(p->GetActor(), RedneckEmptyBikeClass);
auto spawned = spawn(pact, RedneckEmptyBikeClass);
if (spawned)
{
spawned->spr.Angles.Yaw = p->GetActor()->spr.Angles.Yaw;
spawned->spr.Angles.Yaw = pact->spr.Angles.Yaw;
spawned->saved_ammo = p->ammo_amount[MOTORCYCLE_WEAPON];
}
}
@ -3019,11 +3024,12 @@ void OffBoat(DDukePlayer *p)
{
if (p->OnBoat)
{
const auto pact = p->GetActor();
p->OnBoat = 0;
p->gotweapon[BOAT_WEAPON] = false;
p->curr_weapon = p->last_full_weapon;
checkavailweapon(p);
p->GetActor()->spr.Angles.Pitch = nullAngle;
pact->spr.Angles.Pitch = nullAngle;
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = nullAngle;
@ -3031,12 +3037,12 @@ void OffBoat(DDukePlayer *p)
p->VBumpTarget = 0;
p->VBumpNow = 0;
p->TurbCount = 0;
p->vel.XY() = p->GetActor()->spr.Angles.Yaw.ToVector() / 2048.;
p->vel.XY() = pact->spr.Angles.Yaw.ToVector() / 2048.;
p->moto_underwater = 0;
auto spawned = spawn(p->GetActor(), RedneckEmptyBoatClass);
auto spawned = spawn(pact, RedneckEmptyBoatClass);
if (spawned)
{
spawned->spr.Angles.Yaw = p->GetActor()->spr.Angles.Yaw;
spawned->spr.Angles.Yaw = pact->spr.Angles.Yaw;
spawned->saved_ammo = p->ammo_amount[BOAT_WEAPON];
}
}

View file

@ -109,13 +109,14 @@ void fakedomovethings(void)
int psect, psectlotag, tempsect, backcstat;
uint8_t shrunk, spritebridge;
ESyncBits actions;
const auto pact = p->GetActor();
syn = (input *)&inputfifo[fakemovefifoplc&(MOVEFIFOSIZ-1)][myconnectindex];
p = &ps[myconnectindex];
backcstat = p->GetActor()->s.cstat;
p->GetActor()->s.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
backcstat = pact->s.cstat;
pact->s.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
actions = syn->actions;
@ -123,7 +124,7 @@ void fakedomovethings(void)
psectlotag = psect->lotag;
spritebridge = 0;
shrunk = (p->GetActor()->s.y_repeat < (isRR()? 8 : 32));
shrunk = (pact->s.y_repeat < (isRR()? 8 : 32));
if( ud.clipping == 0 && ( psect->floortexture == mirrortex || psect == nullptr) )
{
@ -180,7 +181,7 @@ void fakedomovethings(void)
psectlotag = 0;
spritebridge = 1;
}
if(badguy(chz.actor) && chz.actor()->s.ScaleX() > 0.375 && abs(p->GetActor()->s.z- chz.actor()->s.z) < (84<<8) )
if(badguy(chz.actor) && chz.actor()->s.ScaleX() > 0.375 && abs(pact->s.z- chz.actor()->s.z) < (84<<8) )
{
j = g etangle(chz.actor()->s.x-myx, chz.actor()->s.y-myy);
myxvel -= b cos(j, 4);
@ -188,7 +189,7 @@ void fakedomovethings(void)
}
}
if( p->GetActor()->s.extra <= 0 )
if( pact->s.extra <= 0 )
{
if( psectlotag == 2 )
{
@ -524,7 +525,7 @@ ENDFAKEPROCESSINPUT:
myhorizbak[fakemovefifoplc&(MOVEFIFOSIZ-1)] = myhoriz;
fakemovefifoplc++;
p->GetActor()->s.cstat = backcstat;
pact->s.cstat = backcstat;
}
#endif

View file

@ -1737,6 +1737,7 @@ void togglewallswitches(walltype* wwal, const TexExtInfo& ext, int lotag, int& c
bool checkhitswitch(DDukePlayer* const p, walltype* wwal, DDukeActor* act)
{
const auto pact = p->GetActor();
uint8_t switchpal;
int lotag, hitag, correctdips, numdips;
DVector2 spos;
@ -1812,11 +1813,11 @@ bool checkhitswitch(DDukePlayer* const p, walltype* wwal, DDukeActor* act)
p->SeaSick = 350;
operateactivators(668, p);
operatemasterswitches(668);
S_PlayActorSound(328, p->GetActor());
S_PlayActorSound(328, pact);
return 1;
}
}
DVector3 v(spos, p->GetActor()->getOffsetZ());
DVector3 v(spos, pact->getOffsetZ());
if (swdef.type != SwitchDef::None || isadoorwall(texid))
{
@ -1826,9 +1827,9 @@ bool checkhitswitch(DDukePlayer* const p, walltype* wwal, DDukeActor* act)
{
FSoundID sound = swdef.soundid != NO_SOUND ? swdef.soundid : S_FindSoundByResID(SWITCH_ON);
if (act) S_PlaySound3D(sound, act, v);
else S_PlaySound3D(sound, p->GetActor(), v);
else S_PlaySound3D(sound, pact, v);
if (numdips != correctdips) return 0;
S_PlaySound3D(END_OF_LEVEL_WARN, p->GetActor(), v);
S_PlaySound3D(END_OF_LEVEL_WARN, pact, v);
}
if (swdef.type == SwitchDef::Multi)
{
@ -1877,7 +1878,7 @@ bool checkhitswitch(DDukePlayer* const p, walltype* wwal, DDukeActor* act)
}
operateactivators(lotag, p);
operateforcefields(p->GetActor(), lotag);
operateforcefields(pact, lotag);
operatemasterswitches(lotag);
if (swdef.type == SwitchDef::Combo) return 1;
@ -1886,7 +1887,7 @@ bool checkhitswitch(DDukePlayer* const p, walltype* wwal, DDukeActor* act)
{
FSoundID sound = swdef.soundid != NO_SOUND ? swdef.soundid : S_FindSoundByResID(SWITCH_ON);
if (act) S_PlaySound3D(sound, act, v);
else S_PlaySound3D(sound, p->GetActor(), v);
else S_PlaySound3D(sound, pact, v);
}
else if (hitag != 0)
{
@ -1895,7 +1896,7 @@ bool checkhitswitch(DDukePlayer* const p, walltype* wwal, DDukeActor* act)
if (act && (flags & SF_TALK) == 0)
S_PlaySound3D(hitag, act, v);
else
S_PlayActorSound(hitag, p->GetActor());
S_PlayActorSound(hitag, pact);
}
return 1;

View file

@ -131,23 +131,24 @@ void checkplayerhurt_d(DDukePlayer* p, const Collision& coll)
if (p->hurt_delay > 0) p->hurt_delay--;
else if (wal->cstat & (CSTAT_WALL_BLOCK | CSTAT_WALL_ALIGN_BOTTOM | CSTAT_WALL_MASKED | CSTAT_WALL_BLOCK_HITSCAN))
{
const auto pact = p->GetActor();
int tf = tileflags(wal->overtexture);
if (tf & TFLAG_ANIMFORCEFIELD)
{
p->GetActor()->spr.extra -= 5;
pact->spr.extra -= 5;
p->hurt_delay = 16;
SetPlayerPal(p, PalEntry(32, 32, 0, 0));
p->vel.XY() = -p->GetActor()->spr.Angles.Yaw.ToVector() * 16;
S_PlayActorSound(DUKE_LONGTERM_PAIN, p->GetActor());
p->vel.XY() = -pact->spr.Angles.Yaw.ToVector() * 16;
S_PlayActorSound(DUKE_LONGTERM_PAIN, pact);
checkhitwall(p->GetActor(), wal, p->GetActor()->getPosWithOffsetZ() + p->GetActor()->spr.Angles.Yaw.ToVector() * 2);
checkhitwall(pact, wal, pact->getPosWithOffsetZ() + pact->spr.Angles.Yaw.ToVector() * 2);
}
else if (tf & TFLAG_FORCEFIELD)
{
p->hurt_delay = 26;
checkhitwall(p->GetActor(), wal, p->GetActor()->getPosWithOffsetZ() + p->GetActor()->spr.Angles.Yaw.ToVector() * 2);
checkhitwall(pact, wal, pact->getPosWithOffsetZ() + pact->spr.Angles.Yaw.ToVector() * 2);
}
}
}
@ -160,10 +161,11 @@ void checkplayerhurt_d(DDukePlayer* p, const Collision& coll)
void clearcameras(DDukePlayer* p)
{
p->GetActor()->restorepos();
const auto pact = p->GetActor();
pact->restorepos();
p->newOwner = nullptr;
updatesector(p->GetActor()->getPosWithOffsetZ(), &p->cursector);
updatesector(pact->getPosWithOffsetZ(), &p->cursector);
DukeStatIterator it(STAT_ACTOR);
while (auto act = it.Next())

View file

@ -147,8 +147,9 @@ void checkplayerhurt_r(DDukePlayer* p, const Collision &coll)
int tf = tileflags(wal->overtexture);
if (tf & TFLAG_FORCEFIELD)
{
const auto pact = p->GetActor();
p->hurt_delay = 26;
checkhitwall(p->GetActor(), wal, p->GetActor()->getPosWithOffsetZ() + p->GetActor()->spr.Angles.Yaw.ToVector() * 2);
checkhitwall(pact, wal, pact->getPosWithOffsetZ() + pact->spr.Angles.Yaw.ToVector() * 2);
}
}
}