Fix anonymous-names setting not hiding names on the map (#4345)

## Problem

Enabling the **hidden names** (anonymous names) setting hid names in the
leaderboard/HUD but **not on the map**.

The GL name renderer (`NamePass`) drew `slot.static.displayName` —
always the real name — and never consulted
`userSettings.anonymousNames()`. The HUD works because it calls
`PlayerView.displayName()` (which honors the setting) on each render,
but the names baked into the GPU texture bypassed that path entirely.

## Fix

Push the *resolved* name into the renderer instead of the raw static
name:

- **`WebGLFrameBuilder.syncPlayers`** registers each player with
`displayName: p.displayName()` (honors the setting) instead of
`static.displayName`. Covers enabling the setting before a game and
players who join after a toggle.
- **`WebGLFrameBuilder.refreshNames` → `MapRenderer` → `Renderer` →
`NamePass.refreshNames`** is a new path that re-resolves cached names
and forces a re-upload (resets `slot.nameLen = 0`, which also recomputes
the name half-width so it stays centered).
- **`ClientGameRunner`** listens for the `settings.anonymousNames`
change event and calls `refreshNames`, mirroring the existing
territory-patterns live toggle.

## Behavior

- Enabled before a game → players register with anonymous names.
- Toggled mid-game → map names flip to/from anonymous on the next sim
tick (~100ms), matching the leaderboard.
- Your own name is unaffected (unchanged — `PlayerView` maps the local
player's anonymous name to their real name).

## Testing

`tsc --noEmit` passes for all edited files. This is a WebGL rendering
change with no straightforward unit test; verified by tracing the data
flow (resolved name → cached `slot.static.displayName` → re-upload on
dirty).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Evan
2026-06-18 14:16:57 -07:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 58e8a5fabd
commit 9881b118e4
5 changed files with 48 additions and 0 deletions
+8
View File
@@ -525,6 +525,14 @@ async function createClientGame(
{ signal: graphicsListenerAbort.signal },
);
// Re-resolve names drawn on the map when the anonymous-names setting toggles
// so they switch live, like the leaderboard.
globalThis.addEventListener(
`${USER_SETTINGS_CHANGED_EVENT}:settings.anonymousNames`,
() => webglBuilder.refreshNames(gameView),
{ signal: graphicsListenerAbort.signal },
);
// Re-resolve settings and copy them onto the renderer's live object in
// place (passes hold a reference to it, so they pick the change up).
const regenerateRenderSettings = (): void => {