diff --git a/addons/netfox.extras/plugin.cfg b/addons/netfox.extras/plugin.cfg index aff8cb6f..63a73d82 100644 --- a/addons/netfox.extras/plugin.cfg +++ b/addons/netfox.extras/plugin.cfg @@ -3,5 +3,5 @@ name="netfox.extras" description="Game-specific utilities for Netfox" author="Tamas Galffy and contributors" -version="1.35.0" +version="1.35.1" script="netfox-extras.gd" diff --git a/addons/netfox.internals/plugin.cfg b/addons/netfox.internals/plugin.cfg index 362d935a..704e2df0 100644 --- a/addons/netfox.internals/plugin.cfg +++ b/addons/netfox.internals/plugin.cfg @@ -3,5 +3,5 @@ name="netfox.internals" description="Shared internals for netfox addons" author="Tamas Galffy and contributors" -version="1.35.0" +version="1.35.1" script="plugin.gd" diff --git a/addons/netfox.noray/plugin.cfg b/addons/netfox.noray/plugin.cfg index 8540cd4d..16afd4cc 100644 --- a/addons/netfox.noray/plugin.cfg +++ b/addons/netfox.noray/plugin.cfg @@ -3,5 +3,5 @@ name="netfox.noray" description="Bulletproof your connectivity with noray integration for netfox" author="Tamas Galffy and contributors" -version="1.35.0" +version="1.35.1" script="netfox-noray.gd" diff --git a/addons/netfox/network-time-synchronizer.gd b/addons/netfox/network-time-synchronizer.gd index 2807595e..7f591daf 100644 --- a/addons/netfox/network-time-synchronizer.gd +++ b/addons/netfox/network-time-synchronizer.gd @@ -162,14 +162,17 @@ func _loop() -> void: on_initial_sync.emit() while _active: + if multiplayer.is_server(): + return stop() + var sample := NetworkClockSample.new() _awaiting_samples[_sample_idx] = sample - + sample.ping_sent = _clock.get_time() _send_ping.rpc_id(1, _sample_idx) - + _sample_idx += 1 - + await get_tree().create_timer(sync_interval).timeout func _discipline_clock() -> void: diff --git a/addons/netfox/network-time.gd b/addons/netfox/network-time.gd index 67e39bb9..af6ef343 100644 --- a/addons/netfox/network-time.gd +++ b/addons/netfox/network-time.gd @@ -447,7 +447,7 @@ func start() -> int: _initial_sync_done = true # Remove clients from the synced cache when disconnected - multiplayer.peer_disconnected.connect(func(peer): _synced_peers.erase(peer)) + multiplayer.peer_disconnected.connect(_handle_peer_disconnect) # Set initial clock state _clock.set_time(NetworkTimeSynchronizer.get_time()) @@ -470,6 +470,9 @@ func stop() -> void: _state = _STATE_INACTIVE _synced_peers.clear() + if multiplayer.peer_disconnected.is_connected(_handle_peer_disconnect): + multiplayer.peer_disconnected.disconnect(_handle_peer_disconnect) + ## Check if the initial time sync is done. func is_initial_sync_done() -> bool: return _initial_sync_done @@ -583,6 +586,9 @@ func _notification(what) -> void: func _is_active() -> bool: return _state == _STATE_ACTIVE +func _handle_peer_disconnect(peer: int) -> void: + _synced_peers.erase(peer) + @rpc("any_peer", "reliable", "call_local") func _submit_sync_success() -> void: var peer_id := multiplayer.get_remote_sender_id() diff --git a/addons/netfox/plugin.cfg b/addons/netfox/plugin.cfg index 51a72c5a..1fa57059 100644 --- a/addons/netfox/plugin.cfg +++ b/addons/netfox/plugin.cfg @@ -3,5 +3,5 @@ name="netfox" description="Shared internals for netfox addons" author="Tamas Galffy and contributors" -version="1.35.0" +version="1.35.1" script="netfox.gd" diff --git a/addons/netfox/time/network-tickrate-handshake.gd b/addons/netfox/time/network-tickrate-handshake.gd index 5ee92e1e..e069f9b6 100644 --- a/addons/netfox/time/network-tickrate-handshake.gd +++ b/addons/netfox/time/network-tickrate-handshake.gd @@ -54,7 +54,7 @@ func run() -> void: ## [br][br] ## Called by [_NetworkTime], no need to call manually. func stop() -> void: - if multiplayer.is_server(): + if multiplayer.peer_connected.is_connected(_handle_new_peer): multiplayer.peer_connected.disconnect(_handle_new_peer) func _ready() -> void: