server: fixed bug that caused host client to disconnect when leaving lobby if they were the only connected client in the lobby

This commit is contained in:
2025-07-04 14:24:28 +02:00
parent b468a391f5
commit af763c89b3
6 changed files with 26 additions and 37 deletions
+8 -2
View File
@@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://gqrdpjslr4np"]
[gd_scene load_steps=5 format=3 uid="uid://gqrdpjslr4np"]
[ext_resource type="Script" uid="uid://p5gvnyhjqe6o" path="res://components/web_client_tcp.gd" id="1_feb5d"]
[ext_resource type="Script" uid="uid://c0cqkatyo4uj1" path="res://components/client_interface.gd" id="2_e2o6t"]
[ext_resource type="Script" uid="uid://utt8atbh7b2a" path="res://game_client.gd" id="3_feb5d"]
[sub_resource type="SystemFont" id="SystemFont_80nbo"]
font_names = PackedStringArray("IBM Plex Mono")
@@ -12,7 +13,7 @@ font_weight = 500
[node name="WebClientTCP" type="Node" parent="."]
script = ExtResource("1_feb5d")
[node name="ClientInterface" type="ColorRect" parent="." node_paths=PackedStringArray("client", "connect_button", "create_lobby_button", "join_lobby_button", "leave_lobby_button", "chat_message_input", "send_chat_message_button", "name_input", "lobby_code_input", "output")]
[node name="ClientInterface" type="ColorRect" parent="." node_paths=PackedStringArray("client", "game_client", "connect_button", "create_lobby_button", "join_lobby_button", "leave_lobby_button", "chat_message_input", "send_chat_message_button", "name_input", "lobby_code_input", "output")]
anchors_preset = 9
anchor_bottom = 1.0
offset_right = 362.0
@@ -20,6 +21,7 @@ grow_vertical = 2
color = Color(0.26, 0.2236, 0.230273, 1)
script = ExtResource("2_e2o6t")
client = NodePath("../WebClientTCP")
game_client = NodePath("../GameClient")
connect_button = NodePath("MarginContainer/VBoxContainer/VBoxContainer/ConnectButton")
create_lobby_button = NodePath("MarginContainer/VBoxContainer/VBoxContainer/CreateLobbyButton")
join_lobby_button = NodePath("MarginContainer/VBoxContainer/VBoxContainer/JoinLobbyButton")
@@ -112,6 +114,10 @@ size_flags_horizontal = 3
layout_mode = 2
text = "Send"
[node name="GameClient" type="Node" parent="." node_paths=PackedStringArray("web_client")]
script = ExtResource("3_feb5d")
web_client = NodePath("../WebClientTCP")
[connection signal="client_joined_lobby" from="WebClientTCP" to="ClientInterface" method="_on_web_client_tcp_client_joined_lobby"]
[connection signal="client_left_lobby" from="WebClientTCP" to="ClientInterface" method="_on_web_client_tcp_client_left_lobby"]
[connection signal="connected_to_lobby" from="WebClientTCP" to="ClientInterface" method="_on_web_client_tcp_connected_to_lobby"]