From: Mario Date: Tue, 7 Feb 2023 14:26:03 +0000 (+1000) Subject: Check to make sure neither entity has been freed when calling touch functions, fixes... X-Git-Tag: xonotic-v0.8.6~173^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6f10a41e9b8a94b457328629e392fedc35e8311e;p=xonotic%2Fxonotic-data.pk3dir.git Check to make sure neither entity has been freed when calling touch functions, fixes #2811 --- diff --git a/qcsrc/common/physics/movetypes/movetypes.qc b/qcsrc/common/physics/movetypes/movetypes.qc index 519a526db..e60caec31 100644 --- a/qcsrc/common/physics/movetypes/movetypes.qc +++ b/qcsrc/common/physics/movetypes/movetypes.qc @@ -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;