]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_weaponsystem.qc
Check both ammos before attempting to switch guns
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_weaponsystem.qc
index 2e5a8434d74a91848f20eb9891a3ba735948dfc6..ee4b703523a2239593a46772f0976bd0c8b6dcc2 100644 (file)
@@ -34,6 +34,10 @@ float W_WeaponRateFactor()
 
 void W_SwitchWeapon_Force(entity e, float w)
 {
+       // don't switch to another weapon if we're not allowed to
+       if(e.weapon_forbidchange)
+               return;
+
        e.cnt = e.switchweapon;
        e.switchweapon = w;
        e.selectweapon = w;
@@ -1640,15 +1644,14 @@ void W_ReloadedAndReady()
        self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
 
        // if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load
-       if(!self.reload_ammo_min)
+       if(!self.reload_ammo_min || self.items & IT_UNLIMITED_WEAPON_AMMO)
                self.clip_load = self.reload_ammo_amount;
        else
        {
                while(self.clip_load < self.reload_ammo_amount && self.(self.current_ammo)) // make sure we don't add more ammo than we have
                {
                        self.clip_load += 1;
-                       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
-                               self.(self.current_ammo) -= 1;
+                       self.(self.current_ammo) -= 1;
                }
        }
        self.weapon_load[self.weapon] = self.clip_load;
@@ -1693,6 +1696,7 @@ void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, stri
 
        // no ammo, so nothing to load
        if(!self.(self.current_ammo) && self.reload_ammo_min)
+       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
        {
                if(clienttype(self) == CLIENTTYPE_REAL && self.reload_complain < time)
                {