From 9c822ad53b9bbb571c59937ac6cc07c4f9a09377 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 24 Dec 2015 10:37:42 +1000 Subject: [PATCH] Loopify loops --- .../gamemodes/gamemode/onslaught/onslaught.qc | 11 +++---- .../mutators/mutator/new_toys/new_toys.qc | 30 ++++++++----------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc index 9cafd1a23..485fc1b7c 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc @@ -1330,7 +1330,6 @@ void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float s {SELFPARAM(); entity head; float t, c; - int i; bool needarmor = false, needweapons = false; // Needs armor/health? @@ -1339,13 +1338,11 @@ void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float s // Needs weapons? c = 0; - for(i = WEP_FIRST; i <= WEP_LAST ; ++i) - { - // Find weapon - if(self.weapons & WepSet_FromWeapon(Weapons_from(i))) - if(++c>=4) + FOREACH(Weapons, it != WEP_Null, LAMBDA( + if(self.weapons & (it.m_wepset)) + if(++c >= 4) break; - } + )); if(c<4) needweapons = true; diff --git a/qcsrc/common/mutators/mutator/new_toys/new_toys.qc b/qcsrc/common/mutators/mutator/new_toys/new_toys.qc index 2f4510a3f..ab0567d3a 100644 --- a/qcsrc/common/mutators/mutator/new_toys/new_toys.qc +++ b/qcsrc/common/mutators/mutator/new_toys/new_toys.qc @@ -160,7 +160,7 @@ MUTATOR_HOOKFUNCTION(nt, SetStartItems) // apply those bits that are set by start_weapon_defaultmask // same for warmup - float i, j, k, n; + float j, n; WepSet newdefault; WepSet warmup_newdefault; @@ -168,26 +168,22 @@ MUTATOR_HOOKFUNCTION(nt, SetStartItems) newdefault = '0 0 0'; warmup_newdefault = '0 0 0'; - for(i = WEP_FIRST; i <= WEP_LAST; ++i) - { - entity e = Weapons_from(i); - if(e == WEP_Null) continue; + WepSet seti = '0 0 0'; - n = tokenize_console(nt_GetReplacement(e.netname, autocvar_g_new_toys_autoreplace)); + FOREACH(Weapons, it != WEP_Null, LAMBDA( + seti = it.m_wepset; + n = tokenize_console(nt_GetReplacement(it.netname, autocvar_g_new_toys_autoreplace)); - for (j = 0; j < n; ++j) - for (k = WEP_FIRST; k <= WEP_LAST; ++k) - { - Weapon w = Weapons_from(k); - if (w.netname == argv(j)) + for(j = 0; j < n; ++j) + FOREACH(Weapons, it != WEP_Null, LAMBDA( + if(it.netname == argv(j)) { - WepSet seti = e.m_wepset; - WepSet setk = w.m_wepset; - if (start_weapons & seti) newdefault |= setk; - if (warmup_start_weapons & seti) warmup_newdefault |= setk; + WepSet setk = it.m_wepset; + if(start_weapons & seti) newdefault |= setk; + if(warmup_start_weapons & seti) warmup_newdefault |= setk; } - } - } + )); + )); newdefault &= start_weapons_defaultmask; start_weapons &= ~start_weapons_defaultmask; -- 2.39.2