]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
NudgeOutOfSolid: add a wasn't-stuck result
authorbones_was_here <bones_was_here@xonotic.au>
Sat, 15 Jul 2023 12:27:31 +0000 (22:27 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Sat, 15 Jul 2023 12:27:31 +0000 (22:27 +1000)
It can be handy for calling code to know if the entity was initially
stuck (mainly for warnings).

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
phys.c
phys.h

diff --git a/phys.c b/phys.c
index 6bad2bbc032504e77556b8432f4b0998bf7d9ce4..1e602a1ffbe72013669221e7c31bea1629f77cb8 100644 (file)
--- a/phys.c
+++ b/phys.c
@@ -6,7 +6,7 @@
 #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;
@@ -59,11 +59,11 @@ qbool PHYS_NudgeOutOfSolid(prvm_prog_t *prog, prvm_edict_t *ent)
                        {
                                // 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);
                }
        }
-       return false;
+       return 0;
 }
diff --git a/phys.h b/phys.h
index caa554a94a3d7443720b76c57d34a317fc63f780..d18cfb92ffca06efde88811d015c3931441d6a74 100644 (file)
--- a/phys.h
+++ b/phys.h
@@ -5,9 +5,9 @@
 
 
 /*! move an entity that is stuck out of the surface it is stuck in (can move large amounts)
- * returns true if it found a better place
+ * returns 1 if it found a better place, 0 if it remains stuck, -1 if it wasn't stuck.
  */
-qbool PHYS_NudgeOutOfSolid(prvm_prog_t *prog, prvm_edict_t *ent);
+int PHYS_NudgeOutOfSolid(prvm_prog_t *prog, prvm_edict_t *ent);
 extern cvar_t cl_gameplayfix_nudgeoutofsolid_separation;