ソースを参照

Don't reset MultiplayerAPI when setting same peer.

A GDScript call to:
`multiplayer.network_peer.some_prop = true`
seems to transalte to:
```
var temp = multiplayer.network_peer
temp.some_prop = true
multiplayer.network_peer = temp
```
Which caused the MultiplayerAPI to be resetted.
The call to set_network_peer is now ignored if the peer that's beeing
set is the same as the currently set one.
Fabio Alessandrelli 6 年 前
コミット
60d235622d
1 ファイル変更2 行追加0 行削除
  1. 2 0
      core/io/multiplayer_api.cpp

+ 2 - 0
core/io/multiplayer_api.cpp

@@ -132,6 +132,8 @@ void MultiplayerAPI::set_root_node(Node *p_node) {
 
 void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_peer) {
 
+	if (p_peer == network_peer) return; // Nothing to do
+
 	if (network_peer.is_valid()) {
 		network_peer->disconnect("peer_connected", this, "_add_peer");
 		network_peer->disconnect("peer_disconnected", this, "_del_peer");