]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Check to make sure neither entity has been freed when calling touch functions, fixes...
authorMario <mario.mario@y7mail.com>
Tue, 7 Feb 2023 14:26:03 +0000 (00:26 +1000)
committerMario <mario.mario@y7mail.com>
Tue, 7 Feb 2023 14:26:03 +0000 (00:26 +1000)
qcsrc/common/physics/movetypes/movetypes.qc

index 519a526dbc71f5d85c33d3aa061f4489bdff8a26..e60caec3154be6e8b07cc654ab22970ca89bc80b 100644 (file)
@@ -404,11 +404,8 @@ void _Movetype_CheckWaterTransition(entity ent)  // SV_CheckWaterTransition
        }
 }
 
-void _Movetype_Impact(entity this, entity oth)  // SV_Impact
+void _Movetype_Impact(entity this, entity toucher)  // SV_Impact
 {
-       if(!this && !oth)
-               return;
-
        // due to a lack of pointers in QC, we must save the trace values and restore them for other functions
        bool save_trace_allsolid = trace_allsolid;
        bool save_trace_startsolid = trace_startsolid;
@@ -424,11 +421,20 @@ void _Movetype_Impact(entity this, entity oth)  // SV_Impact
        int save_trace_dphitq3surfaceflags = trace_dphitq3surfaceflags;
        string save_trace_dphittexturename = trace_dphittexturename;
 
-       if(this.solid != SOLID_NOT && gettouch(this))
-               gettouch(this)(this, oth);
+       if(this.solid != SOLID_NOT && gettouch(this) && !wasfreed(this) && !wasfreed(toucher))
+               gettouch(this)(this, toucher);
 
-       if(oth.solid != SOLID_NOT && gettouch(oth))
-               gettouch(oth)(oth, this);
+       if(toucher.solid != SOLID_NOT && gettouch(toucher) && !wasfreed(this) && !wasfreed(toucher))
+       {
+               trace_endpos = toucher.origin;
+               trace_plane_dist = -trace_plane_dist;
+               trace_ent = this;
+               trace_dpstartcontents = 0;
+               trace_dphitcontents = 0;
+               trace_dphitq3surfaceflags = 0;
+               trace_dphittexturename = string_null;
+               gettouch(toucher)(toucher, this);
+       }
 
        trace_allsolid = save_trace_allsolid;
        trace_startsolid = save_trace_startsolid;