From: Mario Date: Sat, 3 Mar 2018 02:40:44 +0000 (+1000) Subject: Fix weapon arena menu display X-Git-Tag: xonotic-v0.8.5~2262 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=23d5ed0d4c67fb8ef96adb401ad1e2a8c8af1387;p=xonotic%2Fxonotic-data.pk3dir.git Fix weapon arena menu display --- diff --git a/qcsrc/lib/string.qh b/qcsrc/lib/string.qh index 0a3fb085c..812eb72c8 100644 --- a/qcsrc/lib/string.qh +++ b/qcsrc/lib/string.qh @@ -161,6 +161,14 @@ string cons(string a, string b) return strcat(a, " ", b); } +ERASEABLE +string cons_mid(string a, string mid, string b) +{ + if (a == "") return b; + if (b == "") return a; + return strcat(a, mid, b); +} + ERASEABLE string substring_range(string s, float b, float e) { diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc b/qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc index 0ea24a889..f8bf895c2 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc @@ -20,7 +20,7 @@ string weaponarenastring_cvar; string WeaponArenaString() { string s; - float n, i; + float n; s = cvar_string("g_weaponarena"); if(s == "0") return ""; @@ -39,14 +39,14 @@ string WeaponArenaString() n = tokenize_console(s); s = ""; - for(i = 0; i < n; ++i) + for(int j = 0; j < n; ++j) { FOREACH(Weapons, it != WEP_Null, { - if(argv(i) == it.netname) - s = strcat(s, " & ", it.m_name); + if(argv(j) == it.netname) + s = cons_mid(s, " & ", it.m_name); }); } - s = sprintf(_("%s Arena"), substring(s, 3, strlen(s) - 3)); + s = sprintf(_("%s Arena"), s); weaponarenastring = strzone(s);