Skip to content

Split screen: the players come together on their own - #705

Draft
Piktrip wants to merge 15 commits into
Dittobyte:mainfrom
Piktrip:feat/684-split-session
Draft

Piktrip wants to merge 15 commits into
Dittobyte:mainfrom
Piktrip:feat/684-split-session

Conversation

@Piktrip

@Piktrip Piktrip commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

What it changes

Build step 2 of the design in #701. It builds on #692 (split screen): the last four commits are this change, the ones before them are #692's.

Split screen started the game once per player, and the players then met by hand: each one walked to the PC and went through the Link Play menu, host first. In a new game that is not possible at all, because the game unlocks that menu later and the first cave has no PC. Now the players come together on their own once each has loaded their save.

  • Runtime (shared): two more [split] keys, meet and together (runtime/include/nxrt/split.h, play_split.cpp, CONFIG.md). Both are off unless whoever starts the group sets them; shared code only carries them.
  • Game layer, core/pkp_split_session.cpp: the game has one Link Play session manager, and its multiplayer menu only makes requests of it. With meet the module makes the same three requests the menu makes for "Local connection" without a password, on the game thread: window 1 opens a session once its player is in the world, the other windows search and join, and search again while window 1 is not there yet. No menu is opened and nothing is pressed for the player. The requests do not ask for the menu's unlock, so a group can meet in the first minutes of a new game. A player who leaves the session is not brought back.
  • together: the game lets a visitor arrive at the PC, wherever the host is. With this key a visitor is taken to where the first player stands, by the game's own warp of a player (the one its script command for moving a player calls), once the game reads the visitor's input again; both games then show the two side by side. If the visitor is found far from the first player a moment later, it is warped again, three times at most.
  • Game layer, ui/pkp_wait_screen.{h,cpp}: a waiting screen over the whole picture (two lines of text, a row of squares that light up in turn) that any feature can show and hide. A joining window shows it from its first search until its player is there, so nobody plays on in a world they are about to leave or sees the stop at the PC. It ends on its own after the time the caller gives.
  • Launcher: two switches on the split screen page, both on by default: Join player 1 automatically and, with it, Start next to player 1. With the first one off the page names the Link Play menu entries as before. Translated in all nine languages.
  • In Split screen: two to four players on one PC #692's branch: main's new [pad] controller (the one controller that plays) is not applied in a split screen window, which already plays the one pad [split] pad names. With a controller chosen there, every window whose pad is another one got no input.

Part of #684.

For players

  • CHANGELOG.md ## Unreleased has an entry (Before / Now / Still not), or this change is not player-facing
  • Needs Set up again / Finish update: Finish update, the runtime changed and the game is linked again. Shaders and saves are kept. No new hook site: the module calls game functions, it hooks none.
  • Rebuilds shaders: no

Pros

  • Two players can start a new game together: both create their character, and the second one is then brought into the first one's world and to their side without any menu.
  • It uses the game's own interfaces: the session manager's requests and the game's warp. No menu is driven by button presses, and no hook site is added, so the game code is not lifted again for it.
  • A session opened this way is an ordinary Link Play session: the game saves before it opens, shows its own "came to visit" notice and applies its own rules.
  • Off unless asked for: without [split] meet the module does nothing, and the launcher's first switch gives the manual way back.
  • The waiting screen is a module of its own, free for other features that hold the player for a moment.

Cons

  • The stop at the PC is still there, only covered: the game lets the visitor arrive at the PC, places it there once more a few seconds later and only then reads its input again. The warp is made at that moment, so the waiting screen stays up a little longer than the trip itself.
  • Start next to player 1 is the players' call. The module does not know whether the first player can be reached from the PC, so with the switch on a visitor is taken to the first player at every start, also in a later game where walking there would do.
  • Every player still goes through their own start first: the title, their save or the opening with the character editor. They are brought together when each one walks in the world.
  • Visitors play by the game's online rules (Spectator Mode in the story areas unless the existing experimental Link Play switches are on). One story for the group, abilities and quests are the later build steps of Seamless co-op and split screen: design draft #701.
  • The session is a local one without a password, as the launcher keeps the group on this PC.
  • The waiting screen's lines and the notices are English, like the game layer's other notices.

For the repo owner

  • The game functions the module calls, how they were found and what is still open (the visitor's arrival steps, three and four players, other stages) are in the mappings repository: split/SPLIT-SESSION-RE.md, sections 2, 5 and 8.
  • Not in this PR: the story gating at the mask site and the menu lock from Seamless co-op and split screen: design draft #701. They fit on top of it.
  • [split] meet and together have no row in the game's Settings screen, like the other [split] keys: they are a start's role, set by the launcher.
  • pkp_split_session.cpp holds the session requests and the visitor's placing. If the placing grows (choosing where a visitor arrives would remove the stop at the PC), it is a file of its own.
  • Debt seen on the way, not changed here: runtime/src/gfx/platform.cpp on main has a literal NUL byte inside a char literal (line 599, out[0] = '<NUL>'), which clang warns about; '\0' was probably meant.

Piktrip and others added 15 commits November 15, 2026 11:58
platform.h gets display_work_area, place_window, window_rect and
set_window_focusable, in their own file (platform_place.cpp), plus
WindowDesc::focusable and InitOptions::place_windows. Split screen (Dittobyte#684)
needs them: each of its two windows sits without a frame in its half of
the work area, and the second must not take the keyboard focus when it
appears.

place_window asks first whether the window system lets a window choose
its position (Wayland does not), and sets position and size in two passes:
KWin fits each request to the window as it is at that moment, so one pass
left the window on the wrong display's width or pushed out of the lower
half. With place_windows set, X11 is asked for before Wayland on Linux.

Co-Authored-By: Claude <noreply@anthropic.com>
Split screen (Dittobyte#684) runs the game twice on one PC, the two processes
meeting through Link Play on 127.0.0.1, after pokopia-native's design.
Whoever starts the pair says which window a process is with the new
[split] keys (window, layout, pad, mute, first_account; nxrt/split.h and
CONFIG.md); nothing is a player setting, so no file is written.

play_split.cpp keeps the window in its half of the work area and puts it
back when anything moves it; the settings' window mode, monitor move,
window size and Alt+Enter do nothing there. A window plays one
controller, by its place in connection order, or none: poll_pads, the
prompts and the status read the pads through own_pads. One of the two
windows never has the focus, so [audio] mute_unfocused does not apply and
a window is silent only when [split] mute says so.

play::display() tells the game's start-up that the window is placed by
play mode and whether it may take the focus, so pkp_main.cpp needs no
knowledge of split screen.

Co-Authored-By: Claude <noreply@anthropic.com>
The second player's save can be a copy of the first player's, and the
host refuses a visitor with its own player UUID (error 9005), as it did
with the UUID older builds shared. In split screen's second window a save
whose UUID equals the one of the first player's save ([split]
first_account) gets a new one in the same places, before the game reads
it. The UUID is read from its plain copy in SYDAT and only taken when the
bytes there are a version 4 UUID.

The rewrite the repair already did is now swap_uuid, with the UUID to
replace as a parameter; the repair of the shared UUID uses it unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
Link Play gets a Split screen section (Dittobyte#684): top and bottom or side by
side, what player 1 plays with, who player 2 is, the second window's
sound, and Start split screen. play_split starts the game twice: the
active profile hosts in the first window, a second profile visits it on
127.0.0.1 on a port of the pair's own. Each window gets its role in its
environment (the runtime's [split] keys and the second player's account),
so pkp.ini is not touched. The second window ends with the first.

split.rs prepares the pair. The second player is a profile other than
the active and the first one; without one, "Player 2" is made. A second
player without a save starts from a copy of the first player's
(saveimport::copy_account), since a new game cannot visit before its
story opens Link Play. The second window writes its own log and a fresh
copy of controls.ini under split/, and only reads the pipeline cache.

The first player's account folder comes from the profile's uid.
saveimport::locate is not used for it alone: for the first profile it
takes the newest .meta in the save folder, which can be another
profile's once there are several.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
A Link Play session holds four players, so split screen (Dittobyte#684) takes up
to four windows. [split] window is 1 to 4 and the new [split] count says
how many share the screen: with three the first window keeps a half and
the other two share the rest, with four each has a quarter. split_part
replaces split_half. Every window but the first appears without taking
the keyboard focus.

Every visiting window may hold a copy of the first player's save, so the
check for a player UUID of its own runs in windows 2 to 4. The new UUID
is random, so two copies differ from each other too.

Co-Authored-By: Claude <noreply@anthropic.com>
The Split screen section asks how many play. Every player after the
first is a profile of their own, picked on the page or made at the start
("Player 2", "Player 3", ...), and nobody plays twice. A player without
a save starts from a copy of the first player's. Each visiting window
has its own folder (split/<window>/) for its log and its copy of
controls.ini, and all of them end with the first window.

With the first player on the keyboard and mouse, the controllers start
at the second player.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
[pad] controller picks the one controller that plays on a PC with other people's pads connected. A split screen window
already plays one pad only, the one [split] pad names, and every window reads the same number from controls.ini: with a
controller chosen there, each window whose pad is another one got no input at all.

Co-Authored-By: Claude <noreply@anthropic.com>
A layer over the whole picture with two lines of text and a row of squares that light up in turn, for the moments a
feature holds the player until something outside their own game is ready. Any feature shows and hides it; it ends on
its own after the time the caller gives, so a caller that never comes back does not leave a covered game.

Co-Authored-By: Claude <noreply@anthropic.com>
[split] meet: the first window opens a local Link Play session once its player is in the world, and the other windows
look for it and join. The game layer makes the three requests the game's multiplayer menu makes of the session manager
(open, search, join), on the game thread, so no menu is opened and nothing is pressed for the player. A window that
joins shows the waiting screen until it is there.

[split] together: a player who joined is taken to where the first player stands, by the game's own warp of a player,
once the game reads their input again. The game lets a visitor arrive at the PC, which the first cave of a new game
cannot be reached from.

Both keys are off unless the starter sets them.

Co-Authored-By: Claude <noreply@anthropic.com>
Two switches on the split screen page, both on by default: Join player 1 automatically (the runtime's [split] meet) and,
with it, Start next to player 1 ([split] together). With the first one off the page names the Link Play menu entries as
before.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
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