Internal methods in MultiplayerAPI start with _

This commit is contained in:
Fabio Alessandrelli 2018-05-08 11:49:57 +02:00
parent 234914c42c
commit e391b493d5
2 changed files with 25 additions and 25 deletions

View file

@ -47,11 +47,11 @@ void MultiplayerAPI::set_root_node(Node *p_node) {
void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_peer) { void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_peer) {
if (network_peer.is_valid()) { if (network_peer.is_valid()) {
network_peer->disconnect("peer_connected", this, "add_peer"); network_peer->disconnect("peer_connected", this, "_add_peer");
network_peer->disconnect("peer_disconnected", this, "del_peer"); network_peer->disconnect("peer_disconnected", this, "_del_peer");
network_peer->disconnect("connection_succeeded", this, "connected_to_server"); network_peer->disconnect("connection_succeeded", this, "_connected_to_server");
network_peer->disconnect("connection_failed", this, "connection_failed"); network_peer->disconnect("connection_failed", this, "_connection_failed");
network_peer->disconnect("server_disconnected", this, "server_disconnected"); network_peer->disconnect("server_disconnected", this, "_server_disconnected");
clear(); clear();
} }
@ -61,11 +61,11 @@ void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_pee
ERR_FAIL_COND(p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED); ERR_FAIL_COND(p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED);
if (network_peer.is_valid()) { if (network_peer.is_valid()) {
network_peer->connect("peer_connected", this, "add_peer"); network_peer->connect("peer_connected", this, "_add_peer");
network_peer->connect("peer_disconnected", this, "del_peer"); network_peer->connect("peer_disconnected", this, "_del_peer");
network_peer->connect("connection_succeeded", this, "connected_to_server"); network_peer->connect("connection_succeeded", this, "_connected_to_server");
network_peer->connect("connection_failed", this, "connection_failed"); network_peer->connect("connection_failed", this, "_connection_failed");
network_peer->connect("server_disconnected", this, "server_disconnected"); network_peer->connect("server_disconnected", this, "_server_disconnected");
} }
} }
@ -458,29 +458,29 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p
} }
} }
void MultiplayerAPI::add_peer(int p_id) { void MultiplayerAPI::_add_peer(int p_id) {
connected_peers.insert(p_id); connected_peers.insert(p_id);
path_get_cache.insert(p_id, PathGetCache()); path_get_cache.insert(p_id, PathGetCache());
emit_signal("network_peer_connected", p_id); emit_signal("network_peer_connected", p_id);
} }
void MultiplayerAPI::del_peer(int p_id) { void MultiplayerAPI::_del_peer(int p_id) {
connected_peers.erase(p_id); connected_peers.erase(p_id);
path_get_cache.erase(p_id); //I no longer need your cache, sorry path_get_cache.erase(p_id); //I no longer need your cache, sorry
emit_signal("network_peer_disconnected", p_id); emit_signal("network_peer_disconnected", p_id);
} }
void MultiplayerAPI::connected_to_server() { void MultiplayerAPI::_connected_to_server() {
emit_signal("connected_to_server"); emit_signal("connected_to_server");
} }
void MultiplayerAPI::connection_failed() { void MultiplayerAPI::_connection_failed() {
emit_signal("connection_failed"); emit_signal("connection_failed");
} }
void MultiplayerAPI::server_disconnected() { void MultiplayerAPI::_server_disconnected() {
emit_signal("server_disconnected"); emit_signal("server_disconnected");
} }
@ -691,15 +691,15 @@ void MultiplayerAPI::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_network_unique_id"), &MultiplayerAPI::get_network_unique_id); ClassDB::bind_method(D_METHOD("get_network_unique_id"), &MultiplayerAPI::get_network_unique_id);
ClassDB::bind_method(D_METHOD("is_network_server"), &MultiplayerAPI::is_network_server); ClassDB::bind_method(D_METHOD("is_network_server"), &MultiplayerAPI::is_network_server);
ClassDB::bind_method(D_METHOD("get_rpc_sender_id"), &MultiplayerAPI::get_rpc_sender_id); ClassDB::bind_method(D_METHOD("get_rpc_sender_id"), &MultiplayerAPI::get_rpc_sender_id);
ClassDB::bind_method(D_METHOD("add_peer", "id"), &MultiplayerAPI::add_peer); ClassDB::bind_method(D_METHOD("_add_peer", "id"), &MultiplayerAPI::_add_peer);
ClassDB::bind_method(D_METHOD("del_peer", "id"), &MultiplayerAPI::del_peer); ClassDB::bind_method(D_METHOD("_del_peer", "id"), &MultiplayerAPI::_del_peer);
ClassDB::bind_method(D_METHOD("set_network_peer", "peer"), &MultiplayerAPI::set_network_peer); ClassDB::bind_method(D_METHOD("set_network_peer", "peer"), &MultiplayerAPI::set_network_peer);
ClassDB::bind_method(D_METHOD("poll"), &MultiplayerAPI::poll); ClassDB::bind_method(D_METHOD("poll"), &MultiplayerAPI::poll);
ClassDB::bind_method(D_METHOD("clear"), &MultiplayerAPI::clear); ClassDB::bind_method(D_METHOD("clear"), &MultiplayerAPI::clear);
ClassDB::bind_method(D_METHOD("connected_to_server"), &MultiplayerAPI::connected_to_server); ClassDB::bind_method(D_METHOD("_connected_to_server"), &MultiplayerAPI::_connected_to_server);
ClassDB::bind_method(D_METHOD("connection_failed"), &MultiplayerAPI::connection_failed); ClassDB::bind_method(D_METHOD("_connection_failed"), &MultiplayerAPI::_connection_failed);
ClassDB::bind_method(D_METHOD("server_disconnected"), &MultiplayerAPI::server_disconnected); ClassDB::bind_method(D_METHOD("_server_disconnected"), &MultiplayerAPI::_server_disconnected);
ClassDB::bind_method(D_METHOD("get_network_connected_peers"), &MultiplayerAPI::get_network_connected_peers); ClassDB::bind_method(D_METHOD("get_network_connected_peers"), &MultiplayerAPI::get_network_connected_peers);
ClassDB::bind_method(D_METHOD("set_refuse_new_network_connections", "refuse"), &MultiplayerAPI::set_refuse_new_network_connections); ClassDB::bind_method(D_METHOD("set_refuse_new_network_connections", "refuse"), &MultiplayerAPI::set_refuse_new_network_connections);
ClassDB::bind_method(D_METHOD("is_refusing_new_network_connections"), &MultiplayerAPI::is_refusing_new_network_connections); ClassDB::bind_method(D_METHOD("is_refusing_new_network_connections"), &MultiplayerAPI::is_refusing_new_network_connections);

View file

@ -66,11 +66,11 @@ public:
// Called by Node.rset // Called by Node.rset
void rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_property, const Variant &p_value); void rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_property, const Variant &p_value);
void add_peer(int p_id); void _add_peer(int p_id);
void del_peer(int p_id); void _del_peer(int p_id);
void connected_to_server(); void _connected_to_server();
void connection_failed(); void _connection_failed();
void server_disconnected(); void _server_disconnected();
bool has_network_peer() const { return network_peer.is_valid(); } bool has_network_peer() const { return network_peer.is_valid(); }
Vector<int> get_network_connected_peers() const; Vector<int> get_network_connected_peers() const;