This commit is contained in:
7H3LaughingMan 2025-04-22 11:46:24 -05:00 committed by GitHub
commit 78bb645019
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 1 deletions

View file

@ -26,4 +26,8 @@
<None Include="../../LICENSE" Pack="true" PackagePath="" /> <None Include="../../LICENSE" Pack="true" PackagePath="" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="ZstdSharp.Port" Version="0.8.5" />
</ItemGroup>
</Project> </Project>

View file

@ -46,6 +46,12 @@ internal static partial class Helpers
return ReadMemoryStreamAsInt32Array(decompressedStream); 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) internal static uint[] ReadBytesAsInt32Array(byte[] bytes)
{ {
var intArray = new uint[bytes.Length / 4]; var intArray = new uint[bytes.Length / 4];

View file

@ -78,7 +78,7 @@ public abstract partial class TmxReaderBase
{ {
DataCompression.GZip => DecompressGZip(bytes), DataCompression.GZip => DecompressGZip(bytes),
DataCompression.ZLib => DecompressZLib(bytes), DataCompression.ZLib => DecompressZLib(bytes),
DataCompression.ZStd => throw new NotSupportedException("ZStd compression is not supported."), DataCompression.ZStd => DecompressZStd(bytes),
_ => throw new XmlException("Invalid compression") _ => throw new XmlException("Invalid compression")
}; };
@ -117,4 +117,10 @@ public abstract partial class TmxReaderBase
using var decompressedStream = new ZLibStream(stream, CompressionMode.Decompress); using var decompressedStream = new ZLibStream(stream, CompressionMode.Decompress);
return ReadMemoryStreamAsInt32Array(decompressedStream); return ReadMemoryStreamAsInt32Array(decompressedStream);
} }
internal static uint[] DecompressZStd(MemoryStream stream)
{
using var decompressedStream = new ZstdSharp.DecompressionStream(stream);
return ReadMemoryStreamAsInt32Array(decompressedStream);
}
} }