From 5cd29820d10891f8592714c0c62a624f5797b964 Mon Sep 17 00:00:00 2001
From: havoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Date: Sun, 7 Jul 2013 06:42:11 +0000
Subject: [PATCH] fix a serious issue with CSQC frametime being non-zero on
 both calls when using stereo rendering, it is now zero on the second eye so
 that frametime does not lie

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11964 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=b941207315be4d71624526b275cb98e261617457
---
 cl_screen.c | 2 +-
 csprogs.c   | 8 ++++----
 render.h    | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/cl_screen.c b/cl_screen.c
index fd73d8d5..640cc090 100644
--- a/cl_screen.c
+++ b/cl_screen.c
@@ -2149,7 +2149,7 @@ static void SCR_DrawScreen (void)
 		r_refdef.view.ortho_x = atan(r_refdef.view.frustum_x) * (360.0 / M_PI); // abused as angle by VM_CL_R_SetView
 		r_refdef.view.ortho_y = atan(r_refdef.view.frustum_y) * (360.0 / M_PI); // abused as angle by VM_CL_R_SetView
 
-		if(!CL_VM_UpdateView())
+		if(!CL_VM_UpdateView(r_stereo_side ? 0.0 : max(0.0, cl.time - cl.oldtime)))
 			R_RenderView();
 	}
 
diff --git a/csprogs.c b/csprogs.c
index 9051caef..36cecf83 100644
--- a/csprogs.c
+++ b/csprogs.c
@@ -221,13 +221,13 @@ void CSQC_UpdateNetworkTimes(double newtime, double oldtime)
 }
 
 //[515]: set globals before calling R_UpdateView, WEIRD CRAP
-static void CSQC_SetGlobals (void)
+static void CSQC_SetGlobals (double frametime)
 {
 	vec3_t pmove_org;
 	prvm_prog_t *prog = CLVM_prog;
 	CSQC_BEGIN
 		PRVM_clientglobalfloat(time) = cl.time;
-		PRVM_clientglobalfloat(frametime) = max(0, cl.time - cl.oldtime);
+		PRVM_clientglobalfloat(frametime) = frametime;
 		PRVM_clientglobalfloat(servercommandframe) = cls.servermovesequence;
 		PRVM_clientglobalfloat(clientcommandframe) = cl.movecmd[0].sequence;
 		VectorCopy(cl.viewangles, PRVM_clientglobalvector(input_angles));
@@ -460,7 +460,7 @@ qboolean CL_VM_InputEvent (int eventtype, int x, int y)
 
 extern r_refdef_view_t csqc_original_r_refdef_view;
 extern r_refdef_view_t csqc_main_r_refdef_view;
-qboolean CL_VM_UpdateView (void)
+qboolean CL_VM_UpdateView (double frametime)
 {
 	prvm_prog_t *prog = CLVM_prog;
 	vec3_t emptyvector;
@@ -478,7 +478,7 @@ qboolean CL_VM_UpdateView (void)
 		//VectorCopy(cl.viewangles, oldangles);
 		PRVM_clientglobalfloat(time) = cl.time;
 		PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
-		CSQC_SetGlobals();
+		CSQC_SetGlobals(frametime);
 		// clear renderable entity and light lists to prevent crashes if the
 		// CSQC_UpdateView function does not call R_ClearScene as it should
 		r_refdef.scene.numentities = 0;
diff --git a/render.h b/render.h
index d30f1f41..090e92bc 100644
--- a/render.h
+++ b/render.h
@@ -607,7 +607,7 @@ void R_Model_Sprite_Draw(entity_render_t *ent);
 
 struct prvm_prog_s;
 void R_UpdateFog(void);
-qboolean CL_VM_UpdateView(void);
+qboolean CL_VM_UpdateView(double frametime);
 void SCR_DrawConsole(void);
 void R_Shadow_EditLights_DrawSelectedLightProperties(void);
 void R_DecalSystem_Reset(decalsystem_t *decalsystem);
-- 
2.39.5