Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Properly encode `EncodedObjectAsID` objects

Michael Alexsander5b9ef1681969
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index ff42d310d33..30e62429a4e 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -1768,7 +1768,9 @@ Error encode_variant(const Variant &p_variant, uint8_t *p_buffer, int &r_len, bo
Object *obj = p_variant.get_validated_object();
ObjectID id;
if (obj) {
- id = obj->get_instance_id();
+ // If the object is already an encoded ID, use that instead.
+ Ref<EncodedObjectAsID> obj_as_id = Object::cast_to<EncodedObjectAsID>(obj);
+ id = obj_as_id.is_valid() ? obj_as_id->get_object_id() : obj->get_instance_id();
}
encode_uint64(id, buf);