]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Merge PR 'sv_gameplayfix_stepmultipletimes 1: Prevent players moving too far/fast...
authorbones_was_here <bones_was_here@xa.org.au>
Sun, 16 Jan 2022 20:54:53 +0000 (06:54 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Sun, 16 Jan 2022 20:54:53 +0000 (06:54 +1000)
After the player made some horizontal progress, and before stepping up, it's necessary to recalculate the remaining time and distance for the move. Previously the step up made the player travel (up to) nearly the move's full distance, again.

https://github.com/DarkPlacesEngine/darkplaces/pull/10

branch: bones_was_here/stepup_distance
commits: 365e221966b15c24c6e2f4cbb6e619b0db443ebf

Signed-off-by: bones_was_here <bones_was_here@xa.org.au>
1  2 
sv_phys.c

diff --combined sv_phys.c
index 2e61888d5bba7b669f56e7bf3dd20874e32a5291,1669e682c487590f003f7a5585ed32b01cd54808..f2b515935fd2fd7707da4327e2fb9c4af32c35d3
+++ b/sv_phys.c
@@@ -1255,6 -1255,9 +1255,9 @@@ static int SV_FlyMove (prvm_edict_t *en
  
                if (trace.fraction == 1)
                        break;
+               time_left *= 1 - trace.fraction;
                if (trace.plane.normal[2])
                {
                        if (trace.plane.normal[2] > 0.7)
                        trace_t steptrace3;
                        //Con_Printf("step %f %f %f : ", PRVM_serveredictvector(ent, origin)[0], PRVM_serveredictvector(ent, origin)[1], PRVM_serveredictvector(ent, origin)[2]);
                        VectorSet(steppush, 0, 0, stepheight);
+                       VectorScale(PRVM_serveredictvector(ent, velocity), time_left, push);
                        VectorCopy(PRVM_serveredictvector(ent, origin), org);
                        if(!SV_PushEntity(&steptrace, ent, steppush, false))
                        {
                        }
                        //Con_Printf("%f %f %f : ", PRVM_serveredictvector(ent, origin)[0], PRVM_serveredictvector(ent, origin)[1], PRVM_serveredictvector(ent, origin)[2]);
                        // accept the new position if it made some progress...
 -                      if (fabs(PRVM_serveredictvector(ent, origin)[0] - org[0]) >= 0.03125 || fabs(PRVM_serveredictvector(ent, origin)[1] - org[1]) >= 0.03125)
 +                      // previously this checked if absolute distance >= 0.03125 which made stepping up unreliable
 +                      if (PRVM_serveredictvector(ent, origin)[0] - org[0] || PRVM_serveredictvector(ent, origin)[1] - org[1])
                        {
                                //Con_Printf("accepted (delta %f %f %f)\n", PRVM_serveredictvector(ent, origin)[0] - org[0], PRVM_serveredictvector(ent, origin)[1] - org[1], PRVM_serveredictvector(ent, origin)[2] - org[2]);
                                trace = steptrace2;
                        numplanes = 0;
                }
  
-               time_left *= 1 - trace.fraction;
                // clipped to another plane
                if (numplanes >= MAX_CLIP_PLANES)
                {
@@@ -2351,11 -2352,7 +2353,11 @@@ static void SV_WalkMove (prvm_edict_t *
                VectorCopy(PRVM_serveredictvector(ent, maxs), entmaxs);
                trace = SV_TraceBox(upmove, entmins, entmaxs, downmove, type, ent, SV_GenericHitSuperContentsMask(ent), skipsupercontentsmask, skipmaterialflagsmask, collision_extendmovelength.value);
                if(trace.fraction < 1 && trace.plane.normal[2] > 0.7)
 +              {
                        clip |= 1; // but we HAVE found a floor
 +                      // set groundentity so we get carried when walking onto a mover with sv_gameplayfix_nogravityonground
 +                      PRVM_serveredictedict(ent, groundentity) = PRVM_EDICT_TO_PROG(trace.ent);
 +              }
        }
  
        // if the move did not hit the ground at any point, we're not on ground