]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix onground clearing by ANDing it with a downtrace by 1 unit - this does NOT cause...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 5 Dec 2009 20:14:22 +0000 (20:14 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 5 Dec 2009 20:14:22 +0000 (20:14 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9541 d7cf8633-e32d-0410-b094-e92efae38249

sv_phys.c

index de66811ac91633a402de1d5e6a774ad5d3dbc291..c8f73b83c0af92584afc1b67a64f7a68bfcbda40 100644 (file)
--- 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);