Fix multiplayer state: stacked players, ghosts after rejoin; add a build stamp
checkpoint / checkpoint (push) Successful in 1m40s

- Clients now hard-snap to the server's spawn position on the first
  snapshot. player.gd starts everyone on the fixed PlayerSpawn marker but
  the server spreads spawns out -- so one client saw players ~1m apart
  (correct) while the other saw them stacked (its local player still on the
  marker, never corrected because the ~1m drift was under the old 1.5m
  threshold). Threshold also tightened to 0.6m.
- game.gd._exit_tree() closes the ENet connection cleanly when you leave a
  world, so the server fires peer_disconnected and removes your player.
  Before, leaving just changed scene and the server never knew -- everyone
  else kept seeing a frozen "ghost".
- server.gd: once-a-second sweep of players whose peer is no longer
  connected, as a backstop for a missed disconnect.
- Build stamp: checkpoint_ops bakes "<PC> <commit>" into
  application/config/version at export; the menu and in-world HUD show
  "build PC3 <hash>" so playtest reports aren't ambiguous about which
  build is running.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015jtxAiu5dAW4WxCNdGkrkJ
This commit is contained in:
2026-09-06 00:39:30 +00:00
parent da4e1420ee
commit 3639fb3132
3 changed files with 57 additions and 5 deletions
+16
View File
@@ -102,11 +102,27 @@ func _physics_process(_delta: float) -> void:
if not is_running:
return
tick += 1
if tick % PHYSICS_HZ == 0:
_sweep_stale_players()
_broadcast_snapshot()
if tick % STATUS_WRITE_EVERY == 0:
_write_status()
## Backstop for _on_peer_disconnected: once a second, drop any player whose
## peer is no longer connected (covers a missed disconnect signal, so a
## rejoining client never sees a frozen ghost of its old self).
func _sweep_stale_players() -> void:
var connected := multiplayer.get_peers()
for peer_id in players.keys():
if peer_id not in connected:
var p: Node = players[peer_id]
if is_instance_valid(p):
p.queue_free()
players.erase(peer_id)
print("[Server] swept stale player %d (%d left)" % [peer_id, players.size()])
func _broadcast_snapshot() -> void:
var snap := {"tick": tick, "players": {}}
for peer_id in players: