From 767244d8148b5f7b59f42cd4223d4f064a75c1a2 Mon Sep 17 00:00:00 2001 From: Chris Bell Date: Thu, 7 Aug 2025 12:13:58 -0500 Subject: [PATCH] ai slop lobby fix test --- splunk/networking/steam-manager.gd | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/splunk/networking/steam-manager.gd b/splunk/networking/steam-manager.gd index 7dcfe3c..12b0115 100644 --- a/splunk/networking/steam-manager.gd +++ b/splunk/networking/steam-manager.gd @@ -96,7 +96,7 @@ func init_steam() -> bool: func setup_multiplayer_peer(is_host: bool = false) -> void: ## ADDED: Check if a peer is already active before creating a new one. - if multiplayer.multiplayer_peer and multiplayer.get_connection_status() != MultiplayerPeer.CONNECTION_DISCONNECTED: + if multiplayer.multiplayer_peer and multiplayer.multiplayer_peer.get_connection_status() != MultiplayerPeer.CONNECTION_DISCONNECTED: print("[Multiplayer] Peer already exists. Disconnecting old one.") multiplayer.multiplayer_peer.close() @@ -104,7 +104,7 @@ func setup_multiplayer_peer(is_host: bool = false) -> void: if is_host: print("[Multiplayer] Creating Host...") - var err = peer.create_host() ## REMOVED: Channel is handled by the peer automatically now. + var err = peer.create_host(0) ## REMOVED: Channel is handled by the peer automatically now. if err != OK: print("[Multiplayer] !!! Failed to create host. Error: %s" % err) return @@ -160,9 +160,17 @@ func _on_lobby_joined(this_lobby_id: int, permissions: int, locked: bool, respon print("Successfully joined lobby: %s" % lobby_id) get_lobby_members() - # is_server() is the most reliable check for host status - if not multiplayer.is_server(): - setup_multiplayer_peer() # Setup as client + # FIXED: Use Steam.getLobbyOwner() to determine if we should be host or client + var lobby_owner_id = Steam.getLobbyOwner(lobby_id) + var am_i_owner = (lobby_owner_id == steam_id) + + print("[Multiplayer] Lobby Owner: %s, My Steam ID: %s, Am I Owner?: %s" % [lobby_owner_id, steam_id, am_i_owner]) + + if not am_i_owner: + print("[Multiplayer] I am not the lobby owner, setting up as client...") + setup_multiplayer_peer(false) # Setup as client + else: + print("[Multiplayer] I am the lobby owner, but multiplayer peer should already be set up as host.") else: ## ADDED: Log the specific reason for the join failure. print("!!! Failed to join lobby. Reason: %s" % get_join_fail_reason(response)) @@ -245,16 +253,19 @@ func log_multiplayer_info(): print("## Multiplayer Status:") if multiplayer.multiplayer_peer: print(" - Peer State: Active") - print(" - Connection Status: %s" % get_connection_status_string(multiplayer.get_connection_status())) + print(" - Connection Status: %s" % get_connection_status_string(multiplayer.multiplayer_peer.get_connection_status())) print(" - Is Server?: %s" % multiplayer.is_server()) print(" - My Peer ID: %s" % multiplayer.get_unique_id()) - print(" - Connected Peer IDs: %s" % multiplayer.get_peer_ids()) + print(" - Connected Peer IDs: %s" % multiplayer.get_peers()) else: print(" - Peer State: Inactive (null)") print("\n## Steam Lobby Info:") print(" - In Lobby?: %s" % (lobby_id != 0)) print(" - Lobby ID: %s" % lobby_id) + if lobby_id != 0: + print(" - Lobby Owner Steam ID: %s" % Steam.getLobbyOwner(lobby_id)) + print(" - My Steam ID: %s" % steam_id) print(" - Lobby Members Array (%s):" % lobby_members.size()) for member in lobby_members: print(" - %s (%s)" % [member.steam_name, member.steam_id])