]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix ladder/jumppad/teleporter destination waypoints stuck in solid if they end up...
authorterencehill <piuntn@gmail.com>
Mon, 31 Jul 2017 10:46:41 +0000 (12:46 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 31 Jul 2017 10:53:54 +0000 (12:53 +0200)
qcsrc/common/triggers/func/ladder.qc
qcsrc/common/triggers/teleporters.qc
qcsrc/common/triggers/trigger/jumppads.qc
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/waypoints.qc
qcsrc/server/bot/default/waypoints.qh
qcsrc/server/bot/null/bot_null.qc
qcsrc/server/sv_main.qc

index 9aec33b90702a2fa53306d972aba5351ecfce384..92f361a145c098c56efa037cc3b9ede05b3a9a4f 100644 (file)
@@ -48,17 +48,21 @@ void func_ladder_init(entity this)
        if(min(this.absmax.x - this.absmin.x, this.absmax.y - this.absmin.y) > 100)
                return;
 
+       entity tracetest_ent = spawn();
+       setsize(tracetest_ent, PL_MIN_CONST, PL_MAX_CONST);
+       tracetest_ent.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
+
        vector top_min = (this.absmin + this.absmax) / 2;
        top_min.z = this.absmax.z;
        vector top_max = top_min;
        top_max.z += PL_MAX_CONST.z - PL_MIN_CONST.z;
-       tracebox(top_max + jumpstepheightvec, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, NULL);
+       tracebox(top_max + jumpstepheightvec, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, tracetest_ent);
        if(trace_startsolid)
        {
-               tracebox(top_max + stepheightvec, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, NULL);
+               tracebox(top_max + stepheightvec, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, tracetest_ent);
                if(trace_startsolid)
                {
-                       tracebox(top_max, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, NULL);
+                       tracebox(top_max, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, tracetest_ent);
                        if(trace_startsolid)
                        {
                                if(this.absmax.x - this.absmin.x > PL_MAX_CONST.x - PL_MIN_CONST.x
@@ -73,7 +77,7 @@ void func_ladder_init(entity this)
                                        // move top on one side
                                        top_max.x = top_min.x = this.absmin.x + (PL_MAX_CONST.x - PL_MIN_CONST.x) * 0.75;
                                }
-                               tracebox(top_max, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, NULL);
+                               tracebox(top_max, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, tracetest_ent);
                                if(trace_startsolid)
                                {
                                        if(this.absmax.x - this.absmin.x > PL_MAX_CONST.x - PL_MIN_CONST.x
@@ -88,15 +92,16 @@ void func_ladder_init(entity this)
                                                // alternatively on the other side
                                                top_max.x = top_min.x = this.absmax.x - (PL_MAX_CONST.x - PL_MIN_CONST.x) * 0.75;
                                        }
-                                       tracebox(top_max, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, NULL);
-                                       if(trace_startsolid)
-                                               return;
+                                       tracebox(top_max, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, tracetest_ent);
                                }
                        }
                }
        }
-       if(trace_endpos.z < this.absmax.z)
+       if(trace_startsolid || trace_endpos.z < this.absmax.z)
+       {
+               delete(tracetest_ent);
                return;
+       }
 
        this.bot_pickup = true; // allow bots to make use of this ladder
        float cost = waypoint_getlinearcost(trace_endpos.z - this.absmin.z);
index 451afa95b4a3d4d0500064d55e219ca94cc822a5..13a0c41d3fdbb83cda4363935a1e341f8f8b5dd5 100644 (file)
@@ -235,7 +235,13 @@ void teleport_findtarget(entity this)
                ++n;
 #ifdef SVQC
                if(e.move_movetype == MOVETYPE_NONE)
-                       waypoint_spawnforteleporter(this, e.origin, 0);
+               {
+                       entity tracetest_ent = spawn();
+                       setsize(tracetest_ent, PL_MIN_CONST, PL_MAX_CONST);
+                       tracetest_ent.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
+                       waypoint_spawnforteleporter(this, e.origin, 0, tracetest_ent);
+                       delete(tracetest_ent);
+               }
                if(e.classname != "info_teleport_destination")
                        LOG_INFO("^3MAPPER ERROR: teleporter does target an invalid teleport destination entity. Angles will not work.\n");
 #endif
index 64c15bda59a5ed3e2dd7830b0725bbe4cb4bf0b7..5a24bca66903a81ec567534bb1e085cb518d7b26 100644 (file)
@@ -324,6 +324,7 @@ void trigger_push_findtarget(entity this)
 
                        entity e = spawn();
                        setsize(e, PL_MIN_CONST, PL_MAX_CONST);
+                       e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
                        e.velocity = trigger_push_calculatevelocity(org, t, this.height);
                        vel = e.velocity;
                        vector best_target = '0 0 0';
@@ -382,7 +383,7 @@ void trigger_push_findtarget(entity this)
                                        if(velxy < autocvar_sv_maxspeed)
                                                velxy = autocvar_sv_maxspeed;
                                        cost += vlen(vec2(best_target - t.origin)) / velxy;
-                                       waypoint_spawnforteleporter(this, best_target, cost);
+                                       waypoint_spawnforteleporter(this, best_target, cost, e);
                                }
                        }
                        delete(e);
