From 393998b48a49cb11bd53d0236fdd4f812442ea6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=A2=D1=80=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Sun, 2 Aug 2026 00:13:59 +0300 Subject: [PATCH] multiplayer fix: more strict smoke trace sync --- src/main.js | 10 +++++++--- src/projectiles.js | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main.js b/src/main.js index 25ad40f..92f8559 100644 --- a/src/main.js +++ b/src/main.js @@ -41,6 +41,7 @@ let winner; const seenClientExplosions = new Map(); const carveQueue = []; let clientCollapseState = null; +let nextTraceId = 1; let score = 0; let round = 0; @@ -392,7 +393,10 @@ function executeFire(player, a, p, weaponIndex) { weapon.ammo -= 1; player.shotsFired++; projectileType.create(projectile, player, weapon, px, py, a, p, wind) - .forEach(x => projectiles.push(x)); + .forEach(x => { + x.traceId = nextTraceId++; + projectiles.push(x); + }); state = 'shoot'; } @@ -952,7 +956,7 @@ function broadcastWorld() { napalmParticles: napalmParticles.map(p => ({x: p.x, y: p.y})), fireCells: fireCells.map(f => ({x: f.x, y: f.y, timeLeft: f.timeLeft})), smokeParticles: smokeParticles.map(s => ({x: s.x, y: s.y, vx: s.vx, vy: s.vy, alpha: s.alpha, lifetime: s.lifetime})), - trajectories: trajectories.slice(-300).filter((_, i) => i % 3 === 0).map(t => ({x: t.x, y: t.y, a: t.a, c: t.c})), + trajectories: trajectories.slice(-300).filter((_, i) => i % 3 === 0).map(t => ({x: t.x, y: t.y, a: t.a, c: t.c, traceId: t.traceId})), }; netBroadcast({type: HOST_MSG.WORLD, snap}); } @@ -2413,7 +2417,7 @@ function drawTrajectories() { for (let i=1; i ({...x, a:255})) + .map(x => ({...x, a:255, traceId: projectile.traceId})) .forEach(x => trajectories.push(x)); } @@ -269,7 +269,7 @@ export const PROJECTILE_TYPES = { trajectory .slice(0, trajectory.length-1) - .map(x => ({...x, a:255})) + .map(x => ({...x, a:255, traceId: projectile.traceId})) .forEach(x => trajectories.push(x)); }