]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Reduce duplicated code
authorterencehill <piuntn@gmail.com>
Wed, 16 May 2018 21:49:21 +0000 (23:49 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 16 May 2018 21:49:21 +0000 (23:49 +0200)
qcsrc/common/triggers/trigger/jumppads.qc

index 22d7ceba665d07ee6f7b4f28c3ea19d11a17a6d2..5ffdf2d1066085d9bd47fd1dd5d541af179b4671 100644 (file)
@@ -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;
                                }
                        }