Improve multiplayer sync and controls responsiveness

- force host snapshot on round-end transitions to prevent client desync/timeouts\n- add smoother non-host snapshot reconciliation and higher snapshot cadence\n- send periodic input heartbeats for remote control freshness\n- allow bomb placement while moving for local and multiplayer players\n- keep host-only next-round restart flow in-match
This commit is contained in:
Mike Müller 2026-03-08 12:03:56 +01:00
parent 82a124f900
commit 7b2357b915

View File

@ -860,12 +860,12 @@ function applySnapshot(snapshot) {
rebuildFireLookup();
}
function broadcastSnapshot() {
function broadcastSnapshot(force = false) {
if (!network.isHost || state.mode !== "multiplayer" || state.screen !== "game") {
return;
}
const t = now();
if (t - network.lastSnapshotSentAt < 1 / SNAPSHOT_RATE) {
if (!force && t - network.lastSnapshotSentAt < 1 / SNAPSHOT_RATE) {
return;
}
network.lastSnapshotSentAt = t;
@ -1371,9 +1371,10 @@ function checkDeaths() {
function evaluateOutcome() {
if (state.status !== "running") {
return;
return false;
}
let endedThisFrame = false;
const alivePlayers = state.players.filter((player) => player.alive);
if (state.mode === "single") {
@ -1406,8 +1407,10 @@ function evaluateOutcome() {
}
if (state.status === "ended") {
endedThisFrame = true;
openMenu();
}
return endedThisFrame;
}
function updateNonHostClient(dt) {
@ -1521,10 +1524,10 @@ function updateGame(dt) {
collectPowerup(player);
}
evaluateOutcome();
const endedThisFrame = evaluateOutcome();
if (state.mode === "multiplayer" && network.isHost) {
broadcastSnapshot();
broadcastSnapshot(endedThisFrame);
}
}