From 2dc0b29a606f4d0a6b803acba9129cab3f65af43 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 24 Dec 2015 10:27:49 +1000 Subject: [PATCH] More loopification --- qcsrc/server/miscfunctions.qc | 11 ++++------- qcsrc/server/weapons/throwing.qc | 13 ++++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index c56d2c59a..9fd8026a3 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -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; - } + )); } } diff --git a/qcsrc/server/weapons/throwing.qc b/qcsrc/server/weapons/throwing.qc index 1bd88e16f..c70364993 100644 --- a/qcsrc/server/weapons/throwing.qc +++ b/qcsrc/server/weapons/throwing.qc @@ -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; -- 2.39.2