From 2cadb08a5230c73be4599c7543fd02edfb350932 Mon Sep 17 00:00:00 2001
From: havoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Date: Fri, 4 Nov 2005 13:24:15 +0000
Subject: [PATCH] implemented sv_fixedframeratesingleplayer cvar

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5788 d7cf8633-e32d-0410-b094-e92efae38249
---
 cl_input.c | 2 --
 cl_main.c  | 2 +-
 cl_parse.c | 2 +-
 host.c     | 4 +++-
 server.h   | 3 +++
 sv_main.c  | 2 --
 6 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/cl_input.c b/cl_input.c
index 3c8a5140..6cd5315b 100644
--- a/cl_input.c
+++ b/cl_input.c
@@ -56,8 +56,6 @@ kbutton_t	in_button3, in_button4, in_button5, in_button6, in_button7, in_button8
 
 int			in_impulse;
 
-extern cvar_t sys_ticrate;
-
 
 void KeyDown (kbutton_t *b)
 {
diff --git a/cl_main.c b/cl_main.c
index ca17674c..4b0ab04f 100644
--- a/cl_main.c
+++ b/cl_main.c
@@ -426,7 +426,7 @@ static float CL_LerpPoint(void)
 
 	// LordHavoc: lerp in listen games as the server is being capped below the client (usually)
 	f = cl.mtime[0] - cl.mtime[1];
-	if (!f || cl_nolerp.integer || cls.timedemo || cl.islocalgame)
+	if (!f || cl_nolerp.integer || cls.timedemo || (cl.islocalgame && !sv_fixedframeratesingleplayer.integer))
 	{
 		cl.time = cl.mtime[0];
 		return 1;
diff --git a/cl_parse.c b/cl_parse.c
index 2ecbd6d7..a5aea072 100644
--- a/cl_parse.c
+++ b/cl_parse.c
@@ -574,7 +574,7 @@ void CL_MoveLerpEntityStates(entity_t *ent)
 		// not a monster
 		ent->persistent.lerpstarttime = ent->state_previous.time;
 		// no lerp if it's singleplayer
-		if (cl.islocalgame)
+		if (cl.islocalgame && !sv_fixedframeratesingleplayer.integer)
 			ent->persistent.lerpdeltatime = 0;
 		else
 			ent->persistent.lerpdeltatime = bound(0, ent->state_current.time - ent->state_previous.time, 0.1);
diff --git a/host.c b/host.c
index ae8f61be..67ee4c16 100644
--- a/host.c
+++ b/host.c
@@ -71,6 +71,7 @@ cvar_t cl_maxfps = {CVAR_SAVE, "cl_maxfps", "1000"};
 cvar_t sv_echobprint = {CVAR_SAVE, "sv_echobprint", "1"};
 
 cvar_t sys_ticrate = {CVAR_SAVE, "sys_ticrate","0.05"};
+cvar_t sv_fixedframeratesingleplayer = {0, "sv_fixedframeratesingleplayer", "0"};
 cvar_t serverprofile = {0, "serverprofile","0"};
 
 cvar_t fraglimit = {CVAR_NOTIFY, "fraglimit","0"};
@@ -225,6 +226,7 @@ void Host_InitLocal (void)
 	Cvar_RegisterVariable (&sv_echobprint);
 
 	Cvar_RegisterVariable (&sys_ticrate);
+	Cvar_RegisterVariable (&sv_fixedframeratesingleplayer);
 	Cvar_RegisterVariable (&serverprofile);
 
 	Cvar_RegisterVariable (&fraglimit);
@@ -670,7 +672,7 @@ void Host_ServerFrame (void)
 		// setup the VM frame
 		SV_VM_Begin();
 
-		if (cl.islocalgame)
+		if (cl.islocalgame && !sv_fixedframeratesingleplayer.integer)
 			advancetime = min(sv.timer, sys_ticrate.value);
 		else
 			advancetime = sys_ticrate.value;
diff --git a/server.h b/server.h
index bbe93156..f71a1f14 100644
--- a/server.h
+++ b/server.h
@@ -276,6 +276,9 @@ extern cvar_t sv_gameplayfix_setmodelrealbox;
 extern cvar_t sv_gameplayfix_blowupfallenzombies;
 extern cvar_t sv_gameplayfix_findradiusdistancetobox;
 
+extern cvar_t sys_ticrate;
+extern cvar_t sv_fixedframeratesingleplayer;
+
 extern mempool_t *sv_mempool;
 
 // persistant server info
diff --git a/sv_main.c b/sv_main.c
index 7afb4cb5..99ece146 100644
--- a/sv_main.c
+++ b/sv_main.c
@@ -34,8 +34,6 @@ static cvar_t sv_cullentities_trace = {0, "sv_cullentities_trace", "0"}; // tend
 static cvar_t sv_cullentities_stats = {0, "sv_cullentities_stats", "0"};
 static cvar_t sv_entpatch = {0, "sv_entpatch", "1"};
 
-extern cvar_t sys_ticrate;
-
 cvar_t sv_gameplayfix_grenadebouncedownslopes = {0, "sv_gameplayfix_grenadebouncedownslopes", "1"};
 cvar_t sv_gameplayfix_noairborncorpse = {0, "sv_gameplayfix_noairborncorpse", "1"};
 cvar_t sv_gameplayfix_stepdown = {0, "sv_gameplayfix_stepdown", "1"};
-- 
2.39.5