- Duke: Clean up player/actor accesses in checkp().

This commit is contained in:
Mitchell Richters 2023-10-03 22:59:28 +11:00
parent f80290d80e
commit 5d628d712c

View file

@ -1327,7 +1327,7 @@ int checkp(DDukeActor* self, DDukePlayer* p, int flags)
bool j = 0;
double vel = self->vel.X;
unsigned plindex = unsigned(p->pnum);
const auto pact = p->GetActor();
// sigh.. this was yet another place where number literals were used as bit masks for every single value, making the code totally unreadable.
if ((flags & pducking) && p->on_ground && !!(p->cmd.ucmd.actions & SB_CROUCH))
@ -1342,7 +1342,7 @@ int checkp(DDukeActor* self, DDukePlayer* p, int flags)
j = 1;
else if ((flags & prunning) && vel >= 0.5 && !!(p->cmd.ucmd.actions & SB_RUN))
j = 1;
else if ((flags & phigher) && p->GetActor()->getOffsetZ() < self->spr.pos.Z - 48)
else if ((flags & phigher) && pact->getOffsetZ() < self->spr.pos.Z - 48)
j = 1;
else if ((flags & pwalkingback) && vel <= -0.5 && !(!!(p->cmd.ucmd.actions & SB_RUN)))
j = 1;
@ -1350,7 +1350,7 @@ int checkp(DDukeActor* self, DDukePlayer* p, int flags)
j = 1;
else if ((flags & pkicking) && (p->quick_kick > 0 || (p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 0)))
j = 1;
else if ((flags & pshrunk) && p->GetActor()->spr.scale.X < (isRR() ? 0.125 : 0.5))
else if ((flags & pshrunk) && pact->spr.scale.X < (isRR() ? 0.125 : 0.5))
j = 1;
else if ((flags & pjetpack) && p->jetpack_on)
j = 1;
@ -1358,17 +1358,22 @@ int checkp(DDukeActor* self, DDukePlayer* p, int flags)
j = 1;
else if ((flags & ponground) && p->on_ground)
j = 1;
else if ((flags & palive) && p->GetActor()->spr.scale.X > (isRR() ? 0.125 : 0.5) && p->GetActor()->spr.extra > 0 && p->timebeforeexit == 0)
else if ((flags & palive) && pact->spr.scale.X > (isRR() ? 0.125 : 0.5) && pact->spr.extra > 0 && p->timebeforeexit == 0)
j = 1;
else if ((flags & pdead) && p->GetActor()->spr.extra <= 0)
else if ((flags & pdead) && pact->spr.extra <= 0)
j = 1;
else if ((flags & pfacing))
{
DAngle ang;
if (self->isPlayer() && ud.multimode > 1)
ang = absangle(getPlayer(otherp)->GetActor()->spr.Angles.Yaw, (p->GetActor()->spr.pos.XY() - getPlayer(otherp)->GetActor()->spr.pos.XY()).Angle());
{
const auto pact2 = getPlayer(otherp)->GetActor();
ang = absangle(pact2->spr.Angles.Yaw, (pact->spr.pos.XY() - pact2->spr.pos.XY()).Angle());
}
else
ang = absangle(p->GetActor()->spr.Angles.Yaw, (self->spr.pos.XY() - p->GetActor()->spr.pos.XY()).Angle());
{
ang = absangle(pact->spr.Angles.Yaw, (self->spr.pos.XY() - pact->spr.pos.XY()).Angle());
}
j = ang < DAngle22_5;
}