fix(multiplayer): harden reconnect lifecycle fencing

This commit is contained in:
Josh Creek
2026-09-03 13:24:52 +01:00
parent cee0163eac
commit 8c28374eb4
5 changed files with 62 additions and 8 deletions
+3 -2
View File
@@ -438,8 +438,9 @@ func _reserve_join_authorisation(token: String, peer_id: int) -> int:
var now := Time.get_unix_time_from_system()
var history: Dictionary = _join_history.get(token, {})
var lost_at := float(history.get("lost_at", 0.0))
if lost_at > 0.0 and now - lost_at > RECONNECT_GRACE_SECONDS:
return -1
if lost_at > 0.0:
if now < lost_at or now - lost_at > RECONNECT_GRACE_SECONDS:
return -1
var generation := int(history.get("generation", 0)) + 1
_join_history[token] = {"generation": generation, "lost_at": 0.0}
_active_join_peers[token] = peer_id