From 36fd510f2ca80fdfe7fd30b2a830d996f88cfe96 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 2 Oct 2023 20:44:21 +1100 Subject: [PATCH] - Duke: Clean up player/actor accesses in `handle_se24()`. --- source/games/duke/src/actors.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 103f5a7d1..4aca02368 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -3375,13 +3375,16 @@ void handle_se24(DDukeActor *actor, bool scroll, double mult) } } - for (auto p = connecthead; p >= 0; p = connectpoint2[p]) + for (auto i = connecthead; i >= 0; i = connectpoint2[i]) { - if (getPlayer(p)->cursector == actor->sector() && getPlayer(p)->on_ground) + const auto p = getPlayer(i); + const auto pact = p->GetActor(); + + if (p->cursector == actor->sector() && p->on_ground) { - if (abs(getPlayer(p)->GetActor()->getOffsetZ() - getPlayer(p)->truefz) < gs.playerheight + 9) + if (abs(pact->getOffsetZ() - p->truefz) < gs.playerheight + 9) { - getPlayer(p)->fric += vec * (1. / 8.); // keeping the original velocity. to match the animation it should be ~1/24. + p->fric += vec * (1. / 8.); // keeping the original velocity. to match the animation it should be ~1/24. } } }