mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 00:14:00 +00:00
feat(multiplayer): handle planned shutdowns on clients
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user