From 0da2afe3d799e4fa2b5ede88c1698d39ebfe8056 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 26 Mar 2023 13:34:58 +1100 Subject: [PATCH] - Duke: Tidy up some of the pitch stuff. * Remove some extern'd CVARs that didn't need externing. * Change `player_struct::centeringView()` bool into proper method to handle the operation. * Operation now properly unsets `SB_CENTERVIEW` if conditions aren't met instead of relying on implied behaviour from the rest of the playsim. --- source/core/gamecvars.h | 4 ---- source/games/duke/src/player_d.cpp | 6 +----- source/games/duke/src/player_r.cpp | 6 +----- source/games/duke/src/types.h | 21 ++++++++++++++++----- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/source/core/gamecvars.h b/source/core/gamecvars.h index eb936a810..02a14d3f0 100644 --- a/source/core/gamecvars.h +++ b/source/core/gamecvars.h @@ -43,11 +43,7 @@ EXTERN_CVAR(Bool, cl_bloodweapinterp) EXTERN_CVAR(Bool, cl_bloodoldweapbalance) EXTERN_CVAR(Bool, cl_loadingscreens) EXTERN_CVAR(Bool, cl_clampedpitch) - EXTERN_CVAR(Int, cl_dukepitchmode) -EXTERN_CVAR(Flag, cl_dukepitchlockreturn) -EXTERN_CVAR(Flag, cl_dukepitchnohardlanding) -EXTERN_CVAR(Flag, cl_dukepitchnolandingcenter) EXTERN_CVAR(Bool, demorec_seeds_cvar) EXTERN_CVAR(Bool, demoplay_diffs) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index e485166a4..8d112e3ec 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2730,11 +2730,7 @@ void processinput_d(int snum) checklook(snum,actions); p->Angles.doViewYaw(&p->sync); - if (p->centeringView()) - { - p->sync.horz = 0; - setForcedSyncInput(snum); - } + p->updatecentering(snum); if (p->on_crane != nullptr) { diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 99d77df06..b275eb05f 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3318,11 +3318,7 @@ void processinput_r(int snum) p->Angles.doViewYaw(&p->sync); p->apply_seasick(); - if (p->centeringView()) - { - p->sync.horz = 0; - setForcedSyncInput(snum); - } + p->updatecentering(snum); if (p->on_crane != nullptr) { diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 1479f5974..b51124d4c 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -345,12 +345,23 @@ struct player_struct bobpos = GetActor()->spr.pos.XY(); } - bool centeringView() + void updatecentering(const int snum) { - const bool centering = sync.actions & SB_CENTERVIEW; - const bool lockedret = cl_dukepitchmode & kDukePitchLockReturn; - const bool rangetest = abs(GetActor()->spr.Angles.Pitch.Degrees()) > 2.2370; - return centering && lockedret && rangetest; + if (!(sync.actions & SB_CENTERVIEW)) + return; + + const bool returnlock = cl_dukepitchmode & kDukePitchLockReturn; + const bool centertest = abs(GetActor()->spr.Angles.Pitch.Degrees()) > 2.2370; + + if ((centertest && returnlock) || !sync.horz) + { + setForcedSyncInput(snum); + sync.horz = 0; + } + else + { + sync.actions &= ~SB_CENTERVIEW; + } } };