]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use Weapons_fromstr more
authorMario <zacjardine@y7mail.com>
Thu, 13 Sep 2018 21:20:17 +0000 (07:20 +1000)
committerMario <zacjardine@y7mail.com>
Thu, 13 Sep 2018 21:20:17 +0000 (07:20 +1000)
qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/weapons/spawning.qc

index 21e7ecadc454fdc7168a1e0c5314892f5d028749..678578068f526513c83b98924188ac8197afff82 100644 (file)
@@ -37,10 +37,11 @@ string WeaponArenaString()
        s = "";
        for(int j = 0; j < n; ++j)
        {
-               FOREACH(Weapons, it != WEP_Null, {
-                       if(argv(j) == it.netname)
-                               s = cons_mid(s, " & ", it.m_name);
-               });
+               entity wep = Weapons_fromstr(argv(j));
+               if(wep != WEP_Null)
+               {
+                       s = cons_mid(s, " & ", wep.m_name);
+               }
        }
        s = sprintf(_("%s Arena"), s);
 
index f8a2cd79ee60ff26314ce71f9d45502017e05f30..351fa43509de16e2d24d7103779141aaf0b13f9b 100644 (file)
@@ -600,14 +600,12 @@ void readplayerstartcvars()
                for (i = 0; i < t; ++i)
                {
                        s = argv(i);
-                       FOREACH(Weapons, it != WEP_Null, {
-                               if(it.netname == s)
-                               {
-                                       g_weaponarena_weapons |= (it.m_wepset);
-                                       g_weaponarena_list = strcat(g_weaponarena_list, it.m_name, " & ");
-                                       break;
-                               }
-                       });
+                       entity wep = Weapons_fromstr(s);
+                       if(wep != WEP_Null)
+                       {
+                               g_weaponarena_weapons |= (wep.m_wepset);
+                               g_weaponarena_list = strcat(g_weaponarena_list, wep.m_name, " & ");
+                       }
                }
                g_weaponarena_list = strzone(substring(g_weaponarena_list, 0, strlen(g_weaponarena_list) - 3));
        }
index 204b5a7633669ffeac43adcf5c6da6013939d703..37ef94c375946e0f2f058644a078adf9203a6781 100644 (file)
@@ -56,29 +56,20 @@ void weapon_defaultspawnfunc(entity this, Weapon e)
                        for (int i = 1; i < t; ++i)
                        {
                                s = argv(i);
-                               FOREACH(Weapons, it != WEP_Null, {
-                                       if(it.netname == s)
-                                       {
-                                               entity replacement = spawn();
-                                               copyentity(this, replacement);
-                                               replacement.m_isreplaced = true;
-                                               weapon_defaultspawnfunc(replacement, it);
-                                               break;
-                                       }
-                               });
+                               entity wep = Weapons_fromstr(s);
+                               if(wep != WEP_Null)
+                               {
+                                       entity replacement = spawn();
+                                       copyentity(this, replacement);
+                                       replacement.m_isreplaced = true;
+                                       weapon_defaultspawnfunc(replacement, wep);
+                               }
                        }
                }
                if (t >= 1) // always the case!
                {
                        s = argv(0);
-                       wpn = WEP_Null;
-                       FOREACH(Weapons, it != WEP_Null, {
-                               if(it.netname == s)
-                               {
-                                       wpn = it;
-                                       break;
-                               }
-                       });
+                       wpn = Weapons_fromstr(s);
                }
                if (wpn == WEP_Null)
                {