]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/selection.qc
Declare more ints as ints
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / selection.qc
index b4f6930e54b3c1e6adc0f86d9d68485f6be1c456..5ea0a5d9d842c8690cdf979cd7a9c717e5439477 100644 (file)
@@ -1,3 +1,18 @@
+#if defined(CSQC)
+#elif defined(MENUQC)
+#elif defined(SVQC)
+       #include "../../dpdefs/progsdefs.qh"
+    #include "../../dpdefs/dpextensions.qh"
+    #include "../../common/constants.qh"
+    #include "../../common/util.qh"
+    #include "../../common/weapons/weapons.qh"
+    #include "selection.qh"
+    #include "weaponsystem.qh"
+    #include "../t_items.qh"
+    #include "../autocvars.qh"
+    #include "../defs.qh"
+#endif
+
 // switch between weapons
 void Send_WeaponComplain(entity e, float wpn, float type)
 {
@@ -18,7 +33,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
 
        if(wpn == WEP_HOOK && !g_grappling_hook && autocvar_g_nades && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(wpn)))
                complain = 0;
-               
+
        if(complain)
                self.hasweapon_complain_spam = time + 0.2;
 
@@ -26,7 +41,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
        {
                if (complain)
                        sprint(self, "Invalid weapon\n");
-               return FALSE;
+               return false;
        }
        if (cl.weapons & WepSet_FromWeapon(wpn))
        {
@@ -59,10 +74,10 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                                        play2(cl, "weapons/unavailable.wav");
                                        Send_WeaponComplain (cl, wpn, 0);
                                }
-                               return FALSE;
+                               return false;
                        }
                }
-               return TRUE;
+               return true;
        }
        if (complain)
        {
@@ -101,15 +116,14 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
 
                play2(cl, "weapons/unavailable.wav");
        }
-       return FALSE;
+       return false;
 }
 
 float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, float complain, float skipmissing)
 {
        // We cannot tokenize in this function, as GiveItems calls this
        // function. Thus we must use car/cdr.
-       float weaponwant, first_valid, prev_valid, switchtonext, switchtolast, c;
-       string rest;
+       float weaponwant, first_valid, prev_valid, switchtonext, switchtolast;
        WepSet wepset = '0 0 0';
        switchtonext = switchtolast = 0;
        first_valid = prev_valid = 0;
@@ -124,9 +138,9 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
        if(dir == 0)
                switchtonext = 1;
 
-       c = 0;
+       int c = 0;
 
-       rest = weaponorder;
+       string rest = weaponorder;
        while(rest != "")
        {
                weaponwant = stof(car(rest)); rest = cdr(rest);
@@ -136,13 +150,13 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
                if(wep.impulse != imp)
                        continue;
 
-               float i, have_other = FALSE;
+               float i, have_other = false;
                for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                {
                        if(i != weaponwant)
                        if((get_weaponinfo(i)).impulse == imp || imp < 0)
                        if((pl.weapons & WepSet_FromWeapon(i)) || (weaponsInMap & WepSet_FromWeapon(i)))
-                               have_other = TRUE;
+                               have_other = true;
                }
 
                // skip weapons we don't own that aren't normal and aren't in the map
@@ -153,7 +167,7 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
 
                ++c;
 
-               if(!skipmissing || client_hasweapon(pl, weaponwant, TRUE, FALSE))
+               if(!skipmissing || client_hasweapon(pl, weaponwant, true, false))
                {
                        if(switchtonext)
                                return weaponwant;
@@ -193,13 +207,13 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
                                if(wep.impulse != imp)
                                        continue;
 
-                       float i, have_other = FALSE;
+                       float i, have_other = false;
                        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                        {
                                if(i != weaponwant)
                                if((get_weaponinfo(i)).impulse == imp || imp < 0)
                                if((pl.weapons & WepSet_FromWeapon(i)) || (weaponsInMap & WepSet_FromWeapon(i)))
-                                       have_other = TRUE;
+                                       have_other = true;
                        }
 
                        // skip weapons we don't own that aren't normal and aren't in the map
@@ -211,7 +225,7 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa
                        --c;
                        if(c == 0)
                        {
-                               client_hasweapon(pl, weaponwant, TRUE, TRUE);
+                               client_hasweapon(pl, weaponwant, true, true);
                                break;
                        }
                }
@@ -248,7 +262,7 @@ void W_SwitchWeapon(float imp)
 {
        if (self.switchweapon != imp)
        {
-               if (client_hasweapon(self, imp, TRUE, TRUE))
+               if (client_hasweapon(self, imp, true, true))
                        W_SwitchWeapon_Force(self, imp);
                else
                        self.selectweapon = imp; // update selectweapon ANYWAY
@@ -259,7 +273,7 @@ void W_SwitchWeapon(float imp)
 void W_CycleWeapon(string weaponorder, float dir)
 {
        float w;
-       w = W_GetCycleWeapon(self, weaponorder, dir, -1, 1, TRUE);
+       w = W_GetCycleWeapon(self, weaponorder, dir, -1, 1, true);
        if(w > 0)
                W_SwitchWeapon(w);
 }
@@ -297,7 +311,7 @@ void W_PreviousWeapon(float list)
 // previously used if exists and has ammo, (second) best otherwise
 void W_LastWeapon(void)
 {
-       if(client_hasweapon(self, self.cnt, TRUE, FALSE))
+       if(client_hasweapon(self, self.cnt, true, false))
                W_SwitchWeapon(self.cnt);
        else
                W_SwitchToOtherWeapon(self);