From f43839ef8d938e3f05fdba72ca2e5929c14e45bb Mon Sep 17 00:00:00 2001
From: Eidolon <furyhunter600@gmail.com>
Date: Sat, 20 Aug 2022 13:42:34 -0500
Subject: [PATCH] uncapped: Reset cam interpolation on P_ResetCamera

---
 src/p_local.h |  1 +
 src/p_user.c  |  1 +
 src/r_main.c  | 19 +++++++++++++++++++
 3 files changed, 21 insertions(+)

diff --git a/src/p_local.h b/src/p_local.h
index 8a91891761..49af03f366 100644
--- a/src/p_local.h
+++ b/src/p_local.h
@@ -91,6 +91,7 @@ typedef struct camera_s
 	// Camera demobjerization
 	// Info for drawing: position.
 	fixed_t x, y, z;
+	boolean reset;
 
 	//More drawing info: to determine current sprite.
 	angle_t angle; // orientation
diff --git a/src/p_user.c b/src/p_user.c
index 444da6fea8..802c061553 100644
--- a/src/p_user.c
+++ b/src/p_user.c
@@ -9656,6 +9656,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
 	thiscam->x = x;
 	thiscam->y = y;
 	thiscam->z = z;
+	thiscam->reset = true;
 
 	if ((thiscam == &camera && G_ControlStyle(1) == CS_SIMPLE)
 	|| (thiscam == &camera2 && G_ControlStyle(2) == CS_SIMPLE))
diff --git a/src/r_main.c b/src/r_main.c
index b1ba150506..cd5e255ed4 100644
--- a/src/r_main.c
+++ b/src/r_main.c
@@ -1346,12 +1346,31 @@ void R_SkyboxFrame(player_t *player)
 
 boolean R_ViewpointHasChasecam(player_t *player)
 {
+	camera_t *thiscam;
 	boolean chasecam = false;
 
 	if (splitscreen && player == &players[secondarydisplayplayer] && player != &players[consoleplayer])
+	{
+		thiscam = &camera2;
 		chasecam = (cv_chasecam2.value != 0);
+		R_SetViewContext(VIEWCONTEXT_PLAYER2);
+		if (thiscam->reset)
+		{
+			R_ResetViewInterpolation(2);
+			thiscam->reset = false;
+		}
+	}
 	else
+	{
+		thiscam = &camera;
 		chasecam = (cv_chasecam.value != 0);
+		R_SetViewContext(VIEWCONTEXT_PLAYER1);
+		if (thiscam->reset)
+		{
+			R_ResetViewInterpolation(1);
+			thiscam->reset = false;
+		}
+	}
 
 	if (player->climbing || (player->powers[pw_carry] == CR_NIGHTSMODE) || player->playerstate == PST_DEAD || gamestate == GS_TITLESCREEN || tutorialmode)
 		chasecam = true; // force chasecam on
-- 
GitLab