]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix 100% cpu when entities using TOSS-based movetypes get stuck
authorbones_was_here <bones_was_here@xonotic.au>
Mon, 18 Sep 2023 14:52:31 +0000 (00:52 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Thu, 14 Mar 2024 06:40:30 +0000 (16:40 +1000)
This is a bug in sv_gameplayfix_slidemoveprojectiles which gives nicer
physics interactions but didn't abort if the entity is immovable.

qcsrc/common/physics/movetypes/movetypes.qc
qcsrc/common/physics/movetypes/toss.qc

index 651b6f3d642e7f861fe1cb4adcb439b5a7d6a8e3..f72d4d43f6cefe0903fdc745089e0009608e97c3 100644 (file)
@@ -708,7 +708,10 @@ bool _Movetype_PushEntity(entity this, vector push, bool dolink)  // SV_PushEnti
                _Movetype_PushEntityTrace(this, push);
                this.move_nomonsters = oldtype;
                if(trace_startsolid)
+               {
+                       trace_fraction = 0;
                        return true;
+               }
        }
 
        this.origin = trace_endpos;
index c23ab4384b7651ffb0e284da0ce8b353d1272f85..5c254811d181c2cac9f5a5496490ae442241d403 100644 (file)
@@ -50,14 +50,17 @@ void _Movetype_Physics_Toss(entity this, float dt)  // SV_Physics_Toss
        float movetime = dt;
        for (int bump = 0; bump < MAX_CLIP_PLANES && movetime > 0; bump++)
        {
+               if(this.velocity == '0 0 0')
+                       break;
+
                vector move = this.velocity * movetime;
                if(!_Movetype_PushEntity(this, move, true))
-                       return;
+                       return; // teleported
                if (wasfreed(this))
                        return;
 
                // NOTE: this is bmodelstartsolid in the engine
-               if (trace_startsolid && trace_ent.solid == SOLID_BSP)
+               if (trace_allsolid && trace_fraction == 0 && trace_ent.solid == SOLID_BSP)
                {
                        // QC lacks pointers so we must save the old trace values
                        float oldtrace_fraction = trace_fraction;
@@ -68,9 +71,16 @@ void _Movetype_Physics_Toss(entity this, float dt)  // SV_Physics_Toss
                        trace_plane_normal = oldtrace_plane_normal;
                        trace_ent = oldtrace_ent;
                        if(!_Movetype_PushEntity(this, move, true))
-                               return;
+                               return; // teleported
                        if (wasfreed(this))
                                return;
+                       if (trace_allsolid && trace_fraction == 0)
+                       {
+                               // immovably stuck, don't waste CPU trying to move again
+                               this.velocity = '0 0 0';
+                               SET_ONGROUND(this);
+                               return;
+                       }
                }
 
                if (trace_fraction == 1)