mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
fix: fail closed for unsupported allocated transport
This commit is contained in:
@@ -51,6 +51,15 @@ func _ready() -> void:
|
||||
ServerLog.configure(String(config.get_value("log-level")))
|
||||
var port := int(config.get_value("port"))
|
||||
var max_clients := int(config.get_value("max-clients"))
|
||||
var allocated_mode := bool(config.get_value("allocated-mode"))
|
||||
var assigned_transport := String(config.get_value("transport"))
|
||||
# Hosted SDR is not wired into the Godot transport layer yet. Refuse the
|
||||
# allocated launch rather than silently opening an ENet endpoint that does
|
||||
# not match the signed assignment's transport contract.
|
||||
if allocated_mode and assigned_transport != NetworkManager.TRANSPORT_ENET:
|
||||
printerr("cosmic-clash-server: allocated transport '%s' is not supported by this build" % assigned_transport)
|
||||
get_tree().quit(1)
|
||||
return
|
||||
|
||||
NetworkManager.client_connected.connect(_on_client_connected)
|
||||
NetworkManager.client_disconnected.connect(_on_client_disconnected)
|
||||
@@ -66,8 +75,13 @@ func _ready() -> void:
|
||||
ServerLog.info("server_started", {
|
||||
"port": port, "max_clients": max_clients, "log_level": ServerLog.level_name(),
|
||||
"min_players": int(config.get_value("min-players")),
|
||||
"max_matches": int(config.get_value("max-matches")),
|
||||
"max_matches": 1 if allocated_mode else int(config.get_value("max-matches")),
|
||||
"arena_rotation": String(config.get_value("arena-rotation")),
|
||||
"allocated_mode": allocated_mode,
|
||||
"match_id": String(config.get_value("match-id")) if allocated_mode else "",
|
||||
"server_id": String(config.get_value("server-id")) if allocated_mode else "",
|
||||
"region": String(config.get_value("region")) if allocated_mode else "",
|
||||
"transport": assigned_transport if allocated_mode else NetworkManager.TRANSPORT_ENET,
|
||||
})
|
||||
_last_physics_frame = Engine.get_physics_frames()
|
||||
|
||||
@@ -81,7 +95,7 @@ func _install_match_loop() -> void:
|
||||
loop.name = "ServerMatchLoop"
|
||||
loop.min_players = int(config.get_value("min-players"))
|
||||
loop.start_countdown_seconds = float(config.get_value("start-countdown"))
|
||||
loop.max_matches = int(config.get_value("max-matches"))
|
||||
loop.max_matches = 1 if bool(config.get_value("allocated-mode")) else int(config.get_value("max-matches"))
|
||||
loop.rotation_mode = String(config.get_value("arena-rotation"))
|
||||
get_tree().root.add_child.call_deferred(loop)
|
||||
|
||||
@@ -118,4 +132,3 @@ func _on_player_joined(peer_id: int, player_name: String) -> void:
|
||||
|
||||
func _on_player_left(peer_id: int) -> void:
|
||||
ServerLog.info("player_left", {"peer_id": peer_id, "roster": MatchNet.roster.size()})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user