From 88d6ef51ebd0809375622ac38b2692607e8aa0cd Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 19 Aug 2022 01:19:33 +0200 Subject: [PATCH] Removed additional direct script rpc mode query when sending rpcs, in order to simplify that codepath as much as possible. Also removed the remote, remotesync etc. keywords from gdscript, as now they won't work anymore. Node's rpc_config() method should be used instead of marking methods with keywords in scripts. --- core/io/multiplayer_api.cpp | 34 +------ core/object/script_language.h | 6 -- modules/cscript/cscript.cpp | 9 -- modules/cscript/cscript.h | 3 - modules/gdscript/gdscript.cpp | 40 -------- modules/gdscript/gdscript.h | 4 - modules/gdscript/gdscript_compiler.cpp | 3 - modules/gdscript/gdscript_editor.cpp | 4 +- modules/gdscript/gdscript_function.cpp | 1 - modules/gdscript/gdscript_function.h | 2 - modules/gdscript/gdscript_parser.cpp | 118 +----------------------- modules/gdscript/gdscript_parser.h | 5 - modules/gdscript/gdscript_tokenizer.cpp | 23 ----- modules/gdscript/gdscript_tokenizer.h | 8 -- 14 files changed, 7 insertions(+), 253 deletions(-) diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index 3ad186991..e9e5daf0a 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -270,8 +270,6 @@ void MultiplayerAPI::_process_rpc(Node *p_node, const StringName &p_name, int p_ const Map::Element *E = p_node->get_node_rpc_mode(p_name); if (E) { rpc_mode = E->get(); - } else if (p_node->get_script_instance()) { - rpc_mode = p_node->get_script_instance()->get_rpc_mode(p_name); } bool can_call = _can_call_mode(p_node, rpc_mode, p_from); @@ -572,8 +570,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const int node_id = network_peer->get_unique_id(); bool skip_rpc = node_id == p_peer_id; - bool call_local_native = false; - bool call_local_script = false; + bool call_local = false; bool is_master = p_node->is_network_master(); if (p_peer_id == 0 || p_peer_id == node_id || (p_peer_id < 0 && p_peer_id != -node_id)) { @@ -581,15 +578,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const const Map::Element *E = p_node->get_node_rpc_mode(p_method); if (E) { - call_local_native = _should_call_local(E->get(), is_master, skip_rpc); - } - - if (call_local_native) { - // Done below. - } else if (p_node->get_script_instance()) { - // Attempt with script. - RPCMode rpc_mode = p_node->get_script_instance()->get_rpc_mode(p_method); - call_local_script = _should_call_local(rpc_mode, is_master, skip_rpc); + call_local = _should_call_local(E->get(), is_master, skip_rpc); } } @@ -605,7 +594,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const _send_rpc(p_node, p_peer_id, p_unreliable, p_method, p_arg, p_argcount); } - if (call_local_native) { + if (call_local) { int temp_id = rpc_sender_id; rpc_sender_id = get_network_unique_id(); Variant::CallError ce; @@ -619,22 +608,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const } } - if (call_local_script) { - int temp_id = rpc_sender_id; - rpc_sender_id = get_network_unique_id(); - Variant::CallError ce; - ce.error = Variant::CallError::CALL_OK; - p_node->get_script_instance()->call(p_method, p_arg, p_argcount, ce); - rpc_sender_id = temp_id; - if (ce.error != Variant::CallError::CALL_OK) { - String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce); - error = "rpc() aborted in script local call: - " + error + "."; - ERR_PRINT(error); - return; - } - } - - ERR_FAIL_COND_MSG(skip_rpc && !(call_local_native || call_local_script), "RPC '" + p_method + "' on yourself is not allowed by selected mode."); + ERR_FAIL_COND_MSG(skip_rpc && !(call_local), "RPC '" + p_method + "' on yourself is not allowed by selected mode."); } Error MultiplayerAPI::send_bytes(PoolVector p_data, int p_to, NetworkedMultiplayerPeer::TransferMode p_mode) { diff --git a/core/object/script_language.h b/core/object/script_language.h index 7d7cfbec3..fba2cb00d 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -196,9 +196,6 @@ public: virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid); virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid); - virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const = 0; - virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const = 0; - virtual ScriptLanguage *get_language() = 0; virtual ~ScriptInstance(); }; @@ -410,9 +407,6 @@ public: virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid = nullptr); virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid = nullptr); - virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const { return MultiplayerAPI::RPC_MODE_DISABLED; } - virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const { return MultiplayerAPI::RPC_MODE_DISABLED; } - PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref