Protocol Versions

In short

When a client says Hello, the host compares two strings: the co-op protocol (NetSession.Protocol, now HRD-COOP-7) and the game version (Application.version). If either differs, the client is refused with “different game version (host X, you Y)“. Bump the protocol whenever a message’s payload or the run’s rules change in a way an older build would misread.

How it works

  1. NetRuntime creates the session with new NetSession(transport, Application.version).
  2. The client’s first session message is Hello with its Protocol and version (Net Messages).
  3. NetSession.Admit on the host: if (protocol != Protocol || version != _version) → Refuse. The client’s session ends with “The host refused: different game version (host X, you Y)“.
  4. Below the session, each transport has its own fixed version string, checked earlier:
    • Local: Connect carries HRD-LOCAL-1; a mismatch gets a transport-level Refuse “different game version”.
    • Steam: the lobby’s hrd_protocol data must be HRD-STEAM-1; a mismatch logs “That lobby runs a different game version” and leaves the lobby.

History of NetSession.Protocol

Dated with git log -G "HRD-COOP" -- Assets/_Project/Scripts/Net/NetSession.cs on main (-S only finds the first commit, because every bump keeps one “HRD-COOP” on the line).

ProtocolCommitDateWhat changed
HRD-COOP-125992ce2026-10-21First version: co-op phase 2 (NetSession, roster, version check, START, shared run map)
HRD-COOP-2114ddee2026-10-21Pitches carry the park’s special ball: AtBatPitch gained the effect byte (Special balls per park)
HRD-COOP-343a52452026-10-219-inning runs on a chosen map: StartRun gained parkId and difficulty
HRD-COOP-47651f482026-10-22The match intro: new IntroDone (37) and IntroProgress (38, done and total) (PR #40)
HRD-COOP-526257bd2026-10-22Intro reading stops and walk-up: IntroProgress also lists who is still reading (PR #40)
HRD-COOP-6592c48c2026-10-22The Phantom’s decoy balls: AtBatPitch gained the decoy count and positions (PR #41)
HRD-COOP-73b4a0f02026-10-22Boss balls stack with the map’s: AtBatPitch gained bossEffect; 6f753ee in the same PR then added arcAngle (curveballs and changeups loop sideways) and only extended the comment (PR #41)

The code comment keeps the history short: // 2: pitches carry the park's special ball; 3: 9-inning runs on a chosen map; 4: the match intro; 5: intro reading stops and walk-up; 6: The Phantom's decoy balls; 7: boss balls stack with the map's, curveballs / changeups loop sideways.

PR #46 changed a payload without a bump

Batting after Mario Superstar Baseball (255f139, merged as #46) added zone, hitAim, curveAccel and gravityScale to AtBatResult (44) but left the protocol at HRD-COOP-7. A build from 41-45 and a build from #46 on both say HRD-COOP-7 and Application.version 1.0, so they connect and then misread every swing result. Until someone bumps it to HRD-COOP-8, make sure both players run a build from the same commit.

Feature branches

Branches can bump the protocol before they merge. Only main counts: update this table when such a branch merges.

Numbers

WhatValueWhere to tune
Co-op protocolHRD-COOP-7NetSession.Protocol
Game versionApplication.version (Player Settings > Version)Project Settings
Local transport protocolHRD-LOCAL-1LocalTransport.Protocol
Steam lobby protocolHRD-STEAM-1SteamTransport.Protocol

In the code

FileWhat it does
Assets/_Project/Scripts/Net/NetSession.csProtocol constant, Admit check, Hello sent in OnPeerJoined
Assets/_Project/Scripts/Net/NetRuntime.csPasses Application.version to the session
Assets/_Project/Scripts/Net/LocalTransport.csHRD-LOCAL-1 on Connect
Assets/_Project/Scripts/Net/SteamTransport.csHRD-STEAM-1 lobby data
Assets/_Project/Editor/NetSessionTest.csChecks a client on another build is refused

Gotchas

  • Both players must run the same build: two builds with the same Application.version but different code will still connect if nobody bumped the protocol. When in doubt, bump it.
  • Message ids are never renumbered even across protocol bumps (MsgId comment), so logs from different builds stay readable.
  • docs/MULTIPLAYER-PLAN.md section 6c says the protocol is HRD-COOP-5; the code is at HRD-COOP-7.
  • The plan says the lobby should also carry a content hash. Not built: only the protocol and version are compared.
  • The transport strings (HRD-LOCAL-1, HRD-STEAM-1) have never changed; a payload change only needs the co-op one.