Skip to content

Commit

Permalink
fix static checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Daylily-Zeleen committed Jul 29, 2023
1 parent a757ce9 commit d27ee89
Show file tree
Hide file tree
Showing 19 changed files with 119 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ CMakeLists.txt
resource.h
*.pdb

*.obj
*.obj
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@

[中文文档](README_zh_cn.md) <- 点击这里。

A Godot's universal serializer for size optimization.
A Godot's universal serializer for size optimization.
Support all data types except `Object`, `RID`, `Callable` and `Signal` in Godot 4.x.

# 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 are variable length serialization.
3. The serialized data size is smaller than JSON text to utf8 and the native serialization method `var_to_bytes()`.GUS is especially suitable for the serialization of structured small data transfer in multiplayer games.
4. GDExtension plugin, high performance.
4. GDExtension plugin, high performance.

You can run the `EditorScript` which named `GUS_benchmark.gd` to view the contrast between `GUS`, `Native`, and `JSON`.

# How to use:
1. Download released plugin, install ~~and enable~~ this plugin just like other plugin( If the version is not match, please compile by yourselves).
2. ~~Modify properties of autoload which named `GUS` as you require.~~
3. Pass variable which without `Object`, `OID`, `Callable`, `Signal` into `GUS.var_to_bytes()` and get the serialized data, than send to network peer.
3. After the remote network peer obtains the serialized data, passe it into `GUS.bytes_to_var()` to get the same variable as before serialization.
4. After the remote network peer obtains the serialized data, passe it into `GUS.bytes_to_var()` to get the same variable as before serialization.


# Be careful:
Expand All @@ -32,8 +32,8 @@ Support all data types except `Object`, `RID`, `Callable` and `Signal` in Godot
3. ~~The properties of autoload `GUS` between all network peers should keep the same.~~
4. ~~Currently unsupport Godot 4.x which compiled with `typeof double real_t`.~~
5. ~~Currently just support platform `windows`.~~


