From: drjaska Date: Wed, 22 Mar 2023 14:37:26 +0000 (+0200) Subject: untested protorefactor X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3c6e09b32ae3d658bf058abb3f9b48e599919c34;p=xonotic%2Fxonotic-data.pk3dir.git untested protorefactor --- diff --git a/qcsrc/common/minigames/minigame/c4.qc b/qcsrc/common/minigames/minigame/c4.qc index 51287ef2e..142e50c89 100644 --- a/qcsrc/common/minigames/minigame/c4.qc +++ b/qcsrc/common/minigames/minigame/c4.qc @@ -353,6 +353,7 @@ void c4_hud_status(vector pos, vector mySize) } entity e; + string allspecs = ""; FOREACH_MINIGAME_ENTITY(e) { if ( e.classname == "minigame_player" && e.team != C4_SPECTATOR_TEAM ) @@ -371,53 +372,32 @@ void c4_hud_status(vector pos, vector mySize) mypos_x += tile_size_x; } - } - int specs = 0; - FOREACH_MINIGAME_ENTITY(e) - { + if (e.classname == "minigame_player" && e.team == C4_SPECTATOR_TEAM) { - ++specs; + string current_spec = ""; + + string cmpctString = entcs_GetName(e.minigame_playerslot - 1); + if (strlennocol(cmpctString) > 8) + { + int new_length = textLengthUpToLength(cmpctString, 8, strlennocol); + cmpctString = strcat(substring(cmpctString, 0, new_length), ".."); + } + if (strlen(allspecs) > 0) + current_spec = strcat(",", cmpctString); + else + current_spec = cmpctString; + if (strlen(allspecs) < 90) + allspecs = strcat(allspecs, current_spec); } } - - if (specs > 0) + if (strlen(allspecs) > 0) { pos_y = pos_y * 0.3; pos_x = pos_x * 0.41; - int i = 0; - - string allspecs = ""; ts = minigame_drawstring_wrapped(mySize_x * 1.7, pos, "Spectators: ", '14 14 0', '0.85 0.47 0.42', panel_fg_alpha, DRAWFLAG_NORMAL, 0); pos_y += 14; - FOREACH_MINIGAME_ENTITY(e) - { - if (e.classname == "minigame_player" && e.team == C4_SPECTATOR_TEAM) - { - ++i; - string current_spec = ""; - - string cmpctString = entcs_GetName(e.minigame_playerslot - 1); - if (strlennocol(cmpctString) > 8) - { - int new_length = textLengthUpToLength(cmpctString, 8, strlennocol); - cmpctString = strcat(substring(cmpctString, 0, new_length), ".."); - } - //last - if (i != specs) - { - current_spec = strcat(cmpctString, ","); - } - else - { - current_spec = cmpctString; - } - if (strlen(allspecs) + strlen(current_spec) > 100) - break; - allspecs = strcat(allspecs, current_spec); - } - } ts = minigame_drawcolorcodedstring_wrapped(mySize_x * 1.7, pos, allspecs, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL, 0); } } diff --git a/qcsrc/common/minigames/minigame/ttt.qc b/qcsrc/common/minigames/minigame/ttt.qc index 6b294e532..a78a6468a 100644 --- a/qcsrc/common/minigames/minigame/ttt.qc +++ b/qcsrc/common/minigames/minigame/ttt.qc @@ -298,6 +298,7 @@ void ttt_hud_status(vector pos, vector mySize) vector tile_size = '48 48 0'; entity e; + string allspecs = ""; FOREACH_MINIGAME_ENTITY(e) { if ( e.classname == "minigame_player" && e.team != TTT_SPECTATOR_TEAM ) @@ -317,56 +318,34 @@ void ttt_hud_status(vector pos, vector mySize) mypos_x += tile_size_x; drawstring(mypos,ftos(e.minigame_flags),tile_size, - '0.7 0.84 1', panel_fg_alpha, DRAWFLAG_NORMAL); + '0.7 0.84 1', panel_fg_alpha, DRAWFLAG_NORMAL); } - } - int specs = 0; - FOREACH_MINIGAME_ENTITY(e) - { if (e.classname == "minigame_player" && e.team == TTT_SPECTATOR_TEAM) { - ++specs; + string current_spec = ""; + + string cmpctString = entcs_GetName(e.minigame_playerslot - 1); + if (strlennocol(cmpctString) > 8) + { + int new_length = textLengthUpToLength(cmpctString, 8, strlennocol); + cmpctString = strcat(substring(cmpctString, 0, new_length), ".."); + } + if (strlen(allspecs) > 0) + current_spec = strcat(",", cmpctString); + else + current_spec = cmpctString; + if (strlen(allspecs) < 90) + allspecs = strcat(allspecs, current_spec); } } - - if (specs > 0) + if (strlen(allspecs) > 0) { pos_y = pos_y * 0.3; pos_x = pos_x * 0.41; - int i = 0; - - string allspecs = ""; ts = minigame_drawstring_wrapped(mySize_x * 1.7, pos, "Spectators: ", '14 14 0', '0.85 0.47 0.42', panel_fg_alpha, DRAWFLAG_NORMAL, 0); pos_y += 14; - FOREACH_MINIGAME_ENTITY(e) - { - if (e.classname == "minigame_player" && e.team == TTT_SPECTATOR_TEAM) - { - ++i; - string current_spec = ""; - - string cmpctString = entcs_GetName(e.minigame_playerslot - 1); - if (strlennocol(cmpctString) > 8) - { - int new_length = textLengthUpToLength(cmpctString, 8, strlennocol); - cmpctString = strcat(substring(cmpctString, 0, new_length), ".."); - } - //last - if (i != specs) - { - current_spec = strcat(cmpctString, ","); - } - else - { - current_spec = cmpctString; - } - if (strlen(allspecs) + strlen(current_spec) > 100) - break; - allspecs = strcat(allspecs, current_spec); - } - } ts = minigame_drawcolorcodedstring_wrapped(mySize_x * 1.7, pos, allspecs, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL, 0); } }