Please help me understand Base64 encoded ZLIB compressed data

I created a map in Tiled and it cannot be loaded with CocosSharp - that is not Tiled’s fault :smile:

But it got me to a point where I want to understand how data base64 encoded and ZLIB compressed data nodes are built up.

My map is an isometric one with a grid of 100x100 tiles. A small fraction of it is filled with content. There’s only one layer.
The compressed string in my test map is 112 characters long and the props show me it is base64 and ZLIB compressed. If I base64-decode the string and inflate it, it will result in 16.384 bytes. And that’s what I find strange. If these bytes are meant to be 32bit integers, it would mean that there are 16.386/4 = 4.096 ints in there. However with my map being 100x100, shouldn’t there be 100x100 = 10.000 integers in it?

If you’d like to have a look at the TMX, it can be found here:

Your decoding is buggy.

Using python:

import base64
z = base64.b64decode('eJzt0UEJADAMwMB6nn+YiO0R6B1EQWYAAAAAAAAAAAAAAAAAAAAAAHY7n+ONHy1+tPjR4keLHy1+tPjR4keLHy1+tPjR4keLHy1+tPjR4keLHy1+tPjR4keLHy1+AAAAAAAAAAAAAAAAwD4XM1POpQ==')



import zlib
d = zlib.decompress(z)



You’re absolutely right! And I was able to fix the relevant code in CocosSharp. Thanks for pointing out.

1 Like