From: Mario <mario@smbclan.net>
Date: Thu, 24 Dec 2015 00:32:46 +0000 (+1000)
Subject: Loopify W_RandomWeapons
X-Git-Tag: xonotic-v0.8.2~1433
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f8c376b36c5dfbf2cf089c9307fa92a6341c8c67;p=xonotic%2Fxonotic-data.pk3dir.git

Loopify W_RandomWeapons
---

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);
 	}