GodotSteam / GodotSteam-Example-Project

An example project for GodotSteam and Godot version 3 / 4.
https://godotsteam.com
MIT License
88 stars 13 forks source link

Lobby server duplicates on the open lobby list pressed event #14

Open kAOSJK opened 4 months ago

kAOSJK commented 4 months ago

Hi,

I believe there is a small mistake on the method "_on_open_lobby_list_pressed" in the lobby.gd script in both godot 3 and 4 examples.

Each time the method "_on_open_lobby_list_pressed" is called, servers are added to the "lobbies_list_vbox". But this list is not freed before the "Steam.requestLobbyList()" call, so after few open/close lots of duplicates are added more and more.

The method "_on_refresh_pressed" on the same script just below does actually free the "lobbies_list_vbox" children before the "Steam.requestLobbyList()" call and it works as intended without duplicates.

Please check the screenshot for more informations.

Capture d’écran 2024-06-11 211219

kAOSJK commented 4 months ago

Rather than adding a clear of the server list before the request of lobby list, maybe it's better to just call the "_on_refresh_pressed" method as it is a refresh ? So that upon that that, the button is disabled during the process ?

Or maybe create a method refresh or something like that, which will be called in both "_on_refresh_pressed" and "_on_open_lobby_list_pressed" methods ?

Gramps commented 4 months ago

Hey again! Yeah, I guess that doesn't take into account someone leaving that example and coming back; it should indeed clear the list if there are any entries. I will get this fixed up. Cheers!

And yeah, I think since they are basically the same thing, they should share some common function.