From e0d05dbd51165e261e3fa1cdbaf9578969346a8e Mon Sep 17 00:00:00 2001 From: divverent Date: Sun, 26 Jun 2011 19:07:03 +0000 Subject: [PATCH] funny feature: cl_lerpexcess Hides the effect of packet loss for linear motion. Mispredicts nonlinear motion, of course. Can be configured to a max number of server packets lost that it will try to compensate for. Of course off by default. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11218 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=1a606ca4c462e8a9a76cd5e7e085efbecbe90009 --- cl_main.c | 6 ++++-- cl_parse.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/cl_main.c b/cl_main.c index 00e88da6..ab7ec1b3 100644 --- a/cl_main.c +++ b/cl_main.c @@ -38,6 +38,7 @@ cvar_t csqc_progsize = {CVAR_READONLY, "csqc_progsize","-1","file size of csprog cvar_t cl_shownet = {0, "cl_shownet","0","1 = print packet size, 2 = print packet message list"}; cvar_t cl_nolerp = {0, "cl_nolerp", "0","network update smoothing"}; +cvar_t cl_lerpexcess = {0, "cl_lerpexcess", "0","maximum allowed lerp excess (hides, not fixes, some packet loss)"}; cvar_t cl_lerpanim_maxdelta_server = {0, "cl_lerpanim_maxdelta_server", "0.1","maximum frame delta for smoothing between server-controlled animation frames (when 0, one network frame)"}; cvar_t cl_lerpanim_maxdelta_framegroups = {0, "cl_lerpanim_maxdelta_framegroups", "0.1","maximum frame delta for smoothing between framegroups (when 0, one network frame)"}; @@ -628,7 +629,7 @@ static float CL_LerpPoint(void) } f = (cl.time - cl.mtime[1]) / (cl.mtime[0] - cl.mtime[1]); - return bound(0, f, 1); + return bound(0, f, 1 + cl_lerpexcess.value); } void CL_ClearTempEntities (void) @@ -1034,7 +1035,7 @@ void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit, qboolean interpolat VectorCopy(cl.movement_origin, origin); VectorSet(angles, 0, cl.viewangles[1], 0); } - else if (interpolate && e->persistent.lerpdeltatime > 0 && (lerp = (cl.time - e->persistent.lerpstarttime) / e->persistent.lerpdeltatime) < 1) + else if (interpolate && e->persistent.lerpdeltatime > 0 && (lerp = (cl.time - e->persistent.lerpstarttime) / e->persistent.lerpdeltatime) < 1 + cl_lerpexcess.value) { // interpolate the origin and angles lerp = max(0, lerp); @@ -2415,6 +2416,7 @@ void CL_Init (void) Cvar_RegisterVariable (&cl_anglespeedkey); Cvar_RegisterVariable (&cl_shownet); Cvar_RegisterVariable (&cl_nolerp); + Cvar_RegisterVariable (&cl_lerpexcess); Cvar_RegisterVariable (&cl_lerpanim_maxdelta_server); Cvar_RegisterVariable (&cl_lerpanim_maxdelta_framegroups); Cvar_RegisterVariable (&cl_deathfade); diff --git a/cl_parse.c b/cl_parse.c index 1f229fd6..ca4bec30 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -3202,6 +3202,7 @@ qboolean CL_ExaminePrintString(const char *text) } extern cvar_t slowmo; +extern cvar_t cl_lerpexcess; extern void CSQC_UpdateNetworkTimes(double newtime, double oldtime); static void CL_NetworkTimeReceived(double newtime) { @@ -3285,6 +3286,20 @@ static void CL_NetworkTimeReceived(double newtime) if (cl.mtime[0] > cl.mtime[1]) World_Physics_Frame(&cl.world, cl.mtime[0] - cl.mtime[1], cl.movevars_gravity); + + // only lerp entities that also get an update in this frame, when lerp excess is used + if(cl_lerpexcess.value > 0) + { + int i; + for (i = 1;i < cl.num_entities;i++) + { + if (cl.entities_active[i]) + { + entity_t *ent = cl.entities + i; + ent->persistent.lerpdeltatime = 0; + } + } + } } #define SHOWNET(x) if(cl_shownet.integer==2)Con_Printf("%3i:%s(%i)\n", msg_readcount-1, x, cmd); -- 2.39.2