summaryrefslogtreecommitdiff
path: root/modules/gdscript/gdscript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/gdscript.cpp')
-rw-r--r--modules/gdscript/gdscript.cpp36
1 files changed, 14 insertions, 22 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index a34bf6ef82..28722bd178 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -51,7 +51,7 @@
#endif
#ifdef TOOLS_ENABLED
-#include "editor/editor_settings.h"
+#include "editor/editor_paths.h"
#endif
///////////////////////////
@@ -848,7 +848,7 @@ Error GDScript::reload(bool p_keep_state) {
// Loading a template, don't parse.
#ifdef TOOLS_ENABLED
- if (EditorSettings::get_singleton() && basedir.begins_with(EditorSettings::get_singleton()->get_project_script_templates_dir())) {
+ if (EditorPaths::get_singleton() && basedir.begins_with(EditorPaths::get_singleton()->get_project_script_templates_dir())) {
return OK;
}
#endif
@@ -954,8 +954,8 @@ void GDScript::get_members(HashSet<StringName> *p_members) {
}
}
-const Vector<Multiplayer::RPCConfig> GDScript::get_rpc_methods() const {
- return rpc_functions;
+const Variant GDScript::get_rpc_config() const {
+ return rpc_config;
}
Variant GDScript::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
@@ -1212,9 +1212,9 @@ void GDScript::_save_orphaned_subclasses() {
void GDScript::_init_rpc_methods_properties() {
// Copy the base rpc methods so we don't mask their IDs.
- rpc_functions.clear();
+ rpc_config.clear();
if (base.is_valid()) {
- rpc_functions = base->rpc_functions;
+ rpc_config = base->rpc_config.duplicate();
}
GDScript *cscript = this;
@@ -1222,12 +1222,9 @@ void GDScript::_init_rpc_methods_properties() {
while (cscript) {
// RPC Methods
for (KeyValue<StringName, GDScriptFunction *> &E : cscript->member_functions) {
- Multiplayer::RPCConfig config = E.value->get_rpc_config();
- if (config.rpc_mode != Multiplayer::RPC_MODE_DISABLED) {
- config.name = E.value->get_name();
- if (rpc_functions.find(config) == -1) {
- rpc_functions.push_back(config);
- }
+ Variant config = E.value->get_rpc_config();
+ if (config.get_type() != Variant::NIL) {
+ rpc_config[E.value->get_name()] = config;
}
}
@@ -1241,9 +1238,6 @@ void GDScript::_init_rpc_methods_properties() {
cscript = nullptr;
}
}
-
- // Sort so we are 100% that they are always the same.
- rpc_functions.sort_custom<Multiplayer::SortRPCConfig>();
}
GDScript::~GDScript() {
@@ -1408,9 +1402,7 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
while (sl) {
HashMap<StringName, GDScriptFunction *>::ConstIterator E = sl->member_functions.find(p_name);
if (E) {
- Multiplayer::RPCConfig config;
- config.name = p_name;
- if (sptr->rpc_functions.find(config) != -1) {
+ if (sptr->rpc_config.has(p_name)) {
r_ret = Callable(memnew(GDScriptRPCCallable(this->owner, E->key)));
} else {
r_ret = Callable(this->owner, E->key);
@@ -1629,15 +1621,13 @@ ScriptLanguage *GDScriptInstance::get_language() {
return GDScriptLanguage::get_singleton();
}
-const Vector<Multiplayer::RPCConfig> GDScriptInstance::get_rpc_methods() const {
- return script->get_rpc_methods();
+const Variant GDScriptInstance::get_rpc_config() const {
+ return script->get_rpc_config();
}
void GDScriptInstance::reload_members() {
#ifdef DEBUG_ENABLED
- members.resize(script->member_indices.size()); //resize
-
Vector<Variant> new_members;
new_members.resize(script->member_indices.size());
@@ -1649,6 +1639,8 @@ void GDScriptInstance::reload_members() {
}
}
+ members.resize(new_members.size()); //resize
+
//apply
members = new_members;