diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-08-19 18:44:09 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-08-19 18:44:09 -0300 |
commit | 2fa693273c4eca763a0d65385e1a44bd46dd715c (patch) | |
tree | c5a13fc10b02d16891269d87c4e0baf87cee977e | |
parent | 1add52b55e038a4fa789c64f3919f7fcab808e91 (diff) |
Many fixes to networking, demo should work now
-rw-r--r-- | modules/enet/networked_multiplayer_enet.cpp | 4 | ||||
-rw-r--r-- | scene/main/scene_main_loop.cpp | 14 |
2 files changed, 14 insertions, 4 deletions
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index e9a3a46e75..1e52083b6b 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -285,8 +285,8 @@ void NetworkedMultiplayerENet::poll(){ incoming_packets.push_back(packet); } else { //to someone else, specifically - ERR_CONTINUE(!peer_map.has(source)); - enet_peer_send(peer_map[source],0,packet.packet); + ERR_CONTINUE(!peer_map.has(target)); + enet_peer_send(peer_map[target],0,packet.packet); } } else { diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp index 53cc11359a..f025c5edfd 100644 --- a/scene/main/scene_main_loop.cpp +++ b/scene/main/scene_main_loop.cpp @@ -1760,6 +1760,17 @@ void SceneTree::_rpc(Node* p_from,int p_to,bool p_unreliable,bool p_set,const St ERR_FAIL(); } + if (p_to!=0 && !connected_peers.has(ABS(p_to))) { + if (p_to==get_network_unique_id()) { + ERR_EXPLAIN("Attempt to remote call/set yourself! unique ID: "+itos(get_network_unique_id())); + } else { + ERR_EXPLAIN("Attempt to remote call unexisting ID: "+itos(p_to)); + + } + + ERR_FAIL(); + } + NodePath from_path = p_from->get_path(); ERR_FAIL_COND(from_path.is_empty()); @@ -1816,7 +1827,6 @@ void SceneTree::_rpc(Node* p_from,int p_to,bool p_unreliable,bool p_set,const St } has_all_peers=false; - break; } } @@ -1990,10 +2000,10 @@ void SceneTree::_network_process_packet(int p_from, const Array& p_packet) { message.resize(2); message[0]=NETWORK_COMMAND_CONFIRM_PATH; message[1]=path; - network_peer->put_var(message); } break; case NETWORK_COMMAND_CONFIRM_PATH: { + ERR_FAIL_COND(p_packet.size()!=2); NodePath path = p_packet[1]; |