feat(multiplayer): add Steam transport foundation

This commit is contained in:
Josh Creek
2026-08-21 18:52:07 +01:00
parent f2b72394de
commit 6bafdc7794
16 changed files with 402 additions and 31 deletions
+26
View File
@@ -0,0 +1,26 @@
extends "res://tests/test_case.gd"
const EnetTransport = preload("res://scripts/enet_transport.gd")
const SteamBootstrap = preload("res://scripts/steam_bootstrap.gd")
const SteamTransport = preload("res://scripts/steam_transport.gd")
func test_enet_is_available_without_steam() -> void:
var transport = EnetTransport.new()
assert_true(transport.is_available(), "ENet remains available in a stock Godot build")
assert_eq(transport.transport_id(), "enet", "stable selection key")
func test_steam_development_app_id_has_a_safe_default() -> void:
assert_eq(SteamBootstrap.app_id(), SteamBootstrap.SPACEWAR_APP_ID, "Spacewar is the local-development default")
assert_true(SteamBootstrap.app_id() > 0, "Steam bootstrap never uses an invalid app ID")
func test_stock_build_refuses_steam_without_falling_back_to_enet() -> void:
var transport = SteamTransport.new()
if transport.is_available():
assert_true(true, "a custom Steam build is validated by the separate Steam export check")
return
var result: Dictionary = transport.create_server(7777, 2)
assert_eq(int(result.error), ERR_UNAVAILABLE, "Steam request fails explicitly when its custom build is absent")
assert_true(not result.has("peer") or result.peer == null, "an unavailable Steam request never returns an ENet peer")
assert_true(not transport.unavailable_reason().is_empty(), "failure tells an operator what is missing")
+20
View File
@@ -0,0 +1,20 @@
extends Node
# This is intentionally separate from the stock test suite: it is run only
# by scripts/verify_steam_templates.sh, where failing to supply a custom Steam
# executable is a setup failure rather than a regression in the ENet build.
func _ready() -> void:
var failures: Array[String] = []
if not OS.has_feature("steam"):
failures.append("custom export is missing the steam feature")
if not ClassDB.class_exists("SteamMultiplayerPeer"):
failures.append("SteamMultiplayerPeer is missing")
if not Engine.has_singleton("Steam") and not Engine.has_singleton("SteamServer"):
failures.append("neither Steam nor SteamServer singleton is available")
if failures.is_empty():
print("STEAM TEMPLATE SMOKE PASS")
get_tree().quit(0)
return
for failure in failures:
printerr("STEAM TEMPLATE SMOKE FAIL: %s" % failure)
get_tree().quit(1)
+6
View File
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://tests/steam_template_smoke.gd" id="1"]
[node name="SteamTemplateSmoke" type="Node"]
script = ExtResource("1")