Multiplayer: settable nickname for LAN / logged-out play #40

Closed
opened 2026-10-20 18:45:11 +00:00 by mintopia · 3 comments
Owner

Want

Let the player set their multiplayer nickname for LAN / when not logged in. Today, offline, it falls back to the computer's name or blur.

Preferred: an option under Options > Multiplayer (text entry, persisted like the Graphics host options via Host.get/set / NSUserDefaults). Acceptable fallback: a command-line parameter.

What exists

  • src/host/misc_dlls.cpp:66: GetUserNameA/W return $BLUR_PLAYER_NAME, else "blur". So there's already an env-var override, but you can't find it and it's not in the UI.
  • src/host/ws2_32.cpp:373: gethostname returns the real Mac hostname. This is probably the "computer name" source.
  • src/host/k32_misc.cpp:207: GetComputerNameA is hard-coded to BLURHOST.
  • Not yet known: which of these the game actually uses for the LAN/offline display name, and whether that changes when signed in.

Tasks

  1. Trace which API or field the game reads for the offline/LAN player name, and when.
  2. Add a persisted Nickname host setting (default: current behaviour) that feeds that source.
  3. UI: a row in Options > Multiplayer (Lua patch like patches/Screens/Shared/Options_Graphics.post.lua). Needs a text-entry widget. If the stock UI has no usable keyboard/text entry, fall back to a CLI flag (e.g. --nickname NAME) and document BLUR_PLAYER_NAME.
  4. Sanitise: length limit and allowed characters to match what the game/network packet accepts.

Verify

On recomp: set a nickname, host a LAN game, join from a second instance. The other player sees the nickname in the lobby and in race standings. The setting survives a restart.

## Want Let the player set their multiplayer nickname for LAN / when not logged in. Today, offline, it falls back to the computer's name or `blur`. Preferred: an option under **Options > Multiplayer** (text entry, persisted like the Graphics host options via `Host.get/set` / NSUserDefaults). Acceptable fallback: a command-line parameter. ## What exists - `src/host/misc_dlls.cpp:66`: `GetUserNameA/W` return `$BLUR_PLAYER_NAME`, else `"blur"`. So there's already an env-var override, but you can't find it and it's not in the UI. - `src/host/ws2_32.cpp:373`: `gethostname` returns the real Mac hostname. This is probably the "computer name" source. - `src/host/k32_misc.cpp:207`: `GetComputerNameA` is hard-coded to `BLURHOST`. - Not yet known: which of these the game actually uses for the LAN/offline display name, and whether that changes when signed in. ## Tasks 1. Trace which API or field the game reads for the offline/LAN player name, and when. 2. Add a persisted `Nickname` host setting (default: current behaviour) that feeds that source. 3. UI: a row in Options > Multiplayer (Lua patch like `patches/Screens/Shared/Options_Graphics.post.lua`). Needs a text-entry widget. If the stock UI has no usable keyboard/text entry, fall back to a CLI flag (e.g. `--nickname NAME`) and document `BLUR_PLAYER_NAME`. 4. Sanitise: length limit and allowed characters to match what the game/network packet accepts. ## Verify On recomp: set a nickname, host a LAN game, join from a second instance. The other player sees the nickname in the lobby and in race standings. The setting survives a restart.
Author
Owner

Update on the name source: BLUR_PLAYER_NAME came in with 356f58a (2026-10-18, #5). Before that commit, GetUserNameA/W wasn't implemented. docs/state-websocket.md:61 says the player name the game sees is the OS user name, which is this env var or blur if it's unset. It was added so test instances could be told apart in the MP standings feed.

So step 1 (trace the name source) is probably already done: GetUserNameA/W is the source, not gethostname. Still to confirm on a real LAN lobby; if it holds, this ticket shrinks to:

  • a persisted Nickname host setting that feeds user in src/host/misc_dlls.cpp:66 (env var still wins if set, so test setups keep working)
  • a row in Options > Multiplayer, or a CLI flag if no text-entry widget exists
  • sanitising (length and allowed characters)

Watch out: user is a function-local static, read once on the first call. A change made in the UI may not show up until restart, or until the game asks for the name again.

Update on the name source: `BLUR_PLAYER_NAME` came in with 356f58a (2026-10-18, #5). Before that commit, `GetUserNameA/W` wasn't implemented. `docs/state-websocket.md:61` says the player name the game sees is the OS user name, which is this env var or `blur` if it's unset. It was added so test instances could be told apart in the MP standings feed. So step 1 (trace the name source) is probably already done: `GetUserNameA/W` is the source, not `gethostname`. Still to confirm on a real LAN lobby; if it holds, this ticket shrinks to: - a persisted `Nickname` host setting that feeds `user` in `src/host/misc_dlls.cpp:66` (env var still wins if set, so test setups keep working) - a row in Options > Multiplayer, or a CLI flag if no text-entry widget exists - sanitising (length and allowed characters) Watch out: `user` is a function-local `static`, read once on the first call. A change made in the UI may not show up until restart, or until the game asks for the name again.
Author
Owner

Added persisted --nickname NAME CLI flag (NSUserDefaults Nickname, sanitised to A-Za-z0-9 space _-. max 15). GetUserNameA/W now reads BLUR_PLAYER_NAME > Nickname > "blur" on each call (no more static). No stock text-entry widget, so no Options > Multiplayer row (CLI fallback per ticket). Documented in play-macos-env-vars.md / state-websocket.md. Build OK, flag/sanitise/persist checked; NOT verified in a two-instance LAN lobby (needs game files); the 15-char limit is a guess, not checked against the packet.

Added persisted `--nickname NAME` CLI flag (NSUserDefaults `Nickname`, sanitised to A-Za-z0-9 space _-. max 15). `GetUserNameA/W` now reads BLUR_PLAYER_NAME > Nickname > "blur" on each call (no more static). No stock text-entry widget, so no Options > Multiplayer row (CLI fallback per ticket). Documented in play-macos-env-vars.md / state-websocket.md. Build OK, flag/sanitise/persist checked; NOT verified in a two-instance LAN lobby (needs game files); the 15-char limit is a guess, not checked against the packet.
Author
Owner

Completed and merged by Harmonic (task 40).

Completed and merged by Harmonic (task 40).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mintopia/blur#40
No description provided.