From: havoc Date: Wed, 15 Feb 2006 03:14:42 +0000 (+0000) Subject: changed client input packets to be sent at a fixed 50fps (configurable by cvar) rathe... X-Git-Tag: xonotic-v0.1.0preview~4326 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0dd9156548a265ffaa349488bce0a5838500de67;p=xonotic%2Fdarkplaces.git changed client input packets to be sent at a fixed 50fps (configurable by cvar) rather than in response to each server packet git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5985 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_input.c b/cl_input.c index de203112..786e8698 100644 --- a/cl_input.c +++ b/cl_input.c @@ -287,6 +287,8 @@ cvar_t in_pitch_max = {0, "in_pitch_max", "90", "how far upward you can aim (qua cvar_t m_filter = {CVAR_SAVE, "m_filter","0", "smoothes mouse movement, less responsive but smoother aiming"}; +cvar_t cl_netinputpacketspersecond = {CVAR_SAVE, "cl_netinputpacketspersecond","50", "how many input packets to send to server each second"}; + /* ================ @@ -799,12 +801,14 @@ void CL_ClientMovement_Replay(void) CL_SendMove ============== */ +extern cvar_t cl_netinputpacketspersecond; void CL_SendMove(void) { int i; int bits; sizebuf_t buf; unsigned char data[128]; + static double lastsendtime = 0; #define MOVEAVERAGING 0 #if MOVEAVERAGING static float forwardmove, sidemove, upmove, total; // accumulation @@ -821,6 +825,11 @@ void CL_SendMove(void) #endif if (cls.signon != SIGNONS) return; + if (realtime < lastsendtime + 1.0 / bound(10, cl_netinputpacketspersecond.value, 100)) + return; + // don't let it fall behind if CL_SendMove hasn't been called recently + // (such is the case when framerate is too low for instance) + lastsendtime = max(lastsendtime + 1.0 / bound(10, cl_netinputpacketspersecond.value, 100), realtime); #if MOVEAVERAGING // average the accumulated changes total = 1.0f / total; @@ -1104,5 +1113,7 @@ void CL_InitInput (void) Cvar_RegisterVariable(&in_pitch_min); Cvar_RegisterVariable(&in_pitch_max); Cvar_RegisterVariable(&m_filter); + + Cvar_RegisterVariable(&cl_netinputpacketspersecond); } diff --git a/cl_main.c b/cl_main.c index 8c2cda21..f32a2281 100644 --- a/cl_main.c +++ b/cl_main.c @@ -1548,6 +1548,9 @@ void CL_SendCmd(void) Host_Error("CL_WriteToServer: lost server connection"); SZ_Clear(&cls.netcon->message); } + + // send a move periodically + CL_SendMove(); } // LordHavoc: pausedemo command diff --git a/cl_parse.c b/cl_parse.c index 78f2589a..063d6bb5 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -1365,7 +1365,6 @@ void CL_ParseServerMessage(void) unsigned char cmdlog[32]; char *cmdlogname[32], *temp; int cmdindex, cmdcount = 0; - qboolean sendmove = false; if (cls.demorecording) CL_WriteDemoMessage (); @@ -1466,7 +1465,6 @@ void CL_ParseServerMessage(void) case svc_time: cl.mtime[1] = cl.mtime[0]; cl.mtime[0] = MSG_ReadFloat (); - sendmove = true; break; case svc_clientdata: @@ -1792,12 +1790,6 @@ void CL_ParseServerMessage(void) EntityFrameQuake_ISeeDeadEntities(); - if (sendmove) - { - // send one move per server frame - CL_SendMove(); - } - parsingerror = false; }