]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add some checks to prevent silly things, like corpses (not the undead ones) picking...
authorMario <mario@smbclan.net>
Mon, 15 Feb 2016 07:50:54 +0000 (17:50 +1000)
committerMario <mario@smbclan.net>
Mon, 15 Feb 2016 07:50:54 +0000 (17:50 +1000)
qcsrc/common/mutators/mutator/nades/nades.qc

index 271ccb90f72c391c192667658781da60bd1f9be2..720a8f0e80ee8618744a1eb7bd7e90aaec03426c 100644 (file)
@@ -684,6 +684,7 @@ void nade_pickup(entity this, entity thenade)
                this.nade.nade_time_primed = thenade.nade_time_primed;
 }
 
+bool CanThrowNade(entity this);
 void nade_touch()
 {SELFPARAM();
        if(other)
@@ -695,7 +696,8 @@ void nade_touch()
        if(autocvar_g_nades_pickup)
        if(time >= self.spawnshieldtime)
        if(!other.nade && self.health == self.max_health) // no boosted shot pickups, thank you very much
-       if(IS_REAL_CLIENT(other) && IS_PLAYER(other))
+       if(CanThrowNade(other)) // prevent some obvious things, like dead players
+       if(IS_REAL_CLIENT(other)) // above checks for IS_PLAYER, don't need to do it here
        {
                nade_pickup(other, self);
                sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
@@ -1013,24 +1015,24 @@ void nade_prime()
        spawn_held_nade(self, self, autocvar_g_nades_nade_lifetime, ntype, pntype);
 }
 
-float CanThrowNade()
-{SELFPARAM();
-       if(self.vehicle)
+bool CanThrowNade(entity this)
+{
+       if(this.vehicle)
                return false;
 
        if(gameover)
                return false;
 
-       if(IS_DEAD(self))
+       if(IS_DEAD(this))
                return false;
 
        if (!autocvar_g_nades)
                return false; // allow turning them off mid match
 
-       if(forbidWeaponUse(self))
+       if(forbidWeaponUse(this))
                return false;
 
-       if (!IS_PLAYER(self))
+       if (!IS_PLAYER(this))
                return false;
 
        return true;
@@ -1040,7 +1042,7 @@ float CanThrowNade()
 
 void nades_CheckThrow()
 {SELFPARAM();
-       if(!CanThrowNade())
+       if(!CanThrowNade(self))
                return;
 
        entity held_nade = self.nade;
@@ -1103,7 +1105,7 @@ CLASS(NadeOffhand, OffhandWeapon)
                                toss_nade(player, false, '0 0 0', time + 0.05);
                }
 
-        if (!CanThrowNade()) return;
+        if (!CanThrowNade(player)) return;
         if (!(time > player.nade_refire)) return;
                if (key_pressed) {
                        if (!held_nade) {