refactor: pass match data to game server launcher

* Pass full match data to InstanceLauncher instead of only match type
* Track server threads by match ID rather than thread instance ID
* Update child completion handling to use match ID
This commit is contained in:
2026-08-11 23:40:09 -05:00
parent 4dd0af2916
commit 2ac444162f
2 changed files with 9 additions and 9 deletions

View File

@@ -6,7 +6,7 @@ var port_range_end: int = 5010
var threads: Dictionary = Dictionary() 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": if port == "-1":
call_deferred("_child_finished", id, -1) call_deferred("_child_finished", id, -1)
return return
@@ -50,9 +50,9 @@ func find_free_port(start_port: int = 1024, end_port: int = 65535) -> int:
return -1 return -1
func launch_game_server(mode: String) -> String: func launch_game_server(match_data: Dictionary) -> String:
var thread := Thread.new() var thread := Thread.new()
var thread_id := str( thread.get_instance_id() ) var _thread_id := str( thread.get_instance_id() )
var port := str( var port := str(
find_free_port( find_free_port(
port_range_start, port_range_start,
@@ -62,11 +62,11 @@ func launch_game_server(mode: String) -> String:
thread.start( thread.start(
_wait_for_child.bind( _wait_for_child.bind(
thread_id,
port, port,
mode match_data.type,
match_data.match_id
) )
) )
threads.set(thread_id, thread) threads.set(match_data.match_id, thread)
return port return port

View File

@@ -42,7 +42,7 @@ func _launch_game_server(
client1: Dictionary, client1: Dictionary,
client2: Dictionary client2: Dictionary
) -> void: ) -> 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": if port == "-1":
# TODO: Alert clients that the game wont be created due to # TODO: Alert clients that the game wont be created due to
# server reaching number of allowed instances. # server reaching number of allowed instances.