feat(net): F3 network overlay - ping graph and where lag comes from (you, opponent, server)

This commit is contained in:
Benjamin Oezcan
2026-11-19 14:30:40 +01:00
parent a8d6158384
commit 695cf77afc
8 changed files with 251 additions and 4 deletions

View File

@@ -122,6 +122,10 @@
const FLAGS = ['DE', 'AT', 'CH', 'GB', 'US', 'FR', 'ES', 'IT', 'NL', 'PL', 'TR', 'RU', 'BR', 'JP', 'KR', 'XX'];
const flagHtml = c => `<span class="fl fl-${FLAGS.includes(c) ? c : 'XX'}"></span>`;
const lobby = net.enabled ? RC.Lobby({ net }) : null;
// F3 (or ?net): network overlay - ping graph + where lag comes from (netstats.js / netoverlay.js)
const netStats = RC.NetStats();
const netOverlay = net.enabled ? RC.NetOverlay({ stats: netStats, net, t, mount: $('stage') }) : null;
if (netOverlay && DEV.has('net')) netOverlay.toggle(true);
const fx = Kit.fx();
const input = Kit.input({
@@ -764,7 +768,7 @@
const count = online ? Math.max(0, +online.countdown || 0) : 3.5;
F = { s, opp, training, exhibition: !!exhibition, online, tour: !!tour, brain: online ? null : RC.AI.create({ style: opp.style, skill, seed: seed + 5 }), count, beat: Math.ceil(count) + 1,
acc: [0, 0], accT: 0, banner: null, ended: false, oppAway: false };
if (online) F.nf = RC.NetFight({ net, seat: online.seat }); // the server runs the fight, we show it
if (online) { netStats.reset(); F.nf = RC.NetFight({ net, seat: online.seat, stats: netStats }); } // the server runs the fight, we show it
// dev: ?auto = AI drives the player too, ?ff=30 = fast-forward 30 s (screenshots, balancing)
if (DEV.has('auto')) F.auto = RC.AI.create({ style: 'brawler', skill: 0.7, seed: seed + 11 });
if (DEV.has('ff')) {