extends SceneTree ## Prints the address AppFlow would connect to, resolved through the same ## ServerInfo (built-in default + res://serverlist.txt). Used by ## script/live_smoke_test.sh so the port precheck can never drift from the ## client connect target. Never opens a connection or reads credentials. ## ## env: MT_SERVER_INDEX (default 0), MT_SERVER_CHANNEL (default: the first ## channel listed for that server, matching the login screen default). ## stdout: one line "SERVER_ADDRESS {json}". exit 2 when unresolvable. const ServerInfoRes = preload("res://net/serverinfo.gd") func _init() -> void: var serverinfo := ServerInfoRes.new() serverinfo.load_file("res://serverlist.txt") var index := int(OS.get_environment("MT_SERVER_INDEX")) if OS.has_environment("MT_SERVER_INDEX") else 0 var server: Dictionary = serverinfo.server(index) if server.is_empty(): printerr("SERVER_ADDRESS: server index %d is not in serverinfo" % index) quit(2) return var channels: Array = server.get("channels", [1]) var channel := int(channels[0]) if not channels.is_empty() else 1 if OS.has_environment("MT_SERVER_CHANNEL"): channel = int(OS.get_environment("MT_SERVER_CHANNEL")) if not channels.has(channel): printerr("SERVER_ADDRESS: channel %d is not listed for server %d" % [channel, index]) quit(2) return var address: Dictionary = serverinfo.address(index, channel) address["server_index"] = index address["channel"] = channel print("SERVER_ADDRESS " + JSON.stringify(address)) quit(0)