From f8c376b36c5dfbf2cf089c9307fa92a6341c8c67 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 24 Dec 2015 10:32:46 +1000 Subject: [PATCH] Loopify W_RandomWeapons --- qcsrc/common/weapons/all.qc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 7db276f66..5149c8d42 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -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); } -- 2.39.2