mirror of
https://github.com/godotengine/godot.git
synced 2025-10-30 13:11:13 +00:00
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.
This commit is contained in:
parent
70dd7f4e1a
commit
eb07e87981
19 changed files with 1580 additions and 292 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue