From ab99b6b29de34b197b225aa049692d1ccddbd7b5 Mon Sep 17 00:00:00 2001 From: Mitch Richters Date: Sat, 6 Nov 2021 13:31:21 +1100 Subject: [PATCH] - `PlayerHorizon::calcviewpitch()`: Make returning `horizoff` to 0 speed uniform across all games. --- source/core/gameinput.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index abf12f028..d35b4c1ab 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -450,6 +450,13 @@ void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const // //--------------------------------------------------------------------------- +/* +// Horizoff centre speed. +Duke: (1 / 8) * 30 = 3.75; +SW: (1 / 8) * 40 = 5; +Average: 4.375; +*/ + enum { // Values used by Duke/SW, where this function originated from. @@ -498,21 +505,14 @@ void PlayerHorizon::calcviewpitch(vec2_t const pos, binangle const ang, bool con { // tilt when climbing but you can't even really tell it. if (horizoff.asq16() < IntToFixed(100)) - horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * (((IntToFixed(100) - horizoff.asq16()) >> 3) + FRACUNIT))); + horizoff += buildfhoriz(scaleAdjust * (((100 - horizoff.asbuildf()) * (4.375 / GameTicRate)) + 1.)); } - else + else if (horizoff.asq16()) { // Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope. - if (horizoff.asq16() > 0) - { - horizoff += q16horiz(xs_CRoundToInt(-scaleAdjust * ((horizoff.asq16() >> 3) + FRACUNIT))); - if (horizoff.asq16() < 0) horizoff = q16horiz(0); - } - if (horizoff.asq16() < 0) - { - horizoff += q16horiz(xs_CRoundToInt(-scaleAdjust * ((horizoff.asq16() >> 3) - FRACUNIT))); - if (horizoff.asq16() > 0) horizoff = q16horiz(0); - } + auto sgn = Sgn(horizoff.asq16()); + horizoff -= buildfhoriz(scaleAdjust * ((horizoff.asbuildf() * (4.375 / GameTicRate)) + sgn)); + if (sgn != Sgn(horizoff.asq16())) horizoff = q16horiz(0); } } }