From e0c0554f2ed03878d82886146e7adb42707a998b Mon Sep 17 00:00:00 2001 From: terencehill Date: Wed, 16 May 2018 23:49:21 +0200 Subject: [PATCH] Reduce duplicated code --- qcsrc/common/triggers/trigger/jumppads.qc | 26 +++++------------------ 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc index 22d7ceba6..5ffdf2d10 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.qc @@ -388,6 +388,8 @@ bool trigger_push_test(entity this, entity item) vector flatdir = normalize(dist - eZ * dist.z); vector ofs = flatdir * 0.5 * min(fabs(this.absmax.x - this.absmin.x), fabs(this.absmax.y - this.absmin.y)); new_org = org + ofs; + + LABEL(new_test) e.velocity = trigger_push_calculatevelocity(new_org, t, this.height, e); if (item) { @@ -410,28 +412,10 @@ bool trigger_push_test(entity this, entity item) valid_best_target = true; } } - new_org = org - ofs; - e.velocity = trigger_push_calculatevelocity(new_org, t, this.height, e); - if (item) - { - if (!trigger_push_testorigin_for_item(e, item, new_org)) - { - delete(e); - return false; - } - } - else + if (ofs && new_org != org - ofs) { - vel = e.velocity; - if (vdist(vec2(e.velocity), <, autocvar_sv_maxspeed)) - e.velocity = autocvar_sv_maxspeed * flatdir; - if (trigger_push_testorigin(e, t, this, new_org) && (!valid_best_target || trace_endpos.z > best_target.z + 50)) - { - best_target = trace_endpos; - best_org = new_org; - best_vel = vel; - valid_best_target = true; - } + new_org = org - ofs; + goto new_test; } } -- 2.39.2