Apply legacy formatting codes in the scoreboard sidebar

Vanilla's Font draws every literal through StringDecomposer.iterateFormatted:
a § code styles what follows and is not drawn, a lone trailing § is
dropped. The sidebar drew owner names, team affixes, scores and the title
raw, so servers' sidebars showed § and the code letters. They now go
through Text::resolve_legacy, as the tab list already does.

The HUD harness's sidebar cases gain legacy-coded owners, affixes, titles
and fixed score formats.

Fixes #937

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-19 12:24:00 +02:00
parent 5c88c46c51
commit 24abdb664d
2 changed files with 15 additions and 7 deletions
+9 -4
View File
@@ -135,7 +135,10 @@ def jump(rng, n):
'jumpScale': rng.choice([0.0, 1.0, 0.4, 0.001, round(rng.random(), 4)])}
OWNERS = ['Alex', 'steve', 'Zed', 'bob', 'Bobby', 'ÉLodie', 'élan', '#hidden', 'x', 'LongPlayerName_123', 'Mia', '_under']
# Servers' sidebars use legacy formatting codes in fake owners, team affixes and titles (#937):
# a code, an unknown code, `§r` and a trailing lone `§`.
OWNERS = ['Alex', 'steve', 'Zed', 'bob', 'Bobby', 'ÉLodie', 'élan', '#hidden', 'x', 'LongPlayerName_123', 'Mia', '_under',
'§1§r', '§a§lPro§r name', 'end§', '§zodd§Rcase']
FORMATS = [None, None, None, {'type': 'blank'}, {'type': 'fixed', 'value': {'text': 'FIX', 'color': 'aqua'}},
{'type': 'styled', 'style': {'color': 'gold', 'bold': True}}, {'type': 'styled', 'style': {}}]
@@ -150,12 +153,14 @@ def sidebar(rng, n):
'format': rng.choice(FORMATS)} for o in owners]
teams = []
for t in range(rng.choice([0, 0, 1, 2])):
teams.append({'name': f'team{t}', 'prefix': rng.choice([{'text': ''}, {'text': '[A] '}, {'text': '<', 'color': 'red'}]),
'suffix': rng.choice([{'text': ''}, {'text': ' *'}]),
teams.append({'name': f'team{t}', 'prefix': rng.choice([{'text': ''}, {'text': '[A] '}, {'text': '<', 'color': 'red'},
{'text': '§c§lRed §r', 'color': 'blue'}]),
'suffix': rng.choice([{'text': ''}, {'text': ' *'}, {'text': ' §7(§e5§7)§'}]),
'color': rng.choice([None, 'red', 'blue', 'gold', 'white']),
'members': [o for o in owners if rng.random() < 0.3]})
return {**screen(rng), **backdrop(rng),
'objective': {'display': rng.choice(TITLES + [{'text': 'Kills'}]), 'format': rng.choice(FORMATS)},
'objective': {'display': rng.choice(TITLES + [{'text': 'Kills'}, {'text': '§e§lANTICHEAT §7test'}]),
'format': rng.choice(FORMATS + [{'type': 'fixed', 'value': {'text': '§a12§'}}])},
'scores': scores, 'teams': teams}