]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - phys.c
Remove a bit of cruft left in Cvar_RestoreInitState()
[xonotic/darkplaces.git] / phys.c
diff --git a/phys.c b/phys.c
index 6bad2bbc032504e77556b8432f4b0998bf7d9ce4..04c5449d2a216131268dd9530ff4e5233a5a0af8 100644 (file)
--- a/phys.c
+++ b/phys.c
@@ -6,13 +6,12 @@
 #include "cl_collision.h"
 
 
-qbool PHYS_NudgeOutOfSolid(prvm_prog_t *prog, prvm_edict_t *ent)
+int PHYS_NudgeOutOfSolid(prvm_prog_t *prog, prvm_edict_t *ent)
 {
        int bump, pass;
        trace_t stucktrace;
        vec3_t stuckorigin;
        vec3_t stuckmins, stuckmaxs;
-       vec_t nudge;
        vec_t separation;
        model_t *worldmodel;
 
@@ -27,7 +26,7 @@ qbool PHYS_NudgeOutOfSolid(prvm_prog_t *prog, prvm_edict_t *ent)
                separation = cl_gameplayfix_nudgeoutofsolid_separation.value;
        }
        else
-               Sys_Error("PHYS_NudgeOutOfSolid: cannot be called from %s VM\n", prog->name);
+               Sys_Abort("PHYS_NudgeOutOfSolid: cannot be called from %s VM\n", prog->name);
 
        VectorCopy(PRVM_serveredictvector(ent, mins), stuckmins);
        VectorCopy(PRVM_serveredictvector(ent, maxs), stuckmaxs);
@@ -55,15 +54,18 @@ qbool PHYS_NudgeOutOfSolid(prvm_prog_t *prog, prvm_edict_t *ent)
                        else
                                stucktrace = CL_TraceBox(stuckorigin, stuckmins, stuckmaxs, stuckorigin, pass ? MOVE_WORLDONLY : MOVE_NOMONSTERS, ent, SV_GenericHitSuperContentsMask(ent), 0, 0, collision_extendmovelength.value, pass ? false : true, false, NULL, false);
 
-                       if (!stucktrace.bmodelstartsolid || stucktrace.startdepth >= 0)
+                       // Separation compared here to ensure a good location will be recognised reliably.
+                       if (-stucktrace.startdepth <= separation
+                       || (!stucktrace.bmodelstartsolid && !stucktrace.worldstartsolid)
+                       || (pass && !stucktrace.worldstartsolid))
                        {
                                // found a good location, use it
                                VectorCopy(stuckorigin, PRVM_serveredictvector(ent, origin));
-                               return true;
+                               return bump || pass ? 1 : -1; // -1 means it wasn't stuck
                        }
-                       nudge = -stucktrace.startdepth;
-                       VectorMA(stuckorigin, nudge, stucktrace.startdepthnormal, stuckorigin);
+
+                       VectorMA(stuckorigin, -stucktrace.startdepth, stucktrace.startdepthnormal, stuckorigin);
                }
        }
-       return false;
+       return 0;
 }