diff options
author | Andrea Catania <info@andreacatania.com> | 2020-02-12 11:51:50 +0100 |
---|---|---|
committer | Andrea Catania <info@andreacatania.com> | 2020-02-12 13:36:47 +0100 |
commit | eb07e87981d55fac8299b6db55fb5c29e0bfa49b (patch) | |
tree | ee7950df756bfdcdd6b4942751ddf100eb5d442c /modules/gdnative/nativescript/godot_nativescript.cpp | |
parent | 70dd7f4e1ae890534692067797c42337c45d3daf (diff) |
Optmized data sent during RPC and RSet calls.
- Now is sent the method ID rather the full function name.
- The passed IDs (Node and Method) are compressed so to use less possible space.
- The variant (INT and BOOL) is now encoded and compressed so to use much less data.
- Optimized RPCMode retrieval for GDScript functions.
- Added checksum to assert the methods are the same across peers.
This work has been kindly sponsored by IMVU.
Diffstat (limited to 'modules/gdnative/nativescript/godot_nativescript.cpp')
-rw-r--r-- | modules/gdnative/nativescript/godot_nativescript.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp index e19e675344..f953206a34 100644 --- a/modules/gdnative/nativescript/godot_nativescript.cpp +++ b/modules/gdnative/nativescript/godot_nativescript.cpp @@ -36,6 +36,7 @@ #include "core/project_settings.h" #include "core/variant.h" #include "gdnative/gdnative.h" +#include <stdint.h> #include "nativescript.h" @@ -67,6 +68,14 @@ void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char if (classes->has(p_base)) { desc.base_data = &(*classes)[p_base]; desc.base_native_type = desc.base_data->base_native_type; + + const NativeScriptDesc *b = desc.base_data; + while (b) { + desc.rpc_count += b->rpc_count; + desc.rset_count += b->rset_count; + b = b->base_data; + } + } else { desc.base_data = NULL; desc.base_native_type = p_base; @@ -87,10 +96,20 @@ void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const desc.destroy_func = p_destroy_func; desc.is_tool = true; desc.base = p_base; + desc.rpc_count = 0; + desc.rset_count = 0; if (classes->has(p_base)) { desc.base_data = &(*classes)[p_base]; desc.base_native_type = desc.base_data->base_native_type; + + const NativeScriptDesc *b = desc.base_data; + while (b) { + desc.rpc_count += b->rpc_count; + desc.rset_count += b->rset_count; + b = b->base_data; + } + } else { desc.base_data = NULL; desc.base_native_type = p_base; @@ -109,6 +128,11 @@ void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const cha NativeScriptDesc::Method method; method.method = p_method; method.rpc_mode = p_attr.rpc_type; + method.rpc_method_id = UINT16_MAX; + if (p_attr.rpc_type != GODOT_METHOD_RPC_MODE_DISABLED) { + method.rpc_method_id = E->get().rpc_count; + E->get().rpc_count += 1; + } method.info = MethodInfo(p_function_name); E->get().methods.insert(p_function_name, method); @@ -125,6 +149,10 @@ void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const c property.default_value = *(Variant *)&p_attr->default_value; property.getter = p_get_func; property.rset_mode = p_attr->rset_type; + if (p_attr->rset_type != GODOT_METHOD_RPC_MODE_DISABLED) { + property.rset_property_id = E->get().rset_count; + E->get().rset_count += 1; + } property.setter = p_set_func; property.info = PropertyInfo((Variant::Type)p_attr->type, p_path, |