]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
More loopification
authorMario <mario@smbclan.net>
Thu, 24 Dec 2015 00:27:49 +0000 (10:27 +1000)
committerMario <mario@smbclan.net>
Thu, 24 Dec 2015 00:27:49 +0000 (10:27 +1000)
qcsrc/server/miscfunctions.qc
qcsrc/server/weapons/throwing.qc

index c56d2c59a8e6e6a87583491cf8fa4d7ad2cc35bb..9fd8026a3120022d8f5bd63f57dc5981e6a0d046 100644 (file)
@@ -490,7 +490,6 @@ float want_weapon(entity weaponinfo, float allguns) // WEAPONTODO: what still ne
 
 void readplayerstartcvars()
 {
-       entity e;
        float i, t;
        string s;
 
@@ -642,18 +641,16 @@ void readplayerstartcvars()
                        warmup_start_weapons = '0 0 0';
                        warmup_start_weapons_default = '0 0 0';
                        warmup_start_weapons_defaultmask = '0 0 0';
-                       for (i = WEP_FIRST; i <= WEP_LAST; ++i)
-                       {
-                               e = Weapons_from(i);
-                               int w = want_weapon(e, g_warmup_allguns);
-                               WepSet s = (e.m_wepset);
+                       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                               int w = want_weapon(it, g_warmup_allguns);
+                               WepSet s = (it.m_wepset);
                                if(w & 1)
                                        warmup_start_weapons |= s;
                                if(w & 2)
                                        warmup_start_weapons_default |= s;
                                if(w & 4)
                                        warmup_start_weapons_defaultmask |= s;
-                       }
+                       ));
                }
        }
 
index 1bd88e16f66417ab4dbe7c83ef178b9e9da30b70..c703649936b5999ed3d67ff9db435445113e73ff 100644 (file)
@@ -32,7 +32,7 @@ void thrown_wep_think()
 // returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo)
 {SELFPARAM();
-       float thisammo, i;
+       float thisammo;
        string s;
        Weapon info = Weapons_from(wpn);
        var .int ammotype = info.ammo_field;
@@ -55,12 +55,11 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                }
                else
                {
-                       float superweapons = 1;
-                       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-                       {
-                               WepSet set = WepSet_FromWeapon(Weapons_from(i));
-                               if ((set & WEPSET_SUPERWEAPONS) && (own.weapons & set)) ++superweapons;
-                       }
+                       int superweapons = 1;
+                       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                               WepSet set = it.m_wepset;
+                               if((set & WEPSET_SUPERWEAPONS) && (own.weapons & set)) ++superweapons;
+                       ));
                        if(superweapons <= 1)
                        {
                                wep.superweapons_finished = own.superweapons_finished;