Spectator fix
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user