From 6f10a41e9b8a94b457328629e392fedc35e8311e Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 8 Feb 2023 00:26:03 +1000 Subject: [PATCH] Check to make sure neither entity has been freed when calling touch functions, fixes #2811 --- qcsrc/common/physics/movetypes/movetypes.qc | 22 +++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) 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; -- 2.39.2