From a1e94f8278bc7e2e299a9a7b803fe6f8c9bdf8c9 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 3 Oct 2023 11:29:07 +1100 Subject: [PATCH] - Duke: Clean up player/actor accesses in `game_misc.cpp`. --- source/games/duke/src/game_misc.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 75975fc73..921cde136 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -243,6 +243,7 @@ void drawoverlays(double interpfrac) { if (automapMode != am_off) { + const auto pact = pp->GetActor(); DoInterpolations(interpfrac); if (pp->newOwner == nullptr && playrunning()) @@ -254,14 +255,14 @@ void drawoverlays(double interpfrac) } else { - cposxy = pp->GetActor()->interpolatedpos(interpfrac).XY(); + cposxy = pact->interpolatedpos(interpfrac).XY(); cang = pp->Angles.getRenderAngles(interpfrac).Yaw; } } else { - cposxy = pp->GetActor()->opos.XY(); - cang = pp->GetActor()->PrevAngles.Yaw; + cposxy = pact->opos.XY(); + cang = pact->PrevAngles.Yaw; } DrawOverheadMap(cposxy, cang, interpfrac); RestoreInterpolations(); @@ -269,11 +270,12 @@ void drawoverlays(double interpfrac) } DrawStatusBar(); + const auto spp = getPlayer(myconnectindex); - if (getPlayer(myconnectindex)->newOwner == nullptr && ud.cameraactor == nullptr) + if (spp->newOwner == nullptr && ud.cameraactor == nullptr) { auto offsets = pp->Angles.getCrosshairOffsets(interpfrac); - DrawCrosshair(getPlayer(screenpeek)->last_extra, offsets.first.X, offsets.first.Y + (pp->over_shoulder_on ? 2.5 : 0), isRR() ? 0.5 : 1, offsets.second); + DrawCrosshair(pp->last_extra, offsets.first.X, offsets.first.Y + (pp->over_shoulder_on ? 2.5 : 0), isRR() ? 0.5 : 1, offsets.second); } if (paused == 2) @@ -371,13 +373,15 @@ bool GameInterface::DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, // Draw sprites if (gFullMap) { + const auto spact = getPlayer(screenpeek)->GetActor(); + for (unsigned ii = 0; ii < sector.Size(); ii++) { if (show2dsector[ii]) continue; DukeSectIterator it(ii); while (auto act = it.Next()) { - if (act == getPlayer(screenpeek)->GetActor() || (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) || act->spr.cstat == CSTAT_SPRITE_BLOCK_ALL || act->spr.scale.X == 0) continue; + if (act == spact || (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) || act->spr.cstat == CSTAT_SPRITE_BLOCK_ALL || act->spr.scale.X == 0) continue; if ((act->spr.cstat & CSTAT_SPRITE_BLOCK_ALL) != 0) {