From: Mario Date: Thu, 13 Sep 2018 21:20:17 +0000 (+1000) Subject: Use Weapons_fromstr more X-Git-Tag: xonotic-v0.8.5~1870 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1bab4110193f99315f7592f9872abd827ada5a44;p=xonotic%2Fxonotic-data.pk3dir.git Use Weapons_fromstr more --- diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc b/qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc index 21e7ecadc..678578068 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc @@ -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); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index f8a2cd79e..351fa4350 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -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)); } diff --git a/qcsrc/server/weapons/spawning.qc b/qcsrc/server/weapons/spawning.qc index 204b5a763..37ef94c37 100644 --- a/qcsrc/server/weapons/spawning.qc +++ b/qcsrc/server/weapons/spawning.qc @@ -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) {