Protocol Versions
In short
When a client says Hello, the host compares two strings: the co-op protocol (
NetSession.Protocol, nowHRD-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
NetRuntimecreates the session withnew NetSession(transport, Application.version).- The client’s first session message is
Hellowith itsProtocoland version (Net Messages). NetSession.Admiton the host:if (protocol != Protocol || version != _version)→Refuse. The client’s session ends with “The host refused: different game version (host X, you Y)“.- Below the session, each transport has its own fixed version string, checked earlier:
- Local:
ConnectcarriesHRD-LOCAL-1; a mismatch gets a transport-level Refuse “different game version”. - Steam: the lobby’s
hrd_protocoldata must beHRD-STEAM-1; a mismatch logs “That lobby runs a different game version” and leaves the lobby.
- Local:
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).
| Protocol | Commit | Date | What changed |
|---|---|---|---|
HRD-COOP-1 | 25992ce | 2026-10-21 | First version: co-op phase 2 (NetSession, roster, version check, START, shared run map) |
HRD-COOP-2 | 114ddee | 2026-10-21 | Pitches carry the park’s special ball: AtBatPitch gained the effect byte (Special balls per park) |
HRD-COOP-3 | 43a5245 | 2026-10-21 | 9-inning runs on a chosen map: StartRun gained parkId and difficulty |
HRD-COOP-4 | 7651f48 | 2026-10-22 | The match intro: new IntroDone (37) and IntroProgress (38, done and total) (PR #40) |
HRD-COOP-5 | 26257bd | 2026-10-22 | Intro reading stops and walk-up: IntroProgress also lists who is still reading (PR #40) |
HRD-COOP-6 | 592c48c | 2026-10-22 | The Phantom’s decoy balls: AtBatPitch gained the decoy count and positions (PR #41) |
HRD-COOP-7 | 3b4a0f0 | 2026-10-22 | Boss 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) addedzone,hitAim,curveAccelandgravityScaletoAtBatResult(44) but left the protocol atHRD-COOP-7. A build from 41-45 and a build from #46 on both sayHRD-COOP-7andApplication.version1.0, so they connect and then misread every swing result. Until someone bumps it toHRD-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
| What | Value | Where to tune |
|---|---|---|
| Co-op protocol | HRD-COOP-7 | NetSession.Protocol |
| Game version | Application.version (Player Settings > Version) | Project Settings |
| Local transport protocol | HRD-LOCAL-1 | LocalTransport.Protocol |
| Steam lobby protocol | HRD-STEAM-1 | SteamTransport.Protocol |
In the code
| File | What it does |
|---|---|
Assets/_Project/Scripts/Net/NetSession.cs | Protocol constant, Admit check, Hello sent in OnPeerJoined |
Assets/_Project/Scripts/Net/NetRuntime.cs | Passes Application.version to the session |
Assets/_Project/Scripts/Net/LocalTransport.cs | HRD-LOCAL-1 on Connect |
Assets/_Project/Scripts/Net/SteamTransport.cs | HRD-STEAM-1 lobby data |
Assets/_Project/Editor/NetSessionTest.cs | Checks a client on another build is refused |
Gotchas
- Both players must run the same build: two builds with the same
Application.versionbut different code will still connect if nobody bumped the protocol. When in doubt, bump it. - Message ids are never renumbered even across protocol bumps (
MsgIdcomment), so logs from different builds stay readable. docs/MULTIPLAYER-PLAN.mdsection 6c says the protocol isHRD-COOP-5; the code is atHRD-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.
Related
- Lobby and Session: where the check runs
- Net Messages: the payloads the protocol covers
- Transports: the transport-level strings
- Add a Net Message: remember to bump the protocol
- Steam Test Guide: “different game version” in troubleshooting