feat(multiplayer): handle planned shutdowns on clients

This commit is contained in:
Josh Creek
2026-09-01 16:43:47 +01:00
parent b24f9fc448
commit 4e88ea80f3
5 changed files with 25 additions and 1 deletions
+4 -1
View File
@@ -53,6 +53,7 @@ class PlayerInfo:
var roster: Dictionary = {} # peer_id (int) -> PlayerInfo. Never contains peer 1 (the server; §1.1 decision 2 — dedicated servers are never a player).
var local_player_name := "Player"
var last_server_shutdown_reason := ""
# Set by the assignment connection path. Direct-IP/community-server joins keep
# this empty for backwards compatibility; allocated matches carry the opaque
# signed authorisation in hello rather than putting it in the endpoint URL.
@@ -80,6 +81,7 @@ func _ready() -> void:
func _on_connected_to_server() -> void:
roster.clear()
last_server_shutdown_reason = ""
if _auto_hello:
_hello.rpc_id(1, NetCodec.PROTOCOL_VERSION, SimConstants.TICK_HZ, local_player_name, join_authorisation)
@@ -511,7 +513,8 @@ func _rejected(reason: String) -> void:
@rpc("authority", "call_remote", "reliable")
func _server_shutdown(reason: String) -> void:
server_shutdown.emit(_sanitize_shutdown_reason(reason))
last_server_shutdown_reason = _sanitize_shutdown_reason(reason)
server_shutdown.emit(last_server_shutdown_reason)
@rpc("authority", "call_remote", "reliable")