From 9006af604d68b00234718665c013b0031bf44758 Mon Sep 17 00:00:00 2001 From: Martin Taibr Date: Wed, 9 Aug 2017 05:44:33 +0200 Subject: [PATCH] simplify check_close_to_wall --- .../mutators/mutator/dodging/sv_dodging.qc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc index 93feb5d94..a844ab08c 100644 --- a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc @@ -104,19 +104,20 @@ REGISTER_MUTATOR(dodging, true); .int pressedkeys; #endif -// returns 1 if the player is close to a wall +// returns true if the player is close to a wall bool check_close_to_wall(entity this, float threshold) { if (PHYS_DODGING_WALL == 0) { return false; } -#define X(OFFSET) \ - tracebox(this.origin, this.mins, this.maxs, this.origin + OFFSET, true, this); \ - if(trace_fraction < 1 && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY) && vdist(this.origin - trace_endpos, <, threshold)) \ +#define X(dir) \ + tracebox(this.origin, this.mins, this.maxs, this.origin + threshold * dir, true, this); \ + if (trace_fraction < 1 && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)) \ return true; - X(1000*v_right); - X(-1000*v_right); - X(1000*v_forward); - X(-1000*v_forward); + + X(v_right); + X(-v_right); + X(v_forward); + X(-v_forward); #undef X return false; -- 2.39.2