Skip to content

Commit 9559330

Browse files
committed
Merge pull request #91011 from Faless/mp/fix_disconnect_on_change
[MP] Fix `disconnect_peer` not doing the proper cleanup
2 parents 6cd2876 + c6be5f1 commit 9559330

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

modules/multiplayer/scene_multiplayer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,11 @@ void SceneMultiplayer::_del_peer(int p_id) {
425425

426426
void SceneMultiplayer::disconnect_peer(int p_id) {
427427
ERR_FAIL_COND(multiplayer_peer.is_null() || multiplayer_peer->get_connection_status() != MultiplayerPeer::CONNECTION_CONNECTED);
428-
if (pending_peers.has(p_id)) {
429-
pending_peers.erase(p_id);
430-
} else if (connected_peers.has(p_id)) {
431-
connected_peers.erase(p_id);
432-
}
428+
// Block signals to avoid emitting peer_disconnected.
429+
bool blocking = is_blocking_signals();
430+
set_block_signals(true);
431+
_del_peer(p_id);
432+
set_block_signals(blocking);
433433
multiplayer_peer->disconnect_peer(p_id);
434434
}
435435

0 commit comments

Comments
 (0)