From ff0ad086afd86d040fe8da2cbca6bfb03282b455 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Fri, 2 Apr 2021 00:29:12 +1100 Subject: [PATCH] - Slight cleanup within `PlayerAngle` and `PlayerHorizon` structs following 39fe9efaffc6652993fe2a4708ced8d770d2122a and bf2d8078a4418eed5386faf904ca075d2af587d5. --- source/core/gameinput.h | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/source/core/gameinput.h b/source/core/gameinput.h index 652cac32624..1614c3b5483 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -49,7 +49,7 @@ struct PlayerHorizon if (!SyncInput() && !backup) { target = buildhoriz(value); - if (target.asq16() == 0) target = q16horiz(1); + if (!target.asq16()) target = q16horiz(1); } else { @@ -63,7 +63,7 @@ struct PlayerHorizon if (!SyncInput() && !backup) { target = buildfhoriz(value); - if (target.asq16() == 0) target = q16horiz(1); + if (!target.asq16()) target = q16horiz(1); } else { @@ -77,7 +77,7 @@ struct PlayerHorizon if (!SyncInput() && !backup) { target = value; - if (target.asq16() == 0) target = q16horiz(1); + if (!target.asq16()) target = q16horiz(1); } else { @@ -90,9 +90,13 @@ struct PlayerHorizon { if (target.asq16()) { - horiz += q16horiz(xs_CRoundToInt(scaleAdjust * (target - horiz).asq16())); + auto delta = (target - horiz).asq16(); - if (abs((horiz - target).asq16()) < FRACUNIT) + if (abs(delta) > FRACUNIT) + { + horiz += q16horiz(xs_CRoundToInt(scaleAdjust * delta)); + } + else { horiz = target; target = q16horiz(0); @@ -201,7 +205,7 @@ struct PlayerAngle if (!SyncInput() && !backup) { target = buildang(value & 2047); - if (target.asbam() == 0) target = bamang(1); + if (!target.asbam()) target = bamang(1); } else { @@ -215,7 +219,7 @@ struct PlayerAngle if (!SyncInput() && !backup) { target = buildfang(fmod(value, 2048)); - if (target.asbam() == 0) target = bamang(1); + if (!target.asbam()) target = bamang(1); } else { @@ -229,7 +233,7 @@ struct PlayerAngle if (!SyncInput() && !backup) { target = value; - if (target.asbam() == 0) target = bamang(1); + if (!target.asbam()) target = bamang(1); } else { @@ -242,9 +246,13 @@ struct PlayerAngle { if (target.asbam()) { - ang += bamang(xs_CRoundToUInt(scaleAdjust * getincanglebam(ang, target).asbam())); + auto delta = getincanglebam(ang, target).asbam(); - if (getincanglebam(ang, target).asbam() < BAMUNIT) + if (delta > BAMUNIT) + { + ang += bamang(xs_CRoundToUInt(scaleAdjust * delta)); + } + else { ang = target; target = bamang(0);