You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-26 15:46:23 +00:00
[Net] Move multiplayer to core subdir, split RPCManager.
Move multiplayer classes to "core/multiplayer" subdir. Move the RPCConfig and enums (TransferMode, RPCMode) to a separate file (multiplayer.h), and bind them to the global namespace. Move the RPC handling code to its own class (RPCManager). Renames "get_rpc_sender_id" to "get_remote_sender_id".
This commit is contained in:
@@ -539,10 +539,10 @@ bool Node::is_network_authority() const {
|
||||
|
||||
/***** RPC CONFIG ********/
|
||||
|
||||
uint16_t Node::rpc_config(const StringName &p_method, MultiplayerAPI::RPCMode p_rpc_mode, MultiplayerPeer::TransferMode p_transfer_mode, int p_channel) {
|
||||
uint16_t Node::rpc_config(const StringName &p_method, Multiplayer::RPCMode p_rpc_mode, Multiplayer::TransferMode p_transfer_mode, int p_channel) {
|
||||
for (int i = 0; i < data.rpc_methods.size(); i++) {
|
||||
if (data.rpc_methods[i].name == p_method) {
|
||||
MultiplayerAPI::RPCConfig &nd = data.rpc_methods.write[i];
|
||||
Multiplayer::RPCConfig &nd = data.rpc_methods.write[i];
|
||||
nd.rpc_mode = p_rpc_mode;
|
||||
nd.transfer_mode = p_transfer_mode;
|
||||
nd.channel = p_channel;
|
||||
@@ -550,7 +550,7 @@ uint16_t Node::rpc_config(const StringName &p_method, MultiplayerAPI::RPCMode p_
|
||||
}
|
||||
}
|
||||
// New method
|
||||
MultiplayerAPI::RPCConfig nd;
|
||||
Multiplayer::RPCConfig nd;
|
||||
nd.name = p_method;
|
||||
nd.rpc_mode = p_rpc_mode;
|
||||
nd.transfer_mode = p_transfer_mode;
|
||||
@@ -643,7 +643,7 @@ Variant Node::_rpc_id_bind(const Variant **p_args, int p_argcount, Callable::Cal
|
||||
|
||||
void Node::rpcp(int p_peer_id, const StringName &p_method, const Variant **p_arg, int p_argcount) {
|
||||
ERR_FAIL_COND(!is_inside_tree());
|
||||
get_multiplayer()->rpcp(this, p_peer_id, true, p_method, p_arg, p_argcount);
|
||||
get_multiplayer()->rpcp(this, p_peer_id, p_method, p_arg, p_argcount);
|
||||
}
|
||||
|
||||
Ref<MultiplayerAPI> Node::get_multiplayer() const {
|
||||
@@ -664,7 +664,7 @@ void Node::set_custom_multiplayer(Ref<MultiplayerAPI> p_multiplayer) {
|
||||
multiplayer = p_multiplayer;
|
||||
}
|
||||
|
||||
Vector<MultiplayerAPI::RPCConfig> Node::get_node_rpc_methods() const {
|
||||
Vector<Multiplayer::RPCConfig> Node::get_node_rpc_methods() const {
|
||||
return data.rpc_methods;
|
||||
}
|
||||
|
||||
@@ -2746,7 +2746,7 @@ void Node::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_multiplayer"), &Node::get_multiplayer);
|
||||
ClassDB::bind_method(D_METHOD("get_custom_multiplayer"), &Node::get_custom_multiplayer);
|
||||
ClassDB::bind_method(D_METHOD("set_custom_multiplayer", "api"), &Node::set_custom_multiplayer);
|
||||
ClassDB::bind_method(D_METHOD("rpc_config", "method", "rpc_mode", "transfer_mode", "channel"), &Node::rpc_config, DEFVAL(MultiplayerPeer::TRANSFER_MODE_RELIABLE), DEFVAL(0));
|
||||
ClassDB::bind_method(D_METHOD("rpc_config", "method", "rpc_mode", "transfer_mode", "channel"), &Node::rpc_config, DEFVAL(Multiplayer::TRANSFER_MODE_RELIABLE), DEFVAL(0));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_editor_description", "editor_description"), &Node::set_editor_description);
|
||||
ClassDB::bind_method(D_METHOD("get_editor_description"), &Node::get_editor_description);
|
||||
|
||||
Reference in New Issue
Block a user