Fix 3+ player custom lobby state/ready sync
This commit is contained in:
@@ -148,6 +148,7 @@ func join(lid: String, deck_id: String, password: String,
|
||||
lobby["guestAccountId"] = str(d.get("guestAccountId", ""))
|
||||
lobby["guestDisplayName"] = str(d.get("guestDisplayName", ""))
|
||||
lobby["hasGuest"] = true
|
||||
lobby["additionalPlayers"] = d.get("additionalPlayers", [])
|
||||
if on_success.is_valid(): on_success.call(d),
|
||||
func(code: String, msg: String) -> void:
|
||||
print("[CustomLobby] ERR join ", code, " ", msg)
|
||||
@@ -287,6 +288,13 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
var d := payload as Dictionary
|
||||
var gid : String = str(d.get("guestAccountId", ""))
|
||||
var gname: String = str(d.get("guestDisplayName", gid.substr(0, 8)))
|
||||
# Keep local lobby snapshot current so LobbyRoomScreen can render seat updates.
|
||||
if d.has("additionalPlayers"):
|
||||
lobby["additionalPlayers"] = d.get("additionalPlayers", [])
|
||||
if str(lobby.get("guestAccountId", "")).is_empty():
|
||||
lobby["guestAccountId"] = gid
|
||||
lobby["guestDisplayName"] = gname
|
||||
lobby["hasGuest"] = true
|
||||
guest_joined.emit(gid, gname)
|
||||
|
||||
"game.custom.lobby_updated":
|
||||
@@ -304,13 +312,18 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
var d := payload as Dictionary
|
||||
var hr : bool = d.get("hostReady", false)
|
||||
var gr : bool = d.get("guestReady", false)
|
||||
if d.has("additionalPlayers"):
|
||||
lobby["additionalPlayers"] = d.get("additionalPlayers", [])
|
||||
if is_host:
|
||||
i_am_ready = hr
|
||||
partner_ready = gr
|
||||
elif is_additional:
|
||||
# Additional players (3rd+) are neither host nor guest.
|
||||
# Their own ready state is managed by the set_ready ack — don't overwrite it.
|
||||
# partner_ready reflects whether the two main slots are ready.
|
||||
# Additional players (3rd+) resolve self-ready from the participant snapshot when present.
|
||||
if d.has("additionalPlayers"):
|
||||
for ap: Dictionary in (d.get("additionalPlayers", []) as Array):
|
||||
if str(ap.get("accountId", "")) == Auth.user_id:
|
||||
i_am_ready = bool(ap.get("isReady", false))
|
||||
break
|
||||
partner_ready = hr and gr
|
||||
else:
|
||||
# First guest
|
||||
|
||||
@@ -310,6 +310,8 @@ func _on_guest_joined(_guest_account_id: String, _guest_display_name: String) ->
|
||||
|
||||
func _on_ready_status_changed(host_ready: bool, guest_ready: bool) -> void:
|
||||
_update_ready_indicators(host_ready, guest_ready)
|
||||
# Additional-player readiness can change via ready_status pushes.
|
||||
_refresh_display()
|
||||
|
||||
|
||||
func _on_rules_updated(new_rules: Dictionary) -> void:
|
||||
|
||||
Reference in New Issue
Block a user