File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ extends Node
22
33const SERVER_PORT : int = 5466
44
5+ const ERROR_INEXISTENT_ROOM : String = "There is no room with such id"
6+ const ERROR_GAME_ALREADY_STARTED : String = "Game already started"
7+
58var rooms : Dictionary = {}
69var players_room : Dictionary = {}
710
@@ -50,7 +53,14 @@ remote func create_room(info: Dictionary) -> void:
5053remote func join_room (room_id : int , info : Dictionary ) -> void :
5154 var sender_id : int = get_tree ().get_rpc_sender_id ()
5255
53- _add_player_to_room (room_id , sender_id , info )
56+ if not rooms .keys ().has (room_id ):
57+ rpc_id (sender_id , "show_error" , ERROR_INEXISTENT_ROOM )
58+ get_tree ().network_peer .disconnect_peer (sender_id )
59+ elif rooms [room_id ].state == STARTED :
60+ rpc_id (sender_id , "show_error" , ERROR_GAME_ALREADY_STARTED )
61+ get_tree ().network_peer .disconnect_peer (sender_id )
62+ else :
63+ _add_player_to_room (room_id , sender_id , info )
5464
5565
5666func _add_player_to_room (room_id : int , id : int , info : Dictionary ) -> void :
You can’t perform that action at this time.
0 commit comments