mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 22:53:01 +00:00
MultiplayerAPI: Fix disconnect errors when passing invalid peer
Fixes #34634.
This commit is contained in:
parent
9d3424f61d
commit
3cbfb11460
@ -139,6 +139,9 @@ void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_pee
|
||||
|
||||
if (p_peer == network_peer) return; // Nothing to do
|
||||
|
||||
ERR_FAIL_COND_MSG(p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED,
|
||||
"Supplied NetworkedMultiplayerPeer must be connecting or connected.");
|
||||
|
||||
if (network_peer.is_valid()) {
|
||||
network_peer->disconnect("peer_connected", this, "_add_peer");
|
||||
network_peer->disconnect("peer_disconnected", this, "_del_peer");
|
||||
@ -150,8 +153,6 @@ void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_pee
|
||||
|
||||
network_peer = p_peer;
|
||||
|
||||
ERR_FAIL_COND_MSG(p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED, "Supplied NetworkedNetworkPeer must be connecting or connected.");
|
||||
|
||||
if (network_peer.is_valid()) {
|
||||
network_peer->connect("peer_connected", this, "_add_peer");
|
||||
network_peer->connect("peer_disconnected", this, "_del_peer");
|
||||
|
Loading…
Reference in New Issue
Block a user