@@ -412,12 +413,13 @@ void trigger_push_findtarget(entity this)
        else
        {
                entity e = spawn();
-               setorigin(e, org);
                setsize(e, PL_MIN_CONST, PL_MAX_CONST);
+               e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
+               setorigin(e, org);
                e.velocity = this.movedir;
                tracetoss(e, e);
                if (!(boxesoverlap(this.absmin, this.absmax + eZ * 50, trace_endpos + PL_MIN_CONST, trace_endpos + PL_MAX_CONST)))
-                       waypoint_spawnforteleporter(this, trace_endpos, vlen(trace_endpos - org) / vlen(e.velocity));
+                       waypoint_spawnforteleporter(this, trace_endpos, vlen(trace_endpos - org) / vlen(e.velocity), e);
                delete(e);
        }
 
index 695763fe5606b124684352c992b860a881defb8b..cfe3e42c0c5bc08fb9da76b9e36b630a841c1acb 100644 (file)
@@ -95,8 +95,8 @@ void waypoint_schedulerelinkall();
 void waypoint_schedulerelink(entity wp);
 void waypoint_spawnforitem(entity e);
 void waypoint_spawnforitem_force(entity e, vector org);
-void waypoint_spawnforteleporter(entity e, vector destination, float timetaken);
-void waypoint_spawnforteleporter_v(entity e, vector org, vector destination, float timetaken);
+void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent);
+void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, entity tracetest_ent);
 void waypoint_spawn_fromeditor(entity pl);
 entity waypoint_spawn(vector m1, vector m2, float f);
 void waypoint_unreachable(entity pl);
index f08c32691683d03c8c8f4696153001683c8d6475..824aab23f38d2143cfde4860ef850166c110becd 100644 (file)
@@ -1017,20 +1017,18 @@ float waypoint_loadall()
        return cwp + cwb;
 }
 
-vector waypoint_fixorigin(vector position)
+vector waypoint_fixorigin(vector position, entity tracetest_ent)
 {
-       tracebox(position + '0 0 1' * (1 - PL_MIN_CONST.z), PL_MIN_CONST, PL_MAX_CONST, position + '0 0 -512', MOVE_NOMONSTERS, NULL);
+       tracebox(position + '0 0 1' * (1 - PL_MIN_CONST.z), PL_MIN_CONST, PL_MAX_CONST, position + '0 0 -512', MOVE_NOMONSTERS, tracetest_ent);
        if(trace_fraction < 1)
                position = trace_endpos;
-       //traceline(position, position + '0 0 -512', MOVE_NOMONSTERS, NULL);
-       //print("position is ", ftos(trace_endpos_z - position_z), " above solid\n");
        return position;
 }
 
 void waypoint_spawnforitem_force(entity e, vector org)
 {
        // Fix the waypoint altitude if necessary
-       org = waypoint_fixorigin(org);
+       org = waypoint_fixorigin(org, NULL);
 
        // don't spawn an item spawnfunc_waypoint if it already exists
        IL_EACH(g_waypoints, true,
@@ -1079,16 +1077,16 @@ void waypoint_spawnforteleporter_boxes(entity e, int teleport_flag, vector org1,
        e.nearestwaypointtimeout = -1;
 }
 
-void waypoint_spawnforteleporter_v(entity e, vector org, vector destination, float timetaken)
+void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, entity tracetest_ent)
 {
-       org = waypoint_fixorigin(org);
-       destination = waypoint_fixorigin(destination);
+       org = waypoint_fixorigin(org, tracetest_ent);
+       destination = waypoint_fixorigin(destination, tracetest_ent);
        waypoint_spawnforteleporter_boxes(e, WAYPOINTFLAG_TELEPORT, org, org, destination, destination, timetaken);
 }
 
-void waypoint_spawnforteleporter(entity e, vector destination, float timetaken)
+void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent)
 {
-       destination = waypoint_fixorigin(destination);
+       destination = waypoint_fixorigin(destination, tracetest_ent);
        waypoint_spawnforteleporter_boxes(e, WAYPOINTFLAG_TELEPORT, e.absmin - PL_MAX_CONST + '1 1 1', e.absmax - PL_MIN_CONST + '-1 -1 -1', destination, destination, timetaken);
 }
 
