From 44be58184b34598ecc5d38e01abe40a398632a14 Mon Sep 17 00:00:00 2001
From: Mitchell Richters <mjr4077au@gmail.com>
Date: Sun, 5 Nov 2023 17:37:58 +1100
Subject: [PATCH] - Repair issue where opening the menu cancels player's pitch
 returning to centre.

---
 source/core/coreplayer.h  | 6 +-----
 source/core/gameinput.cpp | 3 ++-
 source/core/mainloop.cpp  | 1 -
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/source/core/coreplayer.h b/source/core/coreplayer.h
index d9385409c..8ffe91443 100644
--- a/source/core/coreplayer.h
+++ b/source/core/coreplayer.h
@@ -98,6 +98,7 @@ public:
 		const auto viewAngles = interpolatedvalue(PrevViewAngles, ViewAngles, interpfrac);
 		return std::make_pair(DVector2(160, 120 * -viewAngles.Roll.Tan()) * -viewAngles.Yaw.Tan() / tan(r_fov * pi::pi() / 360.), viewAngles.Roll);
 	}
+
 	auto getWeaponOffsets(const double interpfrac)
 	{
 		// Push the Y down a bit since the weapon is at the edge of the screen. Also null roll for now.
@@ -108,11 +109,6 @@ public:
 
 extern DCorePlayer* PlayerArray[MAXPLAYERS];
 
-inline ESyncBits GetPersistentActions()
-{
-	return PlayerArray[myconnectindex]->cmd.ucmd.actions & SB_CENTERVIEW;
-}
-
 inline double getTicrateScale(const double value)
 {
 	return value / GameTicRate;
diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp
index fb2cb9b9b..116faaf62 100644
--- a/source/core/gameinput.cpp
+++ b/source/core/gameinput.cpp
@@ -249,7 +249,7 @@ void GameInput::processInputBits()
 	else dpad_lock = 0;
 
 	const auto crouchState = gi->getCrouchState();
-	inputBuffer.actions |= ActionsToSend | GetPersistentActions();
+	inputBuffer.actions |= ActionsToSend;
 	ActionsToSend = 0;
 
 	if (buttonMap.ButtonDown(gamefunc_Aim_Up) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && joyAxes[JOYAXIS_Forward] > 0)) 
@@ -327,6 +327,7 @@ void GameInput::processInputBits()
 void GameInput::getInput(InputPacket* packet)
 {
 	I_GetEvent();
+	SendAction(PlayerArray[myconnectindex]->cmd.ucmd.actions & SB_CENTERVIEW);
 
 	if (paused || M_Active() || gamestate != GS_LEVEL)
 	{
diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp
index 0e02a7e1b..8c2d6b95f 100644
--- a/source/core/mainloop.cpp
+++ b/source/core/mainloop.cpp
@@ -274,7 +274,6 @@ static void GameTicker()
 			Net_ClearFifo();
 			inputState.ClearAllInput();
 			gameInput.Clear();
-			gameInput.SendAction(GetPersistentActions());
 			gamestate = GS_LEVEL;
 			return;