- Duke: Clean up player/actor accesses in game_misc.cpp.

This commit is contained in:
Mitchell Richters 2023-10-03 11:29:07 +11:00
parent 411115304a
commit a1e94f8278

View file

@ -243,6 +243,7 @@ void drawoverlays(double interpfrac)
{ {
if (automapMode != am_off) if (automapMode != am_off)
{ {
const auto pact = pp->GetActor();
DoInterpolations(interpfrac); DoInterpolations(interpfrac);
if (pp->newOwner == nullptr && playrunning()) if (pp->newOwner == nullptr && playrunning())
@ -254,14 +255,14 @@ void drawoverlays(double interpfrac)
} }
else else
{ {
cposxy = pp->GetActor()->interpolatedpos(interpfrac).XY(); cposxy = pact->interpolatedpos(interpfrac).XY();
cang = pp->Angles.getRenderAngles(interpfrac).Yaw; cang = pp->Angles.getRenderAngles(interpfrac).Yaw;
} }
} }
else else
{ {
cposxy = pp->GetActor()->opos.XY(); cposxy = pact->opos.XY();
cang = pp->GetActor()->PrevAngles.Yaw; cang = pact->PrevAngles.Yaw;
} }
DrawOverheadMap(cposxy, cang, interpfrac); DrawOverheadMap(cposxy, cang, interpfrac);
RestoreInterpolations(); RestoreInterpolations();
@ -269,11 +270,12 @@ void drawoverlays(double interpfrac)
} }
DrawStatusBar(); 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); 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) if (paused == 2)
@ -371,13 +373,15 @@ bool GameInterface::DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos,
// Draw sprites // Draw sprites
if (gFullMap) if (gFullMap)
{ {
const auto spact = getPlayer(screenpeek)->GetActor();
for (unsigned ii = 0; ii < sector.Size(); ii++) for (unsigned ii = 0; ii < sector.Size(); ii++)
{ {
if (show2dsector[ii]) continue; if (show2dsector[ii]) continue;
DukeSectIterator it(ii); DukeSectIterator it(ii);
while (auto act = it.Next()) 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) if ((act->spr.cstat & CSTAT_SPRITE_BLOCK_ALL) != 0)
{ {