mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
fix multiplayer snapshot disconnect race
This commit is contained in:
@@ -264,6 +264,11 @@ func send_input(bytes: PackedByteArray) -> void:
|
||||
|
||||
|
||||
func send_snapshot(peer_id: int, bytes: PackedByteArray) -> void:
|
||||
# A server-side disconnect can leave peer_id in get_peers() until the
|
||||
# current poll batch settles. Do not enter Godot's RPC path for that stale
|
||||
# target; NetSim repeats this check at fire time for delayed sends.
|
||||
if not NetworkManager.can_send_to_peer(peer_id):
|
||||
return
|
||||
_track_sent(bytes.size())
|
||||
NetSim.send(func() -> void: _snapshot.rpc_id(peer_id, bytes), peer_id)
|
||||
|
||||
@@ -477,6 +482,7 @@ func _disconnect_abusive_peer(peer_id: int, reason: String) -> void:
|
||||
# which does not carry the peer, the reason or a timestamp into the log
|
||||
# stream a container actually captures.
|
||||
ServerLog.warn("peer_kicked", {"peer_id": peer_id, "reason": reason})
|
||||
NetworkManager.invalidate_peer(peer_id)
|
||||
_peer_input_state.erase(peer_id)
|
||||
if multiplayer.multiplayer_peer is ENetMultiplayerPeer:
|
||||
multiplayer.multiplayer_peer.disconnect_peer(peer_id)
|
||||
|
||||
Reference in New Issue
Block a user