]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
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 3589146352e18d6fe74b3616147cc6233b3d7958..1b4a1fc6765425a8e40fab81e5e65a81a973ffe4 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 4cc848b67342e53181701fe6b06f1463d9319db3..026e1d7ceb9e9fa190633702e12f819a09526f49 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;