From: Mario Date: Tue, 10 Sep 2019 10:49:13 +0000 (+1000) Subject: Use destructors to dequeue crylink spikes, fixes some potential crashes from unsafe... X-Git-Tag: xonotic-v0.8.5~1290^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=34d640dd63e0cbc74176a10587ac8a5589d59531;p=xonotic%2Fxonotic-data.pk3dir.git Use destructors to dequeue crylink spikes, fixes some potential crashes from unsafe spike removal --- 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;