From 3df0d40312477156c5dc515f2643ae1c71d19bf1 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 10 Sep 2020 20:26:19 +1000 Subject: [PATCH] - SW: Fix stupid issue with `playerSetAngle()` and tweak how `angTarget`/`horizTarget` is determined to have been met. --- source/sw/src/input.cpp | 4 ++-- source/sw/src/player.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index e2b09d8f7..c3fb1bb47 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -289,7 +289,7 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool fixed_t horizDelta = pp->horizTarget - pp->q16horiz; pp->q16horiz += xs_CRoundToInt(scaleAdjust * horizDelta); - if (abs(pp->q16horiz) >= abs(horizDelta)) + if (abs(pp->q16horiz - pp->horizTarget) < FRACUNIT) { pp->q16horiz = pp->horizTarget; pp->horizTarget = 0; @@ -310,7 +310,7 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool fixed_t angDelta = GetDeltaQ16Angle(pp->angTarget, pp->q16ang); pp->q16ang = (pp->q16ang + xs_CRoundToInt(scaleAdjust * angDelta)); - if (pp->q16ang >= pp->angTarget) + if (abs(pp->q16ang - pp->angTarget) < FRACUNIT) { pp->q16ang = pp->angTarget; pp->angTarget = 0; diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 297967f07..52e429a0d 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -7817,7 +7817,7 @@ void playerSetAngle(PLAYERp pp, double ang) ang += 0.1; } - pp->angTarget = pp->q16ang + GetDeltaQ16Angle(ang, pp->q16ang); + pp->angTarget = pp->q16ang + GetDeltaQ16Angle(FloatToFixed(ang), pp->q16ang); } else {