diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-01-03 14:33:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-03 14:33:25 +0100 |
commit | 0783874ff20cd868cb926ea1c283e6309ee6f077 (patch) | |
tree | e144bf2ac52ae9712702ea0e22b49385938727dc | |
parent | 136846a6ec4f01eea4ecfbd5b624b1145730288c (diff) | |
parent | 3cbfb11460b6106f89ce7ce80c329fc003002103 (diff) |
Merge pull request #34782 from akien-mga/multiplayerapi-set_network_peer-invalid
MultiplayerAPI: Fix disconnect errors when passing invalid peer
-rw-r--r-- | core/io/multiplayer_api.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index aaa7eb64c9..2708cb8c01 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -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"); |