diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-08-19 16:48:08 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-08-19 16:48:41 -0300 |
commit | 1add52b55e038a4fa789c64f3919f7fcab808e91 (patch) | |
tree | dd7878449dd1d2301684a5e5aa34b8466744b168 /scene/main/node.h | |
parent | 56fa741b7a729bd5a00cff17e4382af547de92ad (diff) |
Brand new networked multiplayer
Diffstat (limited to 'scene/main/node.h')
-rw-r--r-- | scene/main/node.h | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/scene/main/node.h b/scene/main/node.h index 761725286e..3568da2ab0 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -60,6 +60,15 @@ public: NETWORK_MODE_SLAVE }; + enum RPCMode { + + RPC_MODE_DISABLED, //no rpc for this method, calls to this will be blocked (default) + RPC_MODE_REMOTE, // using rpc() on it will call method / set property in all other peers + RPC_MODE_SYNC, // using rpc() on it will call method / set property in all other peers and locally + RPC_MODE_MASTER, // usinc rpc() on it will call method on wherever the master is, be it local or remote + RPC_MODE_SLAVE, // usinc rpc() on it will call method for all slaves, be it local or remote + }; + struct Comparator { bool operator()(const Node* p_a, const Node* p_b) const { return p_b->is_greater_than(p_a); } @@ -75,6 +84,7 @@ private: }; + struct Data { String filename; @@ -108,8 +118,8 @@ private: NetworkMode network_mode; Node *network_owner; - Set<StringName> allowed_remote_calls; - Set<StringName> allowed_remote_set; + Map<StringName,RPCMode> rpc_methods; + Map<StringName,RPCMode> rpc_properties; // variables used to properly sort the node when processing, ignored otherwise @@ -160,8 +170,10 @@ private: Array _get_children() const; Array _get_groups() const; - Variant _remote_call_reliable_bind(const Variant** p_args, int p_argcount, Variant::CallError& r_error); - Variant _remote_call_unreliable_bind(const Variant** p_args, int p_argcount, Variant::CallError& r_error); + Variant _rpc_bind(const Variant** p_args, int p_argcount, Variant::CallError& r_error); + Variant _rpc_unreliable_bind(const Variant** p_args, int p_argcount, Variant::CallError& r_error); + Variant _rpc_id_bind(const Variant** p_args, int p_argcount, Variant::CallError& r_error); + Variant _rpc_unreliable_id_bind(const Variant** p_args, int p_argcount, Variant::CallError& r_error); friend class SceneTree; @@ -358,20 +370,25 @@ public: NetworkMode get_network_mode() const; bool is_network_master() const; - void allow_remote_call(const StringName& p_method); - void disallow_remote_call(const StringName& p_method); + void rpc_config(const StringName& p_method,RPCMode p_mode); // config a local method for RPC + void rset_config(const StringName& p_property,RPCMode p_mode); // config a local property for RPC + + void rpc(const StringName& p_method,VARIANT_ARG_LIST); //rpc call, honors RPCMode + void rpc_unreliable(const StringName& p_method,VARIANT_ARG_LIST); //rpc call, honors RPCMode + void rpc_id(int p_peer_id,const StringName& p_method,VARIANT_ARG_LIST); //rpc call, honors RPCMode + void rpc_unreliable_id(int p_peer_id,const StringName& p_method,VARIANT_ARG_LIST); //rpc call, honors RPCMode - void allow_remote_set(const StringName& p_property); - void disallow_remote_set(const StringName& p_property); + void rpcp(int p_peer_id,bool p_unreliable,const StringName& p_method,const Variant** p_arg,int p_argcount); - void remote_call_reliable(const StringName& p_method,VARIANT_ARG_DECLARE); - void remote_call_reliablep(const StringName& p_method,const Variant** p_arg,int p_argcount); + void rset(const StringName& p_property, const Variant& p_value); //remote set call, honors RPCMode + void rset_unreliable(const StringName& p_property,const Variant& p_value); //remote set call, honors RPCMode + void rset_id(int p_peer_id,const StringName& p_property,const Variant& p_value); //remote set call, honors RPCMode + void rset_unreliable_id(int p_peer_id,const StringName& p_property,const Variant& p_value); //remote set call, honors RPCMode - void remote_call_unreliable(const StringName& p_method,VARIANT_ARG_DECLARE); - void remote_call_unreliablep(const StringName& p_method,const Variant** p_arg,int p_argcount); + void rsetp(int p_peer_id,bool p_unreliable,const StringName& p_property,const Variant& p_value); - void remote_set_reliable(const StringName& p_property,const Variant& p_value); - void remote_set_unreliable(const StringName& p_property,const Variant& p_value); + bool can_call_rpc(const StringName& p_method) const; + bool can_call_rset(const StringName& p_property) const; Node(); |