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:
parent
82a124f900
commit
7b2357b915
13
src/game.js
13
src/game.js
@ -860,12 +860,12 @@ function applySnapshot(snapshot) {
|
|||||||
rebuildFireLookup();
|
rebuildFireLookup();
|
||||||
}
|
}
|
||||||
|
|
||||||
function broadcastSnapshot() {
|
function broadcastSnapshot(force = false) {
|
||||||
if (!network.isHost || state.mode !== "multiplayer" || state.screen !== "game") {
|
if (!network.isHost || state.mode !== "multiplayer" || state.screen !== "game") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const t = now();
|
const t = now();
|
||||||
if (t - network.lastSnapshotSentAt < 1 / SNAPSHOT_RATE) {
|
if (!force && t - network.lastSnapshotSentAt < 1 / SNAPSHOT_RATE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
network.lastSnapshotSentAt = t;
|
network.lastSnapshotSentAt = t;
|
||||||
@ -1371,9 +1371,10 @@ function checkDeaths() {
|
|||||||
|
|
||||||
function evaluateOutcome() {
|
function evaluateOutcome() {
|
||||||
if (state.status !== "running") {
|
if (state.status !== "running") {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let endedThisFrame = false;
|
||||||
const alivePlayers = state.players.filter((player) => player.alive);
|
const alivePlayers = state.players.filter((player) => player.alive);
|
||||||
|
|
||||||
if (state.mode === "single") {
|
if (state.mode === "single") {
|
||||||
@ -1406,8 +1407,10 @@ function evaluateOutcome() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state.status === "ended") {
|
if (state.status === "ended") {
|
||||||
|
endedThisFrame = true;
|
||||||
openMenu();
|
openMenu();
|
||||||
}
|
}
|
||||||
|
return endedThisFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateNonHostClient(dt) {
|
function updateNonHostClient(dt) {
|
||||||
@ -1521,10 +1524,10 @@ function updateGame(dt) {
|
|||||||
collectPowerup(player);
|
collectPowerup(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluateOutcome();
|
const endedThisFrame = evaluateOutcome();
|
||||||
|
|
||||||
if (state.mode === "multiplayer" && network.isHost) {
|
if (state.mode === "multiplayer" && network.isHost) {
|
||||||
broadcastSnapshot();
|
broadcastSnapshot(endedThisFrame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user