From: bones_was_here Date: Sat, 15 Jul 2023 12:27:31 +0000 (+1000) Subject: NudgeOutOfSolid: add a wasn't-stuck result X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=eb6f0e98a7c0e1bcb0e9294a21cf61ac5825cd31;p=xonotic%2Fdarkplaces.git NudgeOutOfSolid: add a wasn't-stuck result It can be handy for calling code to know if the entity was initially stuck (mainly for warnings). Signed-off-by: bones_was_here --- diff --git a/phys.c b/phys.c index 6bad2bbc..1e602a1f 100644 --- 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 caa554a9..d18cfb92 100644 --- 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;