From 6bb5958a9368d272176acfa11e2f804d20ba0fbc Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 3 Oct 2023 22:59:28 +1100 Subject: [PATCH] - Duke: Clean up player/actor accesses in `checkp()`. --- source/games/duke/src/player.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 5d017ba7a..c532e09cd 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -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; }