diff --git a/engine/server/server.h b/engine/server/server.h index bdd516d41..a32de8218 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -399,8 +399,9 @@ typedef struct client_s double connection_started; // or time of disconnect for zombies qboolean send_message; // set on frames a datagram arived on - laggedentinfo_t laggedents[MAX_CLIENTS]; - unsigned int laggedents_count; + laggedentinfo_t laggedents[MAX_CLIENTS]; + unsigned int laggedents_count; + float laggedents_frac; // spawn parms are carried from level to level float spawn_parms[NUM_SPAWN_PARMS]; @@ -895,6 +896,7 @@ typedef enum multicast_e extern cvar_t sv_mintic, sv_maxtic; extern cvar_t sv_maxspeed; extern cvar_t sv_antilag; +extern cvar_t sv_antilag_frac; extern netadr_t master_adr[MAX_MASTERS]; // address of the master server diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index 51d28b7f5..1705d7679 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -45,6 +45,7 @@ cvar_t sv_spectalk = SCVAR("sv_spectalk", "1"); cvar_t sv_mapcheck = SCVAR("sv_mapcheck", "1"); cvar_t sv_antilag = SCVARF("sv_antilag", "0", CVAR_SERVERINFO); +cvar_t sv_antilag_frac = SCVARF("sv_antilag_frac", "1", CVAR_SERVERINFO); cvar_t sv_cheatpc = SCVAR("sv_cheatpc", "125"); cvar_t sv_cheatspeedchecktime = SCVAR("sv_cheatspeedchecktime", "30"); cvar_t sv_playermodelchecks = SCVAR("sv_playermodelchecks", "1"); @@ -5542,6 +5543,8 @@ void SV_ExecuteClientMessage (client_t *cl) VectorCopy(frame->playerpositions[i], cl->laggedents[i].laggedpos); } cl->laggedents_count = sv.allocated_client_slots; + + cl->laggedents_frac = sv_antilag_frac.value; } else cl->laggedents_count = 0; @@ -6175,6 +6178,7 @@ void SV_UserInit (void) Cvar_Register (&sv_mapcheck, cvargroup_servercontrol); Cvar_Register (&sv_antilag, cvargroup_servercontrol); + Cvar_Register (&sv_antilag_frac, cvargroup_servercontrol); Cvar_Register (&sv_cheatpc, cvargroup_servercontrol); Cvar_Register (&sv_cheatspeedchecktime, cvargroup_servercontrol); Cvar_Register (&sv_playermodelchecks, cvargroup_servercontrol); diff --git a/engine/server/world.c b/engine/server/world.c index e448f052a..ffc915a0e 100644 --- a/engine/server/world.c +++ b/engine/server/world.c @@ -1865,6 +1865,7 @@ trace_t World_Move (world_t *w, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t e clip.type |= MOVE_LAGGED; w->lagents = svs.clients[passedict->entnum-1].laggedents; w->maxlagents = svs.clients[passedict->entnum-1].laggedents_count; + w->lagentsfrac = svs.clients[passedict->entnum-1].laggedents_frac; } else if (passedict->v->owner) { @@ -1873,6 +1874,7 @@ trace_t World_Move (world_t *w, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t e clip.type |= MOVE_LAGGED; w->lagents = svs.clients[passedict->v->owner-1].laggedents; w->maxlagents = svs.clients[passedict->v->owner-1].laggedents_count; + w->lagentsfrac = svs.clients[passedict->v->owner-1].laggedents_frac; } } } @@ -1880,6 +1882,7 @@ trace_t World_Move (world_t *w, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t e { trace_t trace; wedict_t *touch; + vec3_t lp; World_ClipToLinks (w, w->areanodes, &clip ); @@ -1914,12 +1917,14 @@ trace_t World_Move (world_t *w, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t e continue; } - if (clip.boxmins[0] > touch->v->absmax[0] - || clip.boxmins[1] > touch->v->absmax[1] - || clip.boxmins[2] > touch->v->absmax[2] - || clip.boxmaxs[0] < touch->v->absmin[0] - || clip.boxmaxs[1] < touch->v->absmin[1] - || clip.boxmaxs[2] < touch->v->absmin[2] ) + VectorInterpolate(touch->v->origin, w->lagentsfrac, w->lagents[i].laggedpos, lp); + + if (clip.boxmins[0] > lp[0]+touch->v->maxs[0] + || clip.boxmins[1] > lp[1]+touch->v->maxs[1] + || clip.boxmins[2] > lp[2]+touch->v->maxs[2] + || clip.boxmaxs[0] < lp[0]+touch->v->mins[0] + || clip.boxmaxs[1] < lp[1]+touch->v->mins[1] + || clip.boxmaxs[2] < lp[2]+touch->v->mins[2] ) continue; if (clip.passedict && clip.passedict->v->size[0] && !touch->v->size[0]) @@ -1933,7 +1938,7 @@ trace_t World_Move (world_t *w, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t e continue; // don't clip against owner } - trace = World_ClipMoveToEntity (w, touch, w->lagents[i].laggedpos, clip.start, clip.mins, clip.maxs, clip.end, clip.hullnum, clip.type & MOVE_HITMODEL); + trace = World_ClipMoveToEntity (w, touch, lp, clip.start, clip.mins, clip.maxs, clip.end, clip.hullnum, clip.type & MOVE_HITMODEL); if (trace.allsolid || trace.startsolid || trace.fraction < clip.trace.fraction) {