diff --git a/src/DotTiled/DotTiled.csproj b/src/DotTiled/DotTiled.csproj index 6e8de2a..c91aeac 100644 --- a/src/DotTiled/DotTiled.csproj +++ b/src/DotTiled/DotTiled.csproj @@ -26,4 +26,8 @@ + + + + diff --git a/src/DotTiled/Serialization/Helpers.cs b/src/DotTiled/Serialization/Helpers.cs index d716293..2038401 100644 --- a/src/DotTiled/Serialization/Helpers.cs +++ b/src/DotTiled/Serialization/Helpers.cs @@ -46,6 +46,12 @@ internal static partial class Helpers return ReadMemoryStreamAsInt32Array(decompressedStream); } + internal static uint[] DecompressZStd(MemoryStream stream) + { + using var decompressedStream = new ZstdSharp.DecompressionStream(stream); + return ReadMemoryStreamAsInt32Array(decompressedStream); + } + internal static uint[] ReadBytesAsInt32Array(byte[] bytes) { var intArray = new uint[bytes.Length / 4]; diff --git a/src/DotTiled/Serialization/Tmx/TmxReaderBase.Data.cs b/src/DotTiled/Serialization/Tmx/TmxReaderBase.Data.cs index a05bbd0..6df7942 100644 --- a/src/DotTiled/Serialization/Tmx/TmxReaderBase.Data.cs +++ b/src/DotTiled/Serialization/Tmx/TmxReaderBase.Data.cs @@ -78,7 +78,7 @@ public abstract partial class TmxReaderBase { DataCompression.GZip => DecompressGZip(bytes), DataCompression.ZLib => DecompressZLib(bytes), - DataCompression.ZStd => throw new NotSupportedException("ZStd compression is not supported."), + DataCompression.ZStd => DecompressZStd(bytes), _ => throw new XmlException("Invalid compression") }; @@ -117,4 +117,10 @@ public abstract partial class TmxReaderBase using var decompressedStream = new ZLibStream(stream, CompressionMode.Decompress); return ReadMemoryStreamAsInt32Array(decompressedStream); } + + internal static uint[] DecompressZStd(MemoryStream stream) + { + using var decompressedStream = new ZstdSharp.DecompressionStream(stream); + return ReadMemoryStreamAsInt32Array(decompressedStream); + } }