@@ -1099,7 +1097,7 @@ entity waypoint_spawnpersonal(entity this, vector position)
        // drop the waypoint to a proper location:
        //   first move it up by a player height
        //   then move it down to hit the floor with player bbox size
-       position = waypoint_fixorigin(position);
+       position = waypoint_fixorigin(position, this);
 
        w = waypoint_spawn(position, position, WAYPOINTFLAG_GENERATED | WAYPOINTFLAG_PERSONAL);
        w.nearestwaypoint = NULL;
index 02dc7b163a0fa7d72ce34c9f09dd7c05f1b1fab0..e78ed55cc5aed4eefe2bc89e17033666ab027a6d 100644 (file)
@@ -52,8 +52,8 @@ void waypoint_saveall();
 
 void waypoint_spawnforitem_force(entity e, vector org);
 void waypoint_spawnforitem(entity e);
-void waypoint_spawnforteleporter(entity e, vector destination, float timetaken);
-void waypoint_spawnforteleporter_v(entity e, vector org, vector destination, float timetaken);
+void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent);
+void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, entity tracetest_ent);
 void botframe_showwaypointlinks();
 
 float waypoint_loadall();
@@ -65,6 +65,6 @@ entity waypoint_spawnpersonal(entity this, vector position);
 
 void waypoint_unreachable(entity pl);
 
-vector waypoint_fixorigin(vector position);
+vector waypoint_fixorigin(vector position, entity tracetest_ent);
 
 void botframe_autowaypoints();
index 6c60a70e35977545dd74b11242deed9da6aefd13..ddf7abd9de70b9c3ea95063dc7dff71895122ce5 100644 (file)
@@ -37,8 +37,8 @@ void waypoint_schedulerelinkall() { }
 void waypoint_schedulerelink(entity wp) { }
 void waypoint_spawnforitem(entity e) { }
 void waypoint_spawnforitem_force(entity e, vector org) { }
-void waypoint_spawnforteleporter(entity e, vector destination, float timetaken) { }
-void waypoint_spawnforteleporter_v(entity e, vector org, vector destination, float timetaken) { }
+void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent) { }
+void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, entity tracetest_ent) { }
 void waypoint_spawn_fromeditor(entity pl) { }
 entity waypoint_spawn(vector m1, vector m2, float f) { return NULL; }
 #endif
index cd316175be2b2868ecef1971b9a5661056ccf593..986dbce155213d5d2fa3403aa02d7b8d4d7a5432 100644 (file)
@@ -411,6 +411,9 @@ LABEL(cvar_fail)
 void WarpZone_PostInitialize_Callback()
 {
        // create waypoint links for warpzones
+       entity tracetest_ent = spawn();
+       setsize(tracetest_ent, PL_MIN_CONST, PL_MAX_CONST);
+       tracetest_ent.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
        //for(entity e = warpzone_first; e; e = e.warpzone_next)
        for(entity e = NULL; (e = find(e, classname, "trigger_warpzone")); )
        {
@@ -421,6 +424,7 @@ void WarpZone_PostInitialize_Callback()
                dst = (e.enemy.absmin + e.enemy.absmax) * 0.5;
                makevectors(e.enemy.warpzone_angles);
                dst = dst + ((e.enemy.warpzone_origin - dst) * v_forward) * v_forward - 16 * v_right;
-               waypoint_spawnforteleporter_v(e, src, dst, 0);
+               waypoint_spawnforteleporter_wz(e, src, dst, 0, tracetest_ent);
        }
+       delete(tracetest_ent);
 }