]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
weapons: fix being able to switch to no weapon
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 19 Dec 2015 05:24:31 +0000 (16:24 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 19 Dec 2015 05:24:53 +0000 (16:24 +1100)
qcsrc/common/weapons/weapon/blaster.qc
qcsrc/server/cl_impulse.qc
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/selection.qh

index 5ae4dd4b9d8f43a609ec2fe34b994c3c57544577..1d76279f33a9e09bab8178a8e8f7723c367f0f68 100644 (file)
@@ -192,7 +192,7 @@ void W_Blaster_Attack(
                                        case 0: // switch to last used weapon
                                        {
                                                if(PS(actor).m_switchweapon == WEP_BLASTER) // don't do this if already switching
-                                                       W_LastWeapon();
+                                                       W_LastWeapon(actor);
                                                break;
                                        }
 
index 59fc183aa495b492e48f3ccbcb4e0f6a47bc0ae4..ecd4ae07e58e2e6c9c30ea6716c6d3b13db68561 100644 (file)
@@ -195,7 +195,7 @@ IMPULSE(weapon_last)
 {
        if (this.vehicle) return;
        if (this.deadflag != DEAD_NO) return;
-       W_LastWeapon();
+       W_LastWeapon(this);
 }
 
 IMPULSE(weapon_best)
index 1c286829f6d506c7fd007b56fcf982a931361c87..0495774227360ee3746ffb7d438891c12b551e21 100644 (file)
@@ -234,16 +234,18 @@ void W_SwitchToOtherWeapon(entity pl)
        // hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway)
        Weapon ww;
        WepSet set = WepSet_FromWeapon(PS(pl).m_weapon);
-       if(pl.weapons & set)
+       if (pl.weapons & set)
        {
                pl.weapons &= ~set;
                ww = w_getbestweapon(pl);
                pl.weapons |= set;
        }
        else
+       {
                ww = w_getbestweapon(pl);
-       if(ww)
-               W_SwitchWeapon_Force(pl, ww);
+       }
+       if (ww == WEP_Null) return;
+       W_SwitchWeapon_Force(pl, ww);
 }
 
 void W_SwitchWeapon(Weapon w)
@@ -299,11 +301,11 @@ void W_PreviousWeapon(float list)
 }
 
 // previously used if exists and has ammo, (second) best otherwise
-void W_LastWeapon()
-{SELFPARAM();
-       Weapon wep = Weapons_from(self.cnt);
-       if(client_hasweapon(self, wep, true, false))
+void W_LastWeapon(entity this)
+{
+       Weapon wep = Weapons_from(this.cnt);
+       if (client_hasweapon(this, wep, true, false))
                W_SwitchWeapon(wep);
        else
-               W_SwitchToOtherWeapon(self);
+               W_SwitchToOtherWeapon(this);
 }
index 18e3f5a1c99cb1d62dd03f0656930b36d88ee84e..b4e2fb81cdb1174f76daaf014416b8af14b7b530 100644 (file)
@@ -29,5 +29,5 @@ void W_NextWeapon(float list);
 void W_PreviousWeapon(float list);
 
 // previously used if exists and has ammo, (second) best otherwise
-void W_LastWeapon();
+void W_LastWeapon(entity this);
 #endif