]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Loopify W_RandomWeapons
authorMario <mario@smbclan.net>
Thu, 24 Dec 2015 00:32:46 +0000 (10:32 +1000)
committerMario <mario@smbclan.net>
Thu, 24 Dec 2015 00:32:46 +0000 (10:32 +1000)
qcsrc/common/weapons/all.qc

index 7db276f66bebb8de08405a2d289c80b79eb4200e..5149c8d4255087304ea127e31bfd47c45edfea45 100644 (file)
@@ -194,7 +194,7 @@ string W_FixWeaponOrder_ForceComplete(string order)
 
 void W_RandomWeapons(entity e, float n)
 {
-       int i, j;
+       int i;
        WepSet remaining;
        WepSet result;
        remaining = e.weapons;
@@ -202,9 +202,11 @@ void W_RandomWeapons(entity e, float n)
        for (i = 0; i < n; ++i)
        {
                RandomSelection_Init();
-               for (j = WEP_FIRST; j <= WEP_LAST; ++j)
-                       if (remaining & WepSet_FromWeapon(Weapons_from(j))) RandomSelection_Add(NULL, j, string_null, 1, 1);
-               Weapon w = Weapons_from(RandomSelection_chosen_float);
+               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                       if (remaining & (it.m_wepset))
+                               RandomSelection_Add(it, 0, string_null, 1, 1);
+               ));
+               Weapon w = RandomSelection_chosen_ent;
                result |= WepSet_FromWeapon(w);
                remaining &= ~WepSet_FromWeapon(w);
        }