- 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 else
floorz = h->floorz; 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(); auto shadowspr = tsprites.newTSprite();
*shadowspr = *t; *shadowspr = *t;
@ -74,7 +75,7 @@ void drawshadows(tspriteArray& tsprites, tspritetype* t, DDukeActor* h)
else else
{ {
// Alter the shadow's position so that it appears behind the sprite itself. // 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; 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) void selectweapon_r(DDukePlayer* const p, int weap)
{ {
const auto pact = p->GetActor();
int i, j, k; 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))) 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); DukeStatIterator it(STAT_ACTOR);
while (auto act = it.Next()) 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; p->gotweapon[DYNAMITE_WEAPON] = true;
j = THROWINGDYNAMITE_WEAPON; j = THROWINGDYNAMITE_WEAPON;
@ -425,7 +426,7 @@ int doincrements_r(DDukePlayer* p)
{ {
p->noise_radius = 1024; p->noise_radius = 1024;
madenoise(getPlayer(screenpeek)); madenoise(getPlayer(screenpeek));
p->vel.XY() += p->GetActor()->spr.Angles.Yaw.ToVector(); p->vel.XY() += pact->spr.Angles.Yaw.ToVector();
} }
p->eat -= 4; p->eat -= 4;
if (p->eat < 0) if (p->eat < 0)
@ -494,11 +495,11 @@ int doincrements_r(DDukePlayer* p)
S_PlayActorSound(DUKE_TAKEPILLS, pact); 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->oaccess_incs = p->access_incs;
p->access_incs++; p->access_incs++;
if (p->GetActor()->spr.extra <= 0) if (pact->spr.extra <= 0)
p->access_incs = 12; p->access_incs = 12;
if (p->access_incs == 12) if (p->access_incs == 12)
{ {
@ -603,19 +604,21 @@ void checkweapons_r(DDukePlayer* p)
&RedneckPowderKegClass, &RedneckTitgunClass, &RedneckDynamiteClass, &RedneckRipsawClass, &RedneckBowlingBallClass, &RedneckPowderKegClass, &RedneckTitgunClass, &RedneckDynamiteClass, &RedneckRipsawClass, &RedneckBowlingBallClass,
nullptr, nullptr, nullptr, &RedneckCrossbowClass }; nullptr, nullptr, nullptr, &RedneckCrossbowClass };
const auto pact = p->GetActor();
if (isRRRA()) if (isRRRA())
{ {
if (p->OnMotorcycle && numplayers > 1) if (p->OnMotorcycle && numplayers > 1)
{ {
auto j = spawn(p->GetActor(), RedneckEmptyBikeClass); auto j = spawn(pact, RedneckEmptyBikeClass);
if (j) 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]; j->saved_ammo = p->ammo_amount[MOTORCYCLE_WEAPON];
} }
p->OnMotorcycle = 0; p->OnMotorcycle = 0;
p->gotweapon[MOTORCYCLE_WEAPON] = false; p->gotweapon[MOTORCYCLE_WEAPON] = false;
p->GetActor()->spr.Angles.Pitch = nullAngle; pact->spr.Angles.Pitch = nullAngle;
p->moto_do_bump = 0; p->moto_do_bump = 0;
p->MotoSpeed = 0; p->MotoSpeed = 0;
p->TiltStatus = nullAngle; p->TiltStatus = nullAngle;
@ -626,15 +629,15 @@ void checkweapons_r(DDukePlayer* p)
} }
else if (p->OnBoat && numplayers > 1) else if (p->OnBoat && numplayers > 1)
{ {
auto j = spawn(p->GetActor(), RedneckEmptyBoatClass); auto j = spawn(pact, RedneckEmptyBoatClass);
if (j) 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]; j->saved_ammo = p->ammo_amount[BOAT_WEAPON];
} }
p->OnBoat = 0; p->OnBoat = 0;
p->gotweapon[BOAT_WEAPON] = false; p->gotweapon[BOAT_WEAPON] = false;
p->GetActor()->spr.Angles.Pitch = nullAngle; pact->spr.Angles.Pitch = nullAngle;
p->moto_do_bump = 0; p->moto_do_bump = 0;
p->MotoSpeed = 0; p->MotoSpeed = 0;
p->TiltStatus = nullAngle; p->TiltStatus = nullAngle;
@ -650,7 +653,7 @@ void checkweapons_r(DDukePlayer* p)
if (krand() & 1) if (krand() & 1)
{ {
auto weap = weapon_sprites[p->curr_weapon]; 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) else switch (p->curr_weapon)
{ {
@ -659,7 +662,7 @@ void checkweapons_r(DDukePlayer* p)
[[fallthrough]]; [[fallthrough]];
case DYNAMITE_WEAPON: case DYNAMITE_WEAPON:
case CROSSBOW_WEAPON: case CROSSBOW_WEAPON:
spawn(p->GetActor(), DukeExplosion2Class); spawn(pact, DukeExplosion2Class);
break; break;
} }
} }
@ -668,7 +671,7 @@ void checkweapons_r(DDukePlayer* p)
{ {
if (p->keys[i] == 1) if (p->keys[i] == 1)
{ {
auto j = spawn(p->GetActor(), RedneckDoorkeyClass); auto j = spawn(pact, RedneckDoorkeyClass);
if (j) switch (i) if (j) switch (i)
{ {
case 1: case 1:
@ -2080,7 +2083,7 @@ static void operateweapon(DDukePlayer* const p, ESyncBits actions, sectortype* p
zvel -= 4; 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++; p->kickback_pic++;
if (p->kickback_pic > 20) if (p->kickback_pic > 20)
@ -2929,6 +2932,8 @@ HORIZONLY:
void OnMotorcycle(DDukePlayer *p) void OnMotorcycle(DDukePlayer *p)
{ {
const auto pact = p->GetActor();
if (!p->OnMotorcycle && p->cursector->lotag != ST_2_UNDERWATER) if (!p->OnMotorcycle && p->cursector->lotag != ST_2_UNDERWATER)
{ {
p->over_shoulder_on = 0; p->over_shoulder_on = 0;
@ -2938,10 +2943,10 @@ void OnMotorcycle(DDukePlayer *p)
p->gotweapon[MOTORCYCLE_WEAPON] = true; p->gotweapon[MOTORCYCLE_WEAPON] = true;
p->vel.X = 0; p->vel.X = 0;
p->vel.Y = 0; p->vel.Y = 0;
p->GetActor()->spr.Angles.Pitch = nullAngle; pact->spr.Angles.Pitch = nullAngle;
} }
if (!S_CheckActorSoundPlaying(p->GetActor(),186)) if (!S_CheckActorSoundPlaying(pact, 186))
S_PlayActorSound(186, p->GetActor()); S_PlayActorSound(186, pact);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -2969,7 +2974,7 @@ void OffMotorcycle(DDukePlayer *p)
p->gotweapon[MOTORCYCLE_WEAPON] = false; p->gotweapon[MOTORCYCLE_WEAPON] = false;
p->curr_weapon = p->last_full_weapon; p->curr_weapon = p->last_full_weapon;
checkavailweapon(p); checkavailweapon(p);
p->GetActor()->spr.Angles.Pitch = nullAngle; pact->spr.Angles.Pitch = nullAngle;
p->moto_do_bump = 0; p->moto_do_bump = 0;
p->MotoSpeed = 0; p->MotoSpeed = 0;
p->TiltStatus = nullAngle; p->TiltStatus = nullAngle;
@ -2977,12 +2982,12 @@ void OffMotorcycle(DDukePlayer *p)
p->VBumpTarget = 0; p->VBumpTarget = 0;
p->VBumpNow = 0; p->VBumpNow = 0;
p->TurbCount = 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; p->moto_underwater = 0;
auto spawned = spawn(p->GetActor(), RedneckEmptyBikeClass); auto spawned = spawn(pact, RedneckEmptyBikeClass);
if (spawned) 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]; spawned->saved_ammo = p->ammo_amount[MOTORCYCLE_WEAPON];
} }
} }
@ -3019,11 +3024,12 @@ void OffBoat(DDukePlayer *p)
{ {
if (p->OnBoat) if (p->OnBoat)
{ {
const auto pact = p->GetActor();
p->OnBoat = 0; p->OnBoat = 0;
p->gotweapon[BOAT_WEAPON] = false; p->gotweapon[BOAT_WEAPON] = false;
p->curr_weapon = p->last_full_weapon; p->curr_weapon = p->last_full_weapon;
checkavailweapon(p); checkavailweapon(p);
p->GetActor()->spr.Angles.Pitch = nullAngle; pact->spr.Angles.Pitch = nullAngle;
p->moto_do_bump = 0; p->moto_do_bump = 0;
p->MotoSpeed = 0; p->MotoSpeed = 0;
p->TiltStatus = nullAngle; p->TiltStatus = nullAngle;
@ -3031,12 +3037,12 @@ void OffBoat(DDukePlayer *p)
p->VBumpTarget = 0; p->VBumpTarget = 0;
p->VBumpNow = 0; p->VBumpNow = 0;
p->TurbCount = 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; p->moto_underwater = 0;
auto spawned = spawn(p->GetActor(), RedneckEmptyBoatClass); auto spawned = spawn(pact, RedneckEmptyBoatClass);
if (spawned) 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]; spawned->saved_ammo = p->ammo_amount[BOAT_WEAPON];
} }
} }

View file

@ -109,13 +109,14 @@ void fakedomovethings(void)
int psect, psectlotag, tempsect, backcstat; int psect, psectlotag, tempsect, backcstat;
uint8_t shrunk, spritebridge; uint8_t shrunk, spritebridge;
ESyncBits actions; ESyncBits actions;
const auto pact = p->GetActor();
syn = (input *)&inputfifo[fakemovefifoplc&(MOVEFIFOSIZ-1)][myconnectindex]; syn = (input *)&inputfifo[fakemovefifoplc&(MOVEFIFOSIZ-1)][myconnectindex];
p = &ps[myconnectindex]; p = &ps[myconnectindex];
backcstat = p->GetActor()->s.cstat; backcstat = pact->s.cstat;
p->GetActor()->s.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; pact->s.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
actions = syn->actions; actions = syn->actions;
@ -123,7 +124,7 @@ void fakedomovethings(void)
psectlotag = psect->lotag; psectlotag = psect->lotag;
spritebridge = 0; 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) ) if( ud.clipping == 0 && ( psect->floortexture == mirrortex || psect == nullptr) )
{ {
@ -180,7 +181,7 @@ void fakedomovethings(void)
psectlotag = 0; psectlotag = 0;
spritebridge = 1; 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); j = g etangle(chz.actor()->s.x-myx, chz.actor()->s.y-myy);
myxvel -= b cos(j, 4); 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 ) if( psectlotag == 2 )
{ {
@ -524,7 +525,7 @@ ENDFAKEPROCESSINPUT:
myhorizbak[fakemovefifoplc&(MOVEFIFOSIZ-1)] = myhoriz; myhorizbak[fakemovefifoplc&(MOVEFIFOSIZ-1)] = myhoriz;
fakemovefifoplc++; fakemovefifoplc++;
p->GetActor()->s.cstat = backcstat; pact->s.cstat = backcstat;
} }
#endif #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) bool checkhitswitch(DDukePlayer* const p, walltype* wwal, DDukeActor* act)
{ {
const auto pact = p->GetActor();
uint8_t switchpal; uint8_t switchpal;
int lotag, hitag, correctdips, numdips; int lotag, hitag, correctdips, numdips;
DVector2 spos; DVector2 spos;
@ -1812,11 +1813,11 @@ bool checkhitswitch(DDukePlayer* const p, walltype* wwal, DDukeActor* act)
p->SeaSick = 350; p->SeaSick = 350;
operateactivators(668, p); operateactivators(668, p);
operatemasterswitches(668); operatemasterswitches(668);
S_PlayActorSound(328, p->GetActor()); S_PlayActorSound(328, pact);
return 1; return 1;
} }
} }
DVector3 v(spos, p->GetActor()->getOffsetZ()); DVector3 v(spos, pact->getOffsetZ());
if (swdef.type != SwitchDef::None || isadoorwall(texid)) 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); FSoundID sound = swdef.soundid != NO_SOUND ? swdef.soundid : S_FindSoundByResID(SWITCH_ON);
if (act) S_PlaySound3D(sound, act, v); 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; 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) if (swdef.type == SwitchDef::Multi)
{ {
@ -1877,7 +1878,7 @@ bool checkhitswitch(DDukePlayer* const p, walltype* wwal, DDukeActor* act)
} }
operateactivators(lotag, p); operateactivators(lotag, p);
operateforcefields(p->GetActor(), lotag); operateforcefields(pact, lotag);
operatemasterswitches(lotag); operatemasterswitches(lotag);
if (swdef.type == SwitchDef::Combo) return 1; 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); FSoundID sound = swdef.soundid != NO_SOUND ? swdef.soundid : S_FindSoundByResID(SWITCH_ON);
if (act) S_PlaySound3D(sound, act, v); if (act) S_PlaySound3D(sound, act, v);
else S_PlaySound3D(sound, p->GetActor(), v); else S_PlaySound3D(sound, pact, v);
} }
else if (hitag != 0) else if (hitag != 0)
{ {
@ -1895,7 +1896,7 @@ bool checkhitswitch(DDukePlayer* const p, walltype* wwal, DDukeActor* act)
if (act && (flags & SF_TALK) == 0) if (act && (flags & SF_TALK) == 0)
S_PlaySound3D(hitag, act, v); S_PlaySound3D(hitag, act, v);
else else
S_PlayActorSound(hitag, p->GetActor()); S_PlayActorSound(hitag, pact);
} }
return 1; return 1;

