Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary serialization API about RID is incorrect #10662

Open
beicause opened this issue Feb 10, 2025 · 2 comments
Open

Binary serialization API about RID is incorrect #10662

beicause opened this issue Feb 10, 2025 · 2 comments
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation bug

Comments

@beicause
Copy link

Your Godot version:
4.4 latest

Issue description:
The document states that RID doesn't support serialization, but in fact RID can be serialized and deserialized (as int64) using var_to_bytes and bytes_to_var, even if the corresponding resource can't be serialized and may not be valid. For example var_to_bytes(rid_from_int64(13)) returns [23,0,0,0,13,0,0,0,0,0,0,0]

serialize:
https://github.com/godotengine/godot/blob/36d90c73a843afa2807a0b8dcbfbf52bdb8a759c/core/io/marshalls.cpp#L1732-L1739

deserialize:
https://github.com/godotengine/godot/blob/36d90c73a843afa2807a0b8dcbfbf52bdb8a759c/core/io/marshalls.cpp#L689-L697

URL to the documentation page:
https://docs.godotengine.org/en/latest/tutorials/io/binary_serialization_api.html#rid-unsupported

@tetrapod00 tetrapod00 added bug area:manual Issues and PRs related to the Manual/Tutorials section of the documentation labels Feb 10, 2025
@beicause
Copy link
Author

beicause commented Feb 10, 2025

In addition in the latest type enum, the RID is 23, not 16

enum Type {
		NIL,

		// atomic types
		BOOL,
		INT,
		FLOAT,
		STRING,

		// math types
		VECTOR2,
		VECTOR2I,
		RECT2,
		RECT2I,
		VECTOR3,
		VECTOR3I,
		TRANSFORM2D,
		VECTOR4,
		VECTOR4I,
		PLANE,
		QUATERNION,
		AABB,
		BASIS,
		TRANSFORM3D,
		PROJECTION,

		// misc types
		COLOR,
		STRING_NAME,
		NODE_PATH,
		RID,
		OBJECT,
		CALLABLE,
		SIGNAL,
		DICTIONARY,
		ARRAY,

		// typed arrays
		PACKED_BYTE_ARRAY,
		PACKED_INT32_ARRAY,
		PACKED_INT64_ARRAY,
		PACKED_FLOAT32_ARRAY,
		PACKED_FLOAT64_ARRAY,
		PACKED_STRING_ARRAY,
		PACKED_VECTOR2_ARRAY,
		PACKED_VECTOR3_ARRAY,
		PACKED_COLOR_ARRAY,
		PACKED_VECTOR4_ARRAY,

		VARIANT_MAX
	};

@tetrapod00
Copy link
Contributor

I think the page has been out of date for a while, see #4945

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation bug
Projects
None yet
Development

No branches or pull requests

2 participants