diff --git a/globals/instance_launcher.gd b/globals/instance_launcher.gd index 2990e1e..5f73eaf 100644 --- a/globals/instance_launcher.gd +++ b/globals/instance_launcher.gd @@ -6,7 +6,7 @@ var port_range_end: int = 5010 var threads: Dictionary = Dictionary() -func _wait_for_child(id: String, port: String, mode: String) -> void: +func _wait_for_child(port: String, mode: String, id: String) -> void: if port == "-1": call_deferred("_child_finished", id, -1) return @@ -50,10 +50,10 @@ func find_free_port(start_port: int = 1024, end_port: int = 65535) -> int: return -1 -func launch_game_server(mode: String) -> String: - var thread := Thread.new() - var thread_id := str( thread.get_instance_id() ) - var port := str( +func launch_game_server(match_data: Dictionary) -> String: + var thread := Thread.new() + var _thread_id := str( thread.get_instance_id() ) + var port := str( find_free_port( port_range_start, port_range_end @@ -62,11 +62,11 @@ func launch_game_server(mode: String) -> String: thread.start( _wait_for_child.bind( - thread_id, port, - mode + match_data.type, + match_data.match_id ) ) - threads.set(thread_id, thread) + threads.set(match_data.match_id, thread) return port diff --git a/scenes/data_bridge/lobby_data.gd b/scenes/data_bridge/lobby_data.gd index 5aded5d..d8f23c7 100644 --- a/scenes/data_bridge/lobby_data.gd +++ b/scenes/data_bridge/lobby_data.gd @@ -42,7 +42,7 @@ func _launch_game_server( client1: Dictionary, client2: Dictionary ) -> void: - var port: String = InstanceLauncher.launch_game_server(match_entry.data.type) + var port: String = InstanceLauncher.launch_game_server(match_entry.data) if port == "-1": # TODO: Alert clients that the game wont be created due to # server reaching number of allowed instances.