# TODO:
1. ~~If I find the way to bind static method for `GDScript`, I will get rid of the autoload `GUS`.~~
2. ~~Compile `linux` and `osx` version.~~
Expand All @@ -44,35 +44,35 @@ Support all data types except `Object`, `RID`, `Callable` and `Signal` in Godot
# How to compile:
1. Follow [offical tutorial](https://docs.godotengine.org/zh_CN/stable/development/compiling/index.html) to set up you develop enviroment.
2. Clone this repository (with submodule).
3. You must generate bindings and build library of `godot-cpp` at least once.
- You can use generate and build manully by steps below:
a. Navigate to `godot-cpp` folder.
b. Run command:
3. You must generate bindings and build library of `godot-cpp` at least once.
- You can use generate and build manully by steps below:
a. Navigate to `godot-cpp` folder.
b. Run command:
```
scons generate_bindings=yes build_library=yes
```
c. Now you can add `generate_bindings=no build_library=no` at next stage to avoid generate bindings and build library every time when compiling `GUS`.
c. Now you can add `generate_bindings=no build_library=no` at next stage to avoid generate bindings and build library every time when compiling `GUS`.

- (Recommand) Generate bindings and build library every time when compiling `GUS`, to keep the compiling condition of `godot-cpp` same as `GUS`.
Just skip this stage and add `generate_bindings=yes build_library=yes` or ignore these command arguments.
- (Recommand) Generate bindings and build library every time when compiling `GUS`, to keep the compiling condition of `godot-cpp` same as `GUS`.
Just skip this stage and add `generate_bindings=yes build_library=yes` or ignore these command arguments.
Don't worry, generate bindings and build library of `godot-cpp` would not take many time if the compile conditions have not change.
4. Here is a little different from `godot-cpp` to compile `GUS` (of course, you can use `scons` to compile, too).
To do some post process, I use a tool script to compile `GUS`.
Navigate to root folder, run command as below to compile `GUS`:
```
python build_tool.py
python build.py
```

You can add arguments like to build `godot-cpp` at this stage.

To learn more arguments detail, run this command.
```
python build_tool.py -h
python build.py -h
```

Specially, if you not specify the argument `target`, this tool will build both `target=template_debug` and `target=template_release`.

5. Now, you can get the addon which be located at `\demo\addons\com.daylily_zeleen.godot_universal_serializer\`, or get the packed addon at `bin\com.daylily_zeleen.godot_universal_serializer.zip`.
5. Now, you can get the addon which be located at `\demo\addons\com.daylily_zeleen.godot_universal_serializer\`, or get the packed addon at `bin\com.daylily_zeleen.godot_universal_serializer.zip`.
(Notice: if your use `scons` instead of `python build_tool`, you can only get dynamic library at `bin` folder.)

# Benchmark 2.1.5:
Expand Down Expand Up @@ -675,4 +675,4 @@ Array[PackedColorArray] - Size:4096
[GUS]: 331459 bytes ser 2359 usec deser 6938 usec
[Native]: 360136 bytes ser 2229 usec deser 5728 usec
[JSON]: 698894 bytes ser 248205 usec deser 59321 usec
```
```
20 changes: 11 additions & 9 deletions README_zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
1. 下载发布的插件包,像其他插件一样安装~~和启用~~即可(如果版本不匹配,请自行编译)。
2. ~~根据你的需求代码修改名为`GUS`的Autoload的属性.~~
3. 传递不包含`Object``OID``Callable`以及 `Signal`的变量给 `GUS.var_to_bytes()`并获取序列化后数据,然后发送给其他网络对等体。
3. 远端的网络对等体获取到序列化后数据,传递给`GUS.bytes_to_var()`,即可获得与序列化前相同的变量。
4. 远端的网络对等体获取到序列化后数据,传递给`GUS.bytes_to_var()`,即可获得与序列化前相同的变量。


# 注意:
Expand All @@ -32,38 +32,40 @@
3. ~~不同端的`GUS`属性必须保持一致才能正确反序列化。~~
4. ~~当前不支持`typeof double real_t`的自定义构建Godot 4.x版本。~~
5. ~~当前仅支持`windows`.~~



# TODO:
1. ~~如果我找到绑定静态方法给`GDScript`的办法,我将抛弃自动加载`GUS`, 改为静态方法的方式去实现功能。~~
2. ~~编译`linux``osx`版本。~~
3. ~~编译`typeof double real_t`版本以支持自定义构建Godot 4.x版本(但我碰上了我无法处理的编译错误)。~~
4. ~~处理 `Object``RID``Callable`以及`Signal`~~
5. 处理大小端。


# 如何编译:
1. 根据[官方文档](https://docs.godotengine.org/zh_CN/stable/development/compiling/index.html)搭建你的编译环境。
2. 克隆这个仓库(以递归方式克隆,以包含子模块)。
3. 你必须至少生成一次`godot-cpp`的绑定,并且至少构建一次它的库。
- 你可以手动生成并构建:
3. 你必须至少生成一次`godot-cpp`的绑定,并且至少构建一次它的库。
- 你可以手动生成并构建:
a. 导航到`godot-cpp`文件夹。
b. 运行以下命令。
```
scons generate_bindings=yes build_library=yes
```
c. 完成以后,您需要在下个步骤的命令中添加参数`generate_bindings=no build_library=no`来避免重复构建`GUS`时重复生成`godot-cpp`的绑定与`godot-cpp`的库。

- (推荐方式)在每次构建`GUS`时重复生成`godot-cpp`的绑定与构建其库,直接跳该步骤,在下个步骤的命令中添加参数`generate_bindings=yes build_library=yes`来显式要求该操作,或忽略这些参数以默认方式工作。
- (推荐方式)在每次构建`GUS`时重复生成`godot-cpp`的绑定与构建其库,直接跳该步骤,在下个步骤的命令中添加参数`generate_bindings=yes build_library=yes`来显式要求该操作,或忽略这些参数以默认方式工作。
别担心,只要编译条件没有变化,重复生成与构建不会占用您太多时间。
4. 编译`GUS`与编译`godot-cpp`有一点小区别(当然你也可以继续使用`scons`命令进行构建),为了执行一些后处理,我使用一个简单的工具脚本进行编译:
4. 编译`GUS`与编译`godot-cpp`有一点小区别(当然你也可以继续使用`scons`命令进行构建),为了执行一些后处理,我使用一个简单的工具脚本进行编译:
导航到根目录,运行以下命令
```
python build_tool.py
python build.py
```

你可以像在编译`godot-cpp`一样对改命令添加其他参数。
你可以使用以下命令来查看更多参数详情:
```
python build_tool.py -h
python build.py -h
```

特别的,如果你没有明确`taget`参数,该脚本工具会同时编译`target=template_debug`和 `target=template_release`两种版本。
Expand Down Expand Up @@ -669,4 +671,4 @@ Array[PackedColorArray] - Size:4096
[GUS]: 331459 bytes ser 2359 usec deser 6938 usec
[Native]: 360136 bytes ser 2229 usec deser 5728 usec
[JSON]: 698894 bytes ser 248205 usec deser 59321 usec
```
```
13 changes: 4 additions & 9 deletions build_tool.py → build.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import os
#!/usr/bin/env python

import sys
import os
import zipfile
import shutil
from os.path import join as path_join


build_debug = True
build_release = True

arg1 = ""
arg2 = ""


def main():
args = "scons"
debug_and_relaese = True
Expand All @@ -23,7 +18,7 @@ def main():

if arg.startswith("python"):
continue
if arg.count("build_tool.py") > 0:
if arg == sys.argv[0]:
continue
if arg.count("scons") > 0:
print("Should not use \"scons\" argument, skip it.")
Expand Down
2 changes: 1 addition & 1 deletion demo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export_presets.cfg

# Mono-specific ignores
.mono/
data_*/
data_*/
32 changes: 16 additions & 16 deletions demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@

[中文文档](README_zh_cn.md) <- 点击这里。

A Godot's universal serializer for size optimization.
A Godot's universal serializer for size optimization.
Support all data types except `Object`, `RID`, `Callable` and `Signal` in Godot 4.x.

# 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 are variable length serialization.
3. The serialized data size is smaller than JSON text to utf8 and the native serialization method `var_to_bytes()`.GUS is especially suitable for the serialization of structured small data transfer in multiplayer games.
4. GDExtension plugin, high performance.
4. GDExtension plugin, high performance.

You can run the `EditorScript` which named `GUS_benchmark.gd` to view the contrast between `GUS`, `Native`, and `JSON`.

# How to use:
1. Download released plugin, install ~~and enable~~ this plugin just like other plugin( If the version is not match, please compile by yourselves).
2. ~~Modify properties of autoload which named `GUS` as you require.~~
3. Pass variable which without `Object`, `OID`, `Callable`, `Signal` into `GUS.var_to_bytes()` and get the serialized data, than send to network peer.
3. After the remote network peer obtains the serialized data, passe it into `GUS.bytes_to_var()` to get the same variable as before serialization.
4. After the remote network peer obtains the serialized data, passe it into `GUS.bytes_to_var()` to get the same variable as before serialization.


# Be careful:
Expand All @@ -32,8 +32,8 @@ Support all data types except `Object`, `RID`, `Callable` and `Signal` in Godot
3. ~~The properties of autoload `GUS` between all network peers should keep the same.~~
4. ~~Currently unsupport Godot 4.x which compiled with `typeof double real_t`.~~
5. ~~Currently just support platform `windows`.~~


# TODO:
1. ~~If I find the way to bind static method for `GDScript`, I will get rid of the autoload `GUS`.~~
2. ~~Compile `linux` and `osx` version.~~
Expand All @@ -44,35 +44,35 @@ Support all data types except `Object`, `RID`, `Callable` and `Signal` in Godot
# How to compile:
1. Follow [offical tutorial](https://docs.godotengine.org/zh_CN/stable/development/compiling/index.html) to set up you develop enviroment.
2. Clone this repository (with submodule).
3. You must generate bindings and build library of `godot-cpp` at least once.
- You can use generate and build manully by steps below:
a. Navigate to `godot-cpp` folder.
b. Run command:
3. You must generate bindings and build library of `godot-cpp` at least once.
- You can use generate and build manully by steps below:
a. Navigate to `godot-cpp` folder.
b. Run command:
```
scons generate_bindings=yes build_library=yes
```
c. Now you can add `generate_bindings=no build_library=no` at next stage to avoid generate bindings and build library every time when compiling `GUS`.
c. Now you can add `generate_bindings=no build_library=no` at next stage to avoid generate bindings and build library every time when compiling `GUS`.

- (Recommand) Generate bindings and build library every time when compiling `GUS`, to keep the compiling condition of `godot-cpp` same as `GUS`.
Just skip this stage and add `generate_bindings=yes build_library=yes` or ignore these command arguments.
- (Recommand) Generate bindings and build library every time when compiling `GUS`, to keep the compiling condition of `godot-cpp` same as `GUS`.
Just skip this stage and add `generate_bindings=yes build_library=yes` or ignore these command arguments.
Don't worry, generate bindings and build library of `godot-cpp` would not take many time if the compile conditions have not change.
4. Here is a little different from `godot-cpp` to compile `GUS` (of course, you can use `scons` to compile, too).
To do some post process, I use a tool script to compile `GUS`.
Navigate to root folder, run command as below to compile `GUS`:
```
python build_tool.py
python build.py
```

You can add arguments like to build `godot-cpp` at this stage.

To learn more arguments detail, run this command.
```
python build_tool.py -h
python build.py -h
```

Specially, if you not specify the argument `target`, this tool will build both `target=template_debug` and `target=template_release`.

5. Now, you can get the addon which be located at `\demo\addons\com.daylily_zeleen.godot_universal_serializer\`, or get the packed addon at `bin\com.daylily_zeleen.godot_universal_serializer.zip`.
5. Now, you can get the addon which be located at `\demo\addons\com.daylily_zeleen.godot_universal_serializer\`, or get the packed addon at `bin\com.daylily_zeleen.godot_universal_serializer.zip`.
(Notice: if your use `scons` instead of `python build_tool`, you can only get dynamic library at `bin` folder.)

# Benchmark 2.1.5:
Expand Down Expand Up @@ -675,4 +675,4 @@ Array[PackedColorArray] - Size:4096
[GUS]: 331459 bytes ser 2359 usec deser 6938 usec
[Native]: 360136 bytes ser 2229 usec deser 5728 usec
[JSON]: 698894 bytes ser 248205 usec deser 59321 usec
```
```
20 changes: 11 additions & 9 deletions demo/README_zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
1. 下载发布的插件包,像其他插件一样安装~~和启用~~即可(如果版本不匹配,请自行编译)。
2. ~~根据你的需求代码修改名为`GUS`的Autoload的属性.~~
3. 传递不包含`Object``OID``Callable`以及 `Signal`的变量给 `GUS.var_to_bytes()`并获取序列化后数据,然后发送给其他网络对等体。
3. 远端的网络对等体获取到序列化后数据,传递给`GUS.bytes_to_var()`,即可获得与序列化前相同的变量。
4. 远端的网络对等体获取到序列化后数据,传递给`GUS.bytes_to_var()`,即可获得与序列化前相同的变量。


# 注意:
Expand All @@ -32,38 +32,40 @@
3. ~~不同端的`GUS`属性必须保持一致才能正确反序列化。~~
4. ~~当前不支持`typeof double real_t`的自定义构建Godot 4.x版本。~~
5. ~~当前仅支持`windows`.~~



# TODO:
1. ~~如果我找到绑定静态方法给`GDScript`的办法,我将抛弃自动加载`GUS`, 改为静态方法的方式去实现功能。~~
2. ~~编译`linux``osx`版本。~~
3. ~~编译`typeof double real_t`版本以支持自定义构建Godot 4.x版本(但我碰上了我无法处理的编译错误)。~~
4. ~~处理 `Object``RID``Callable`以及`Signal`~~
5. 处理大小端。


# 如何编译:
1. 根据[官方文档](https://docs.godotengine.org/zh_CN/stable/development/compiling/index.html)搭建你的编译环境。
2. 克隆这个仓库(以递归方式克隆,以包含子模块)。
3. 你必须至少生成一次`godot-cpp`的绑定,并且至少构建一次它的库。
- 你可以手动生成并构建:
3. 你必须至少生成一次`godot-cpp`的绑定,并且至少构建一次它的库。
- 你可以手动生成并构建:
a. 导航到`godot-cpp`文件夹。
b. 运行以下命令。
```
scons generate_bindings=yes build_library=yes
```
c. 完成以后,您需要在下个步骤的命令中添加参数`generate_bindings=no build_library=no`来避免重复构建`GUS`时重复生成`godot-cpp`的绑定与`godot-cpp`的库。

- (推荐方式)在每次构建`GUS`时重复生成`godot-cpp`的绑定与构建其库,直接跳该步骤,在下个步骤的命令中添加参数`generate_bindings=yes build_library=yes`来显式要求该操作,或忽略这些参数以默认方式工作。
- (推荐方式)在每次构建`GUS`时重复生成`godot-cpp`的绑定与构建其库,直接跳该步骤,在下个步骤的命令中添加参数`generate_bindings=yes build_library=yes`来显式要求该操作,或忽略这些参数以默认方式工作。
别担心,只要编译条件没有变化,重复生成与构建不会占用您太多时间。
4. 编译`GUS`与编译`godot-cpp`有一点小区别(当然你也可以继续使用`scons`命令进行构建),为了执行一些后处理,我使用一个简单的工具脚本进行编译:
4. 编译`GUS`与编译`godot-cpp`有一点小区别(当然你也可以继续使用`scons`命令进行构建),为了执行一些后处理,我使用一个简单的工具脚本进行编译:
导航到根目录,运行以下命令
```
python build_tool.py
python build.py
```

你可以像在编译`godot-cpp`一样对改命令添加其他参数。
你可以使用以下命令来查看更多参数详情:
```
python build_tool.py -h
python build.py -h
```

特别的,如果你没有明确`taget`参数,该脚本工具会同时编译`target=template_debug`和 `target=template_release`两种版本。
Expand Down Expand Up @@ -669,4 +671,4 @@ Array[PackedColorArray] - Size:4096
[GUS]: 331459 bytes ser 2359 usec deser 6938 usec
[Native]: 360136 bytes ser 2229 usec deser 5728 usec
[JSON]: 698894 bytes ser 248205 usec deser 59321 usec
```
```
Loading

0 comments on commit d27ee89

Please sign in to comment.