From 6f248ff34c94c96b7981753e5be274a1df7be061 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 2 Oct 2023 20:45:06 +1100 Subject: [PATCH] - Duke: Clean up player/actor accesses in `alterang()`. --- source/games/duke/src/actors.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 372b3b0d5..6e4974f49 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -4008,6 +4008,8 @@ void alterang(int ang, DDukeActor* actor, int playernum) int j; int ticselapsed; + const auto p = getPlayer(playernum); + const auto pact = p->GetActor(); auto moveptr = &ScriptCode[actor->temp_data[1]]; ticselapsed = (actor->counter) & 31; @@ -4024,13 +4026,13 @@ void alterang(int ang, DDukeActor* actor, int playernum) actor->spr.Angles.Yaw = WindDir; else if (ang & seekplayer) { - DDukeActor* holoduke = !isRR()? getPlayer(playernum)->holoduke_on.Get() : nullptr; + DDukeActor* holoduke = !isRR()? p->holoduke_on.Get() : nullptr; // NOTE: looks like 'Owner' is set to target sprite ID... if (holoduke && cansee(holoduke->spr.pos, holoduke->sector(), actor->spr.pos, actor->sector())) actor->SetOwner(holoduke); - else actor->SetOwner(getPlayer(playernum)->GetActor()); + else actor->SetOwner(pact); auto Owner = actor->GetOwner(); if (Owner->isPlayer()) @@ -4068,7 +4070,7 @@ void alterang(int ang, DDukeActor* actor, int playernum) { goalang = furthestangle(actor, j); actor->spr.Angles.Yaw = goalang; - actor->SetOwner(getPlayer(playernum)->GetActor()); + actor->SetOwner(pact); } if (ang & fleeenemy)