GodotSteam / MultiplayerPeer

An ecosystem of tools for Godot Engine and Valve's Steam. For the Windows, Linux, and Mac platforms.
https://godotsteam.com
MIT License
3 stars 2 forks source link

Unable to join another lobby with SteamMultiplayerPeer after calling close(). #3

Open PeanutButterRat opened 6 months ago

PeanutButterRat commented 6 months ago

Describe the bug SteamMultiplayerPeer will complain that the user is still in a lobby even after calling close(). This prevents the user from joining another lobby and forces the creation of another SteamMultiplayerPeer object.

To Reproduce Steps to reproduce the behavior:

  1. Create a script that with two buttons: the first should create a lobby through SteamMultiplayerPeer.create_lobby() and the second should close the connection with SteamMultiplayerPeer.close().
  2. Click the first button to create a lobby.
  3. Click the second button to close the peer.
  4. Click the first button again to create a different lobby. An error in the console should pop up stating that the user is already in a lobby.

Expected behavior I expect the multiplayer peer to create a different lobby and connect the user to that one instead.

Screenshots Initial state before joining a lobby. image After clicking on "Create" which calls SteamMultiplayerPeer.create_lobby() and updates the lobby ID. image After clicking on "Leave" which calls SteamMultiplayerPeer.close() and clears the lobby ID. image After clicking on "Create" again. Notice that the lobby ID is still "None". image The error that is displayed in the terminal. image

Desktop (please complete the following information):

Version of Godot: Godot Engine v4.3.dev.custom_build.d00734053

Version of GodotSteam: GodotSteam Multiplayer Peer 4.8 (Module) (Latest Version)

Additional context I think the fix is very simple, just add a line to reset the lobby_state in the close method back to disconnected. image

Gramps commented 6 months ago

Hey there! I've still not used the MultiplayerPeer stuff but yeah, it should definitely reset that, I'd think. I'll check it out!

PeanutButterRat commented 6 months ago

After cross referencing with ENetMultiplayerPeer, it looks like some other state should probably be reset as well such as flushing any incoming packets. https://github.com/godotengine/godot/blob/b7feebefabc2d48b0d4794cd31fc141f1caecc5c/modules/enet/enet_multiplayer_peer.cpp#L294

Gramps commented 6 months ago

Yeah, looks like there are a few big differences indeed. Seems like something that should be patched in.