From 573d8cf7274415a4d4105ba440dc6e6be0e39d7a Mon Sep 17 00:00:00 2001 From: dingo Date: Tue, 14 Apr 2026 23:42:28 -0400 Subject: [PATCH] fix(spectate): move Game signal connections to top of _ready, null-safe IIDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Game.state_updated (and other game signals) now connected before any UI setup that could error. Previously they were at line ~340, after hand spin button setup — if anything between _configure_hand_spin_buttons and those connects threw, spectators would never receive live state pushes (no player actions to trigger ACK-based updates as fallback) - _rebuild_hand now uses str(raw) if raw != null else "" for IID extraction; card.get("instanceId", "") returns null (not the default) when the key exists with a null value, which would error on append to Array[String] Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- .../origin-client/scenes/game/game_screen.gd | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index f66cfed..5ca595e 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -302,6 +302,16 @@ const ANIM_ALIASES : Dictionary = { # ── Lifecycle ───────────────────────────────────────────────────────────────── func _ready() -> void: + # Connect critical game signals first — before anything that could error — + # so state pushes are never missed even if later setup fails. + Game.state_updated.connect(_on_state_updated) + Game.game_over.connect(_on_game_over) + Game.session_abandoned.connect(_on_session_abandoned) + Game.opponent_inactive.connect(_on_opponent_inactive) + Game.inactive_warning.connect(_on_inactive_warning) + Game.both_idle_warning.connect(_on_both_idle_warning) + Game.player_eliminated.connect(_on_player_eliminated) + _setup_environment() _apply_camera() _init_cursor_nodes() @@ -337,14 +347,6 @@ func _ready() -> void: Chat.set_bubble_visible(true) Chat.set_bubble_host(_chat_bubble_host) - Game.state_updated.connect(_on_state_updated) - Game.game_over.connect(_on_game_over) - Game.session_abandoned.connect(_on_session_abandoned) - Game.opponent_inactive.connect(_on_opponent_inactive) - Game.inactive_warning.connect(_on_inactive_warning) - Game.both_idle_warning.connect(_on_both_idle_warning) - Game.player_eliminated.connect(_on_player_eliminated) - if Game.is_spectating: _is_spectating = true _setup_spectator_ui() @@ -4453,7 +4455,8 @@ func _rebuild_hand(hand: Array) -> void: # Build new IID list. var new_iids : Array[String] = [] for card: Dictionary in hand: - new_iids.append(card.get("instanceId", "") as String) + var raw_iid := card.get("instanceId") + new_iids.append(str(raw_iid) if raw_iid != null else "") if new_iids == _cached_hand_iids: _refresh_hand_selection() return