View file

@ -131,23 +131,24 @@ void checkplayerhurt_d(DDukePlayer* p, const Collision& coll)
if (p->hurt_delay > 0) p->hurt_delay--; 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)) 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); int tf = tileflags(wal->overtexture);
if (tf & TFLAG_ANIMFORCEFIELD) if (tf & TFLAG_ANIMFORCEFIELD)
{ {
p->GetActor()->spr.extra -= 5; pact->spr.extra -= 5;
p->hurt_delay = 16; p->hurt_delay = 16;
SetPlayerPal(p, PalEntry(32, 32, 0, 0)); SetPlayerPal(p, PalEntry(32, 32, 0, 0));
p->vel.XY() = -p->GetActor()->spr.Angles.Yaw.ToVector() * 16; p->vel.XY() = -pact->spr.Angles.Yaw.ToVector() * 16;
S_PlayActorSound(DUKE_LONGTERM_PAIN, p->GetActor()); 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) else if (tf & TFLAG_FORCEFIELD)
{ {
p->hurt_delay = 26; 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) void clearcameras(DDukePlayer* p)
{ {
p->GetActor()->restorepos(); const auto pact = p->GetActor();
pact->restorepos();
p->newOwner = nullptr; p->newOwner = nullptr;
updatesector(p->GetActor()->getPosWithOffsetZ(), &p->cursector); updatesector(pact->getPosWithOffsetZ(), &p->cursector);
DukeStatIterator it(STAT_ACTOR); DukeStatIterator it(STAT_ACTOR);
while (auto act = it.Next()) while (auto act = it.Next())

View file

@ -147,8 +147,9 @@ void checkplayerhurt_r(DDukePlayer* p, const Collision &coll)
int tf = tileflags(wal->overtexture); int tf = tileflags(wal->overtexture);
if (tf & TFLAG_FORCEFIELD) if (tf & TFLAG_FORCEFIELD)
{ {
const auto pact = p->GetActor();
p->hurt_delay = 26; 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);
} }
} }
} }