]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Loopify nix
authorMario <mario@smbclan.net>
Thu, 24 Dec 2015 00:40:24 +0000 (10:40 +1000)
committerMario <mario@smbclan.net>
Thu, 24 Dec 2015 00:40:24 +0000 (10:40 +1000)
qcsrc/common/mutators/mutator/nix/nix.qc

index a6d42d58e8fc650911d0b80926e515143dfeb5e5..2f4a7cd6390c0637387eab286c39347b531f3710 100644 (file)
@@ -43,11 +43,7 @@ REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill"
                nix_nextchange = 0;
                nix_nextweapon = 0;
 
-               for (int i = WEP_FIRST; i <= WEP_LAST; ++i)
-                       if (NIX_CanChooseWeapon(i)) {
-                               Weapon w = Weapons_from(i);
-                               w.wr_init(w);
-                       }
+               FOREACH(Weapons, it != WEP_Null && NIX_CanChooseWeapon(it.m_id), LAMBDA(it.wr_init(it)));
        }
 
        MUTATOR_ONROLLBACK_OR_REMOVE
@@ -98,11 +94,11 @@ bool NIX_CanChooseWeapon(int wpn)
 }
 void NIX_ChooseNextWeapon()
 {
-       float j;
        RandomSelection_Init();
-       for(j = WEP_FIRST; j <= WEP_LAST; ++j)
-               if(NIX_CanChooseWeapon(j))
-                       RandomSelection_Add(world, j, string_null, 1, (j != nix_weapon));
+       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+               if(NIX_CanChooseWeapon(it.m_id))
+                       RandomSelection_Add(world, it.m_id, string_null, 1, (it.m_id != nix_weapon));
+       ));
        nix_nextweapon = RandomSelection_chosen_float;
 }