From b19c27fd82074c42e1aba5b9d293f70f90995d02 Mon Sep 17 00:00:00 2001 From: divverent Date: Sat, 5 Dec 2009 20:14:22 +0000 Subject: [PATCH] fix onground clearing by ANDing it with a downtrace by 1 unit - this does NOT cause any doublejump bugs, as it is just for CLEARING the onground flag, and fixes problems with short moves (high netfps) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9541 d7cf8633-e32d-0410-b094-e92efae38249 --- sv_phys.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/sv_phys.c b/sv_phys.c index de66811a..c8f73b83 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -2157,7 +2157,7 @@ Only used by players */ void SV_WalkMove (prvm_edict_t *ent) { - int clip, oldonground, originalmove_clip, originalmove_flags, originalmove_groundentity, hitsupercontentsmask; + int clip, oldonground, originalmove_clip, originalmove_flags, originalmove_groundentity, hitsupercontentsmask, type; vec3_t upmove, downmove, start_origin, start_velocity, stepnormal, originalmove_origin, originalmove_velocity; trace_t downtrace, trace; qboolean applygravity; @@ -2184,8 +2184,23 @@ void SV_WalkMove (prvm_edict_t *ent) clip = SV_FlyMove (ent, sv.frametime, applygravity, NULL, hitsupercontentsmask); // if the move did not hit the ground at any point, we're not on ground - if (!(clip & 1)) - ent->fields.server->flags = (int)ent->fields.server->flags & ~FL_ONGROUND; + if(!(clip & 1)) + // only try this if there was no floor in the way in the trace (no, + // this check seems to be not REALLY necessary, because if clip & 1, + // our trace will hit that thing too) + { + VectorSet(upmove, ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2] + 1); + VectorSet(downmove, ent->fields.server->origin[0], ent->fields.server->origin[1], ent->fields.server->origin[2] - 1); + if (ent->fields.server->movetype == MOVETYPE_FLYMISSILE) + type = MOVE_MISSILE; + else if (ent->fields.server->solid == SOLID_TRIGGER || ent->fields.server->solid == SOLID_NOT) + type = MOVE_NOMONSTERS; // only clip against bmodels + else + type = MOVE_NORMAL; + trace = SV_TraceBox(upmove, ent->fields.server->mins, ent->fields.server->maxs, downmove, type, ent, SV_GenericHitSuperContentsMask(ent)); + if(trace.fraction >= 1 || trace.plane.normal[2] <= 0.7) + ent->fields.server->flags = (int)ent->fields.server->flags & ~FL_ONGROUND; + } SV_CheckVelocity(ent); SV_LinkEdict(ent); -- 2.39.2