From 5984fda8a1c5739e205abb02544d60468e65a81a Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 5 Apr 2021 21:41:11 +1000 Subject: [PATCH] - PlayerAngle: Repair issues with `addadjustment()` method following changes in 4ffe0044832410f8c8650001f344abe1cc637cec that were affecting negative input. --- source/core/binaryangle.h | 4 +++- source/core/gameinput.h | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index bec19e891..3cdc8dc49 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -122,6 +122,7 @@ class lookangle friend constexpr lookangle bamlook(int32_t v); friend constexpr lookangle q16look(int32_t v); friend constexpr lookangle buildlook(int32_t v); + friend lookangle buildflook(double v); friend lookangle radlook(double v); friend lookangle deglook(double v); @@ -224,7 +225,8 @@ public: inline constexpr lookangle bamlook(int32_t v) { return lookangle(v); } inline constexpr lookangle q16look(int32_t v) { return lookangle(v << 5); } inline constexpr lookangle buildlook(int32_t v) { return lookangle(v << BAMBITS); } -inline lookangle radlook(double v) { return lookangle(xs_CRoundToUInt(v * (0x80000000u / pi::pi()))); } +inline lookangle buildflook(double v) { return lookangle(xs_CRoundToInt(v * BAMUNIT)); } +inline lookangle radlook(double v) { return lookangle(xs_CRoundToInt(v * (0x80000000u / pi::pi()))); } inline lookangle deglook(double v) { return lookangle(FloatToAngle(v)); } inline FSerializer &Serialize(FSerializer &arc, const char *key, lookangle &obj, lookangle *defval) diff --git a/source/core/gameinput.h b/source/core/gameinput.h index 2fdc94b9a..39f9a12ff 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -149,22 +149,22 @@ struct PlayerAngle void addadjustment(int value) { - __addadjustment(buildang(value)); + __addadjustment(buildlook(value)); } void addadjustment(double value) { - __addadjustment(buildfang(value)); + __addadjustment(buildflook(value)); } void addadjustment(lookangle value) { - __addadjustment(bamang(value.asbam())); + __addadjustment(value); } void addadjustment(binangle value) { - __addadjustment(value); + __addadjustment(bamlook(value.asbam())); } void resetadjustment() @@ -254,7 +254,7 @@ private: binangle target; double adjustment; - void __addadjustment(binangle value) + void __addadjustment(lookangle value) { if (!SyncInput()) {