tmxlite icon indicating copy to clipboard operation
tmxlite copied to clipboard

Read maps with zstd if compression is zstd.

Open SaraSmiseth opened this issue 4 years ago • 6 comments

I added support for base64 encoded maps with zstd compression. This fixes #80.

SaraSmiseth avatar Nov 13 '20 17:11 SaraSmiseth

The build fails. I don't know if zstd is installed on the build machine. Do we need a FindZstd.cmake file? It worked without one for me.

SaraSmiseth avatar Nov 13 '20 17:11 SaraSmiseth

Thanks for the contribution. To pass the CI zstd will need to be added to the cmake file as a dependency. This is somewhat unfortunate as it goes against the original mantra of being 'lite' - which was that tmxlite should not need any external dependencies which couldn't be included in the repository. However, if this is a much sought feature then an exception can probably be made.

fallahn avatar Nov 13 '20 19:11 fallahn

Just looking at this library for the first time, so not an expert on it or its philosophy, I just have a suggestion: could it be an option to make the dependency on zstd (and thus the support for compressed files) optional in cmake? The project could be made to build anyways even if zstd is not there, or even add a user-controlled option like -DTMX_WITH_ZSTD=ON. It should be simple with a few ifdefs around in the code.

KingDuckZ avatar Mar 19 '21 17:03 KingDuckZ

This would be the way to go, I think, should support be added. If there are more requests for it, or the original author of the PR wants to update it then I would happily accept it. It's not a high priority for me personally right now, however, mostly as I don't have time to work on the feature for the foreseeable future, but also because I'm not sure what advantage it offers over the existing zlib compression supported by tmxlite?

fallahn avatar Mar 19 '21 18:03 fallahn

I'm not personally interested in this either, but to answer your question I believe most distros are switching to using zstd as the default compression. From what I read the motivation is that zstd offers a compression ratio comparable to xz but with faster decompression and lower memory requirements. That also makes it superion to gzip, which is fast but doesn't achieve very high compression afaik.

Since I just opened a PR myself, if this gets merged I'll be happy to update my build scripts from my own PR as well.

KingDuckZ avatar Mar 19 '21 19:03 KingDuckZ

Ah OK, thanks for clarifying. Perhaps I shall take another look at this in the future.

fallahn avatar Mar 19 '21 20:03 fallahn