Use destructors to dequeue crylink spikes, fixes some potential crashes from unsafe...
authorMario <mario.mario@y7mail.com>
Tue, 10 Sep 2019 10:49:13 +0000 (20:49 +1000)
committerMario <mario.mario@y7mail.com>
Tue, 10 Sep 2019 10:49:13 +0000 (20:49 +1000)
qcsrc/common/weapons/weapon/crylink.qc
qcsrc/server/miscfunctions.qc

index 3589146..1b4a1fc 100644 (file)
@@ -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;
index 4cc848b..026e1d7 100644 (file)
@@ -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;