From 34d640dd63e0cbc74176a10587ac8a5589d59531 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 10 Sep 2019 20:49:13 +1000 Subject: [PATCH] Use destructors to dequeue crylink spikes, fixes some potential crashes from unsafe spike removal --- qcsrc/common/weapons/weapon/crylink.qc | 11 ++++++++--- qcsrc/server/miscfunctions.qc | 5 ----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 358914635..1b4a1fc67 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -43,9 +43,14 @@ void W_Crylink_Dequeue(entity e) W_Crylink_Dequeue_Raw(e.crylink_owner, e.queueprev, e, e.queuenext); } -void W_Crylink_Reset(entity this) +void W_Crylink_DeleteLink(entity this) { W_Crylink_Dequeue(this); + delete_fn(this); +} + +void W_Crylink_Reset(entity this) +{ delete(this); } @@ -263,7 +268,6 @@ void W_Crylink_Touch(entity this, entity toucher) else if(finalhit) { // just unlink - W_Crylink_Dequeue(this); delete(this); return; } @@ -278,7 +282,6 @@ void W_Crylink_Touch(entity this, entity toucher) void W_Crylink_Fadethink(entity this) { - W_Crylink_Dequeue(this); delete(this); } @@ -308,6 +311,7 @@ void W_Crylink_Attack(Weapon thiswep, entity actor, .entity weaponentity) for(counter = 0; counter < shots; ++counter) { proj = new(spike); + proj.dtor = W_Crylink_DeleteLink; proj.reset = W_Crylink_Reset; proj.realowner = proj.owner = actor; proj.crylink_owner = actor; @@ -420,6 +424,7 @@ void W_Crylink_Attack2(Weapon thiswep, entity actor, .entity weaponentity) for(counter = 0; counter < shots; ++counter) { proj = new(spike); + proj.dtor = W_Crylink_DeleteLink; proj.weaponentity_fld = weaponentity; proj.reset = W_Crylink_Reset; proj.realowner = proj.owner = actor; diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 4cc848b67..026e1d7ce 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -1196,11 +1196,6 @@ bool WarpZone_Projectile_Touch_ImpactFilter_Callback(entity this, entity toucher return false; // no checks here else if(this.classname == "grapplinghook") RemoveHook(this); - else if(this.classname == "spike") - { - W_Crylink_Dequeue(this); - delete(this); - } else delete(this); return true; -- 2.39.2