-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Use compatible text resource format when possible #90889
Conversation
This makes TileMapLayer save in the old PackedByteArray format, which is wrong. |
If you mean the change in |
No I mean I tested with a TileMapLayer in a scene. The whole format change was because of TileMapLayer. |
Ah, sorry I missed the recursion part when in VariantWriter. I'll get rid of the setup for TileSet and push again. |
It should work correctly now.
|
This works correctly and even resolves Resources issue, making my PR irrelevant. But it's hacky. And also it makes Base64 hard-coded only for TileMapLayer, which means nothing else can benefit from it. I think perfectly scenes/resources should always save under new format if they contain PackedByteArray. |
e73358a
to
c46b038
Compare
It turns out Now the resource saver will use the new format if there's a PackedByteArray with at least 64 elements. The hard-coded TileMapLayer check is removed. The downside is that the format version may change depending on what's inside the resource / scene. Maybe the array size limit is an overthinking, a non-empty check is enough. |
Yeah the size check is unecessary. This also means that we have to keep the old PackedByteArray serialization code. |
The main reason I added the size check is for potential custom nodes / resources that export PackedByteArray variables. If the array only contains a few elements, using Base64 won't save much space and is not human readable. Seems not worth breaking compat for. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still somewhat hacky, but at least it's no longer hard-coded to one class. It's a nice solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That approach looks fine to me overall.
I discussed it with @reduz, and we agreed to merge this for now to address the immediate issue, and then:
- Backport support for parsing the new base64 PackedByteArray to 4.1.5 and 4.2.3 (but not saving - so keeping version format 3 there, but being able to parse version 4).
- Eventually consider reverting this compat handling once the currently supported stable versions no longer need it.
Thanks! |
Use the new format only when saving a resource / scene containing a PackedByteArray with at least 64 elements.
This way, editor settings can be kept, and users can still open most scenes with previous versions of Godot.
This PR is a proof of concept of my suggestion on RocketChat.
Bugsquad edit: Fixes #90846