Spectator fix

This commit is contained in:
dingo
2026-04-15 13:35:15 -04:00
parent 7a987e4347
commit f966643e31
3 changed files with 208 additions and 47 deletions
+16 -3
View File
@@ -80,7 +80,11 @@ func _clear_state() -> void:
## 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() and not state.is_empty():
if session_id.is_empty():
return
if is_spectating:
_request_spectator_state()
elif not state.is_empty():
send_ready()
@@ -89,8 +93,14 @@ func start_spectating(sid: String) -> void:
is_spectating = true
state = {}
session_id = sid
_request_spectator_state()
func _request_spectator_state() -> void:
if session_id.is_empty():
return
Network.request("game.spectate",
{ "sessionId": sid },
{ "sessionId": session_id },
func(_t: String, p: Variant) -> void:
if debug_output:
print("[Game] <<< game.spectate.ack")
@@ -389,7 +399,10 @@ func request_sync() -> void:
if session_id.is_empty(): return
if debug_output:
print("[Game] requesting full state sync")
_fetch_state()
if is_spectating:
_request_spectator_state()
else:
_fetch_state()
func _player_by_id(account_id: String) -> Dictionary: