Fix N-player lobby: premature start, unready for seat 3+, stale reconnect

GameLobbyReadyHandler: change else→else if (isGuest) so additional
players (seat 3+) no longer incorrectly set GuestReady=true.  When
Player 3 called ready the else-branch marked GuestReady, making the
all-ready check fire as soon as the host was also ready — starting
the game without Player 2 ever clicking ready, leaving 2/3 clients
in a starting state and 1 stuck in the lobby.
Also: update DeckId for additional players in AdditionalPlayersJson;
push ready_status to additional player connections.

GameUnreadyHandler: handle additional players (seat 3+) by updating
isReady in AdditionalPlayersJson via JsonNode; push unready status to
all participants including additional players.  Previously threw
NOT_IN_LOBBY for anyone beyond the primary guest.

Game.gd: guard _on_auth_reconnect with 'state is non-empty' so stale
session_id values from ended games don't trigger spurious game.ready
calls.  Also clear session_id in the game.over handler so it never
lingers past the end of a session.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-26 09:18:45 -04:00
co-authored by Claude Happy
parent 9c7dc098aa
commit 497e1c3172
3 changed files with 65 additions and 11 deletions
+6 -4
View File
@@ -71,10 +71,11 @@ func _clear_state() -> void:
## Called on every auth_success (initial login AND reconnects).
## If we have an active session, resend game.ready so the server
## re-registers this connection and we get state updates again.
## If we have both an active session_id AND live game state, resend game.ready
## so the server re-registers this connection and we get state updates again.
## The state check prevents sending stale session IDs from games that already ended.
func _on_auth_reconnect(_uid: String, _dn: String) -> void:
if not session_id.is_empty():
if not session_id.is_empty() and not state.is_empty():
send_ready()
@@ -584,7 +585,8 @@ func _on_server_push(type: String, payload: Variant) -> void:
var wd : int = int(d.get("winnerRankDelta", 0))
var ld : int = int(d.get("loserRankDelta", 0))
var outcomes : Array = d.get("playerOutcomes", []) as Array
state = {} # Clear stale state so a new GameScreen calls send_ready() on the next match
session_id = "" # Clear so _on_auth_reconnect doesn't resend game.ready for an ended game
state = {} # Clear stale state so a new GameScreen calls send_ready() on the next match
game_over.emit(winner, wc, wd, ld, outcomes)
"game.session_abandoned":