GUS - Godot Universal Serializer's icon

GUS - Godot Universal Serializer 1.03 Scripts 3.4 Community

Submitted by user Daylily; MIT; 2022-01-27

A Godot's universal serializer for size optimization

Feature:
1. Without losing type information. Need not type detection and
forced typce conversion in Cross end transfer,just like local parameter transfer.

2. Integer and float are variable length serialization.

3. The serialized data size is smaller than JSON text to utf8 and the native serialization method (var2bytes ()).GUS is especially suitable for the serialization of structured small dat transfer in multiplayer games.You can call GUS._test() to view the data size comparison after serialization in these three way.

How to use:
1. Modify the configuration definition constants at the beginning of the script as required.
2. Pass variable which without Object and Eid into GUS.to_bytes() and gets the serialized data for sending through any network peer.

3. After the remote network peer obtains the serialized data, passe it into GUS.to_var () to get the same variable as before serialization.



Additional: The obtained serialized data can be passed into GUS.get_ pretty_ json_text(), a beautified JSON text will be return, which is for printing and display when debugging.

Be careful:
1. The configuration definitions of cross end applications should keep the same.
2. Array and Dictionary should not contain Object or RID.
3. Because of implementing by GDScript, although the serialized data size is better, it will cost lot of time when serialization and deserialization large array(both Array and PoolArray), you should avoid to use GUS in time sensitive case.

TODO:
1. Write GUS 2.0 applicable for godot4 X .
2. Write as C++ addons to solve the problem of low efficiency of large array serialization.

Edit history:
January 21, 2022: Daylily-Zeleen - [email protected] - v1. 03
In order to setting default value by string facilitatly in some special specific occasions, I made some change as below:
a、Modify and add identification code for Boolean.
b、Modify identification code for Boolean Array and Dictionary.
For example, the default values of GUS encoded binary fields which stored in the database can be set as '[]', '{}', 'T' or 't', 'F' or 'f', which mean that empty Array, empty Dictionary, True and False .

January 19, 2022: Daylily-Zeleen - [email protected] - v1. 02
a、Fix empty Array deserialize error.
b、Fix empty Dictionary deserialize error.
c、Optimize empty pool arrays serialized size.

January 19, 2022: Daylily-Zeleen - [email protected] - v1. 01
a. Add type detection assert to GUS.to_bytes() for debugging purposes.
b. Add 'null' and 'bool' into GUS._test().
c. Add "How to use".
d. Add descriptions of common methods and test methods.
e. Optimize the text for push_error() when deserialize(GUS.to_var()) faild.

January 18, 2022: Daylily-Zeleen - [email protected] - v1. 0


View files Download Submit an issue Recent Edits