Rewrite the online session to play the server's rooms

Session now runs only the room this screen is in. It plays ahead of the server
with its own controls, guesses everyone else's, confirms ticks against the
server's frames and rewinds on a wrong guess. It keeps its lead by playing a
little faster or slower as the server says how early its controls arrive,
resends an edit the server dropped, and checks the server's checksums.

Gone with the peer-to-peer design: the host's decisions, the second arena game,
the view swapping and spectating (to come back through the server).
SAB_NET_STATS logs how it's keeping up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-11-08 02:18:53 -05:00
1 parent dadfff189d
commit 3b65cb575f
4 files changed
+406 -1296

No files matched your search

+1 -11
View File
@@ -137,10 +137,8 @@ static bool frame_run(bool isDrawn = true)
Session& session = game.session;
for (; frameClock.accumulator >= TICK; frameClock.accumulator -= TICK)
{
// Online, this screen's own work happens in the game it shows (the arena while it plays or watches a queued
// game), and the session runs the shared games, taking this screen's controls; otherwise each fighter on this
// Online, the session runs the room this screen is in, taking its controls; otherwise each fighter on this
// screen takes its device's. Watching, they do nothing.
session.view_enter(game);
game.menu.update(game);
if (session.is_wanted(game))
{
@@ -148,20 +146,16 @@ static bool frame_run(bool isDrawn = true)
bool isHeld = game.menu.isOpen || game.chat.isOpen || session.is_watching();
Controls controls =
game.input.controls_get(DEVICE_KEYBOARD, game.camera, own.center_get(), own.slot, isHeld);
session.view_leave(game);
session.update(game, controls);
game.input.tick_end();
session.view_enter(game);
if (session.isViewChanged)
{
session.isViewChanged = false;
game.camera = game.cameraPrevious = camera_target_get(game);
}
presentation_update(game);
session.view_leave(game);
continue;
}
session.view_leave(game);
for (int i = 0; i < game.sim.fighterCount; i++)
{
Fighter& fighter = game.sim.fighters[i];
@@ -176,11 +170,7 @@ static bool frame_run(bool isDrawn = true)
game.settings.update(game);
game.alpha = frameClock.accumulator / TICK;
if (isDrawn)
{
session.view_enter(game);
game_draw(game);
session.view_leave(game);
}
return !game.input.isQuit;
}