trace_t stucktrace;
vec3_t stuckorigin;
vec3_t stuckmins, stuckmaxs;
- vec_t nudge;
vec_t separation;
model_t *worldmodel;
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);
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 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 0;