From 31a43cdd79ba0b16cfbe3acc90424a263634d7f3 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 3 Oct 2023 22:55:02 +1100 Subject: [PATCH] - Duke: Clean up player/actor accesses in `shoot()`. --- source/games/duke/src/player.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 7fe89bfdb..2f318ee6a 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -927,7 +927,7 @@ void playerAimDown(DDukePlayer* const p, ESyncBits actions) void shoot(DDukeActor* actor, PClass* cls) { - int p; + int pnum; DVector3 spos; DAngle sang; @@ -936,14 +936,14 @@ void shoot(DDukeActor* actor, PClass* cls) sang = actor->spr.Angles.Yaw; if (actor->isPlayer()) { - p = actor->PlayerIndex(); - spos = actor->getPosWithOffsetZ().plusZ(getPlayer(p)->pyoff + 4); - - getPlayer(p)->crack_time = CRACK_TIME; + pnum = actor->PlayerIndex(); + const auto p = getPlayer(pnum); + spos = actor->getPosWithOffsetZ().plusZ(p->pyoff + 4); + p->crack_time = CRACK_TIME; } else { - p = -1; + pnum = -1; auto tex = TexMan.GetGameTexture(actor->spr.spritetexture()); spos = actor->spr.pos.plusZ(-(actor->spr.scale.Y * tex->GetDisplayHeight() * 0.5) + 4); @@ -958,7 +958,7 @@ void shoot(DDukeActor* actor, PClass* cls) if (cls == nullptr) return; - CallShootThis(static_cast(GetDefaultByType(cls)), actor, p, spos, sang); + CallShootThis(static_cast(GetDefaultByType(cls)), actor, pnum, spos, sang); } //---------------------------------------------------------------------------