Fix 3 multiplayer bugs: type error, reconnect, lobby count

- game_screen.gd: fix Parser Error on line 270 — use 'as Environment'
  cast instead of ': Variant' annotation for WorldEnvironment.environment
- Game.gd: auto-resend game.ready on auth_success reconnect so the
  game session is restored when the WebSocket reconnects mid-game
- lobby_browser_row.gd: show real N/Max player count instead of
  hardcoded "1/2" / "2/2"
- CustomLobbyDto: add MaxPlayers, CurrentPlayerCount, GameMode, TeamCount
- GameListCustomLobbiesHandler: compute currentPlayerCount from
  GuestAccountId + AdditionalPlayersJson; pass new fields to DTO

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:05:40 -04:00
co-authored by Claude Happy
parent 9d4302cc6c
commit 9c7dc098aa
5 changed files with 43 additions and 7 deletions
+9
View File
@@ -59,6 +59,7 @@ var _state_version : int = -1
func _ready() -> void:
Network.message_received.connect(_on_server_push)
Auth.session_expired.connect(_clear_state)
Auth.auth_success.connect(_on_auth_reconnect)
func _clear_state() -> void:
@@ -69,6 +70,14 @@ func _clear_state() -> void:
_state_version = -1
## 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.
func _on_auth_reconnect(_uid: String, _dn: String) -> void:
if not session_id.is_empty():
send_ready()
## Start spectating a game session. State is applied from the server ack.
func start_spectating(sid: String) -> void:
is_spectating = true
@@ -14,14 +14,15 @@ var _has_password: bool = false
func setup(lobby: Dictionary, has_deck: bool) -> void:
var has_pw : bool = lobby.get("rules", {}).get("hasPassword", false)
var has_guest : bool = lobby.get("hasGuest", false)
var host_name : String = lobby.get("hostDisplayName", "?")
var cur_p : int = int(lobby.get("currentPlayerCount", 1 + (1 if lobby.get("hasGuest", false) else 0)))
var max_p : int = int(lobby.get("maxPlayers", 2))
_lobby_id = str(lobby.get("lobbyId", ""))
_has_password = has_pw
name_label.text = lobby.get("lobbyName", "?")
host_label.text = "Host: %s [%s]" % [host_name, "2/2" if has_guest else "1/2"]
host_label.text = "Host: %s [%d/%d]" % [host_name, cur_p, max_p]
password_icon.visible = has_pw
join_btn.disabled = not has_deck
join_btn.disabled = not has_deck or cur_p >= max_p
join_btn.pressed.connect(func(): join_requested.emit(_lobby_id, _has_password), CONNECT_ONE_SHOT)
@@ -267,7 +267,7 @@ func _ready() -> void:
func _process(delta: float) -> void:
var env := $WorldEnvironment.environment
var env := $WorldEnvironment.environment as Environment
if env != null:
env.sky_rotation.y += delta * SKY_ROTATION_SPEED