push project up

This commit is contained in:
2026-08-07 03:02:53 -05:00
parent 48acb406a7
commit de0da3de6e
40 changed files with 986 additions and 0 deletions

7
globals/globals.gd Normal file
View File

@@ -0,0 +1,7 @@
extends Node
var game_data: GameData
var game_state: GameState
var lobby_data: LobbyData
var multiplayer_data: MultiplayerData

1
globals/globals.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://biu64hvcxb1su

View File

@@ -0,0 +1,69 @@
extends Node
var port_range_start: int = 5000
var port_range_end: int = 5010
var threads: Dictionary = Dictionary()
func _wait_for_child(id: String, port: String, mode: String) -> void:
if port == "-1":
call_deferred("_child_finished", id, -1)
return
var output := []
var exit_code := OS.execute(
"./game.sh", ["--", "server_" + port, "game", mode],
output,
true
)
call_deferred("_child_finished", id, exit_code)
func _child_finished(id: String, exit_code: int) -> void:
var thread: Thread = threads.get(id)
if not thread: return
push_warning("Game Server [ %s ] Exited: %d" % [id, exit_code])
thread.wait_to_finish()
threads.erase(id)
func is_port_free(port: int) -> bool:
var server := TCPServer.new()
var state := server.listen(port)
match state:
OK:
server.stop()
return true
_:
return false
func find_free_port(start_port: int = 1024, end_port: int = 65535) -> int:
for port in range(start_port, end_port + 1):
if is_port_free(port):
return port
return -1
func launch_game_server(mode: String) -> 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
)
)
thread.start(
_wait_for_child.bind(
thread_id,
port,
mode
)
)
threads.set(thread_id, thread)
return port

View File

@@ -0,0 +1 @@
uid://cru35twp27pa4