Skip to content

Tell the relay which machine this is - #18

Merged
martin-mat merged 1 commit into
mainfrom
net-platform-id
Nov 1, 2026
Merged

martin-mat merged 1 commit into
mainfrom
net-platform-id

Conversation

@martin-mat

@martin-mat martin-mat commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

The relay's statistics can't tell most machines apart: every build on the shared network client (common/ws.c) sends User-Agent: BomberNet, so C64, PC, Amiga and the rest count as one "retro machine" group. This makes each build name itself on the connection URL.

What changes

  • NET_PLATFORM in plat_config.h adds &pf=<id> to the create and join URLs. The ids are the port ids in the catalog: c64, amiga, atari-xl, atari-st, amstrad-cpc, pc-dos, zx-spectrum-48k, element-zx-128k, browser.
  • A build without NET_PLATFORM (host, sim6502) sends what it sends today.
  • The MZ-800 needs nothing: it uses netdev_card.c, and the MZPico firmware already names itself.
  • net_create and net_join now share one path buffer of 52 bytes instead of having 40 each. The longest URL is /net?game=16974&code=ABCD&bin=1&pf=element-zx-128k, 50 characters plus the terminator.
  • docs/net-protocol.md documents the parameter.

Compatibility

There is no protocol change and BUILD_ID stays the same, so machines with and without this play together. The production relay already reads pf and treats an unknown id as if there were none. relay/relay.py only looks at bin.

Testing

Tested locally with softnet_test (the C network client on a PC) against the production relay code running under wrangler dev:

  • NET_PLATFORM="element-zx-128k" with NET_BINARY_INPUT, built with ASan and UBSan: a 60-frame match passed, and the relay counted both seats as element-zx-128k.
  • No NET_PLATFORM: a 60-frame match passed, and the relay counted both seats as retro, as it does today.

Not tested locally: the retro toolchains aren't installed here, so the machine builds, check_sizes.py and the Spectrum matches rely on CI. relay/relay.py wasn't run locally either.

Worth checking in review

  • Spectrum memory: the two URL strings get about 38 bytes longer on the Spectrum and the shared buffer saves 28, so the program grows by roughly 10 bytes. check_sizes.py should confirm that still fits.
  • 128K Spectrum id: ZX128 always reports element-zx-128k, including the test-only ZX128_NET=spectranet build.

The new ids reach players with the next release; nothing else needs to ship with it.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Room creation and joining can now include platform identification, allowing production relay statistics to distinguish supported systems.
  • Documentation
    • Documented the optional platform identifier and how production and reference relays handle it.

The machines on the shared network client all send the same User-Agent, so
the relay's statistics cannot tell a C64 from an Amiga. NET_PLATFORM in
plat_config.h adds &pf=<id> to the connection URL. It changes nothing in a
game, and both relays accept it. create and join share one path buffer, now
large enough for the longest URL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 9961800 and 1b95eb4.

Files selected for processing: 10
  • c/common/netdev_soft.c
  • c/platform/amiga/plat_config.h
  • c/platform/atari/plat_config.h
  • c/platform/atarist/plat_config.h
  • c/platform/c64/plat_config.h
  • c/platform/cpc/plat_config.h
  • c/platform/pc/plat_config.h
  • c/platform/web/plat_config.h
  • c/platform/zx/plat_config.h
  • docs/net-protocol.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Platform configurations now define machine identifiers for relay statistics. Room creation and join requests append the optional pf parameter when a platform identifier is defined. The network protocol documentation describes the parameter and its handling.

Changes: Relay platform identification

Layer / File(s) Summary
Platform identifiers and parameter contract
docs/net-protocol.md, c/platform/{amiga,atari,atarist,c64,cpc,pc,web,zx}/plat_config.h
Platform configurations define NET_PLATFORM identifiers. The protocol documentation describes the optional pf parameter, accepted identifiers, and handling of unknown identifiers.
Platform parameter in room requests
c/common/netdev_soft.c
Room creation and join request paths append PF_ARG. The macro expands to the configured platform parameter or an empty string when NET_PLATFORM is undefined. Both paths use a shared 52-byte buffer.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: Minimal · up to 1b95e

The platform identifiers and optional relay parameter are ready to merge, subject to normal CI validation.

Pre-merge checks: Passed 4
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Tell the relay which machine this is" describes the main change. The PR adds a pf=<id> platform parameter to create and join URLs when NET_PLATFORM is defined, so the relay can tell whi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Tell the relay which machine this is" describes the main change. The PR adds a pf=&lt;id&gt; platform parameter to create and join URLs when NET_PLATFORM is defined, so the relay can tell which machine connects. The title is specific and short. It does not name the parameter or the files, which is acceptable for a title.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@martin-mat
martin-mat merged commit 6b48c6e into main Nov 1, 2026
30 checks passed
@martin-mat
martin-mat deleted the net-platform-id branch November 1, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant