SUNRISE

Co-op play

In co-op, one player is the host. The host’s Sunrise serves the shared session: activities, matchmaking, friends and chat. Every other player is a guest. A guest’s Sunrise keeps its own save and forwards the shared requests to the host. Co-op works only on the local network.

The settings keys are on Settings, logs and in-game tools. The proxy code is in src/server/bap/proxy/, the co-op checks in src/state/coop/, and friends and chat in src/state/social/.

Roles

rolewhat the Sunrise server does
embeddedsolo play, the default. Everything is answered on loopback
hostserves the shared session to its own game and to every guest. Its BAP listener and gameplay endpoint bind the local network
clienta guest. Its own game connects to it on loopback. It answers account requests itself and forwards the rest to the host

Co-op needs multiplayer_enabled set to true. Without it, any setting that opens a network path makes the file fail to parse.

Local network only

Every address co-op binds, advertises or dials must be a local one:

  • 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16
  • 127.0.0.0/8 and the link-local range 169.254.0.0/16
  • 0.0.0.0, as a bind address only

A setting outside these ranges stops the start with ev=settings result=fail reason=lan_only. The host’s listener also refuses a connection from any other address, and logs ev=transport stage=accept result=refused reason=not_lan.

The host takes at most server.max_players players, 32 by default. Each player can hold up to 4 BAP connections.

What stays on the guest

A guest’s Sunrise sorts every request from its game into one of two kinds (proxy_routing.cpp):

stays on the guestgoes to the host
web service calls: inventory, vendors, character pick and the restActivity Host services 6, 8 and 16
subscribes to queuez family 5, and to families 0, 3 and 4 of its own accountsubscribes to other players’ families
an id translation for its own Steam idan id translation for any other id
client config, purchased offers, clan, skills, keepalive, link setupmatchmaking and every other service

So each player keeps their own save. Items, currencies and progress are written on the install of the player who owns them.

Joining a host

A guest’s Sunrise opens its own BAP link to the host. The link differs from a game link in two ways:

  1. The keys come from a key exchange. Each side makes a fresh P-256 key pair. The guest sends its public key in its hello, and the host answers with its own. Both sides mix a secret hash of the join code into the derived keys. A guest with another join code derives other keys, so the host cannot read its frames.
  2. The hello carries a compatibility summary. The host compares it with its own record before it admits the guest.

The host checks these in order. The first difference refuses the guest:

checkthe two installs must share
buildthe same Sunrise DLL file
join codethe same join_code, or both empty
cheatsboth on or both off; a cheat mod or client.cheats counts as on
modsthe same mods, versions and mod files
contentthe same installed packages and mod packages

The guest sees one line that names the difference, for example “Co-op refused: the host runs a different Sunrise build.” The code is src/state/coop/compatibility.cpp.

After the guest is admitted, it reports its own SignOn keys to the host on the encrypted link. The host keeps them per account, so the guest’s game can open its own links to the host.

Two games on one PC

Peers tell machines apart by the game’s machine id. To run two games on one PC, give the second one a nonzero machine_id in its settings. Sunrise then writes that value over the game’s cached machine id, and frees the game’s single-instance guard so the second game can start. Two PCs need neither.

Friends, invitations and chat

The game asks Steam for friends, presence, invitations and lobby chat. Sunrise answers from the host’s player directory:

  • Friends. Every player connected to the same host is a friend.
  • Presence. Each player’s public profile and equipment are published to the others, so the roster and inspect screens show them.
  • Invitations. An invite reaches the other player as a Sunrise dialog, “Fireteam invitation”, with Accept and Decline. Accept hands the invitation to the game.
  • Fireteam chat. Lobby chat messages go through the host to every member of the lobby. A message holds at most 4 KiB.

Rewards

The host sees every incident and world interaction in a shared activity. It sends a guest’s rewardable events to that guest’s Sunrise, which grants them from its own save:

eventwhat the guest’s install does
world interactionthe same grant rules as solo play
killadvances the guest’s bounties; the host adds the bubble, which only its generated world can name

An event stays queued on the host until it reaches the transport.

Shared activities

All members of one activity share the host’s mission state. The host publishes every Auth state and script output to each member, and a member who joins late arrives at the running state. See The Activity Host for how bubbles are granted.

Sunrise-only services

Sunrise links use five BAP services the game never sends. A frame with one of these ids from the game is answered locally and never forwarded.

servicewhat it carries
0x8001a guest’s social sync: its invites, chat and receipt cursors
0x8002the host’s reply: that guest’s friends, invites and chat
0x8003a notice that the guest’s feed changed
0x8004one reward event for the guest’s install
0x8005the guest’s SignOn keys, after its link is admitted

Client hooks

Co-op adds three client hooks, installed only when co-op is on. They are listed on Client hooks.