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
Fixed PackedByteArray GDScript functions #39100
Conversation
Tested with this script: func _ready():
var plain := "Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions Test PBA functions "
var utf8Bytes := plain.to_utf8()
print(utf8Bytes)
print("utf8Bytes: %d" % utf8Bytes.size())
var xStr := utf8Bytes.get_string_from_utf8()
print("xStr: " + xStr)
var compressedBytes := utf8Bytes.compress(File.COMPRESSION_GZIP)
print("compressedBytes: %d" % compressedBytes.size())
var decompressedBytes := compressedBytes.decompress(utf8Bytes.size(), File.COMPRESSION_GZIP)
print("decompressedBytes: %d" % decompressedBytes.size())
var decStr := decompressedBytes.get_string_from_utf8()
print("decStr: %d" % decStr.length())
print("'%s'" % decStr)
var decStrAscii := decompressedBytes.get_string_from_ascii()
print("decStr: %d" % decStrAscii.length())
print("'%s'" % decStrAscii) |
p_self._data.packed_array needs to be used instead of p_self._data._mem printline
fb3221f
to
8f1a6d7
Compare
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.
Great job 🏅 !
Thanks! |
Would be nice if this can be cherry-picked to 3.2.x in the next few months as I'm using these compression functions in production atm. |
Can't be cherry picked, because |
Well now that you mention it, I think this isn't an issue on 3.x, I just mixed up between projects. I'll open a new issue if it comes up with the 3.x branch instead of master. |
It looks like with the switch to PackedByteArray from the PoolArray types, the GDScript functions weren't updated correctly.
p_self._data.packed_array
needs to be used instead ofp_self._data._mem
These functions are now fixed:
Edit: Fixes #36611