mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-22 14:18:21 +00:00
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:
@@ -70,6 +70,19 @@ export class WebGLFrameBuilder {
|
||||
this.view.updatePalette(this.palette);
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-resolve every player's display name (e.g. after toggling the
|
||||
* anonymous-names setting) and push it to the renderer so the names drawn on
|
||||
* the map switch live, matching the leaderboard.
|
||||
*/
|
||||
refreshNames(gameView: GameView): void {
|
||||
const displayNames = new Map<string, string>();
|
||||
for (const p of gameView.players()) {
|
||||
displayNames.set(p.id(), p.displayName());
|
||||
}
|
||||
this.view.refreshNames(displayNames);
|
||||
}
|
||||
|
||||
update(gameView: GameView): void {
|
||||
this.syncPlayers(gameView);
|
||||
this.syncPlayerSpawns(gameView);
|
||||
@@ -224,6 +237,9 @@ export class WebGLFrameBuilder {
|
||||
|
||||
newPlayers.push({
|
||||
...p.static,
|
||||
// displayName() honors the anonymous-names setting; static.displayName
|
||||
// is always the real name.
|
||||
displayName: p.displayName(),
|
||||
flag: flagUrl,
|
||||
color: p.territoryColor().toHex(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user