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()
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

View File

@@ -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.