feat: Replaces Zlib with LibDeflate (#1774)
> [!Warning] > Users on Linux/OSX will need to follow the Readme > and make sure `libdeflate` is properly installed > [!Note] > **Developer Note** > The API for compression has changed. Use `Deflate.Standard` for the same functionality. ### Summary * Replaces Zlib with LibDeflate for a 50% performance improvement! * Adds MacOS 14 to properly test Arm64
This commit is contained in:
parent
35a292d2c7
commit
1f701e7b55
11 changed files with 279 additions and 282 deletions
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Buffers;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using Server.Compression;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
|
|
@ -209,20 +210,14 @@ namespace Server.Network
|
|||
|
||||
var inflatedBuffer = planeBuffers[i];
|
||||
|
||||
var deflatedLength = deflatedBuffer.Length;
|
||||
var ce = Zlib.Pack(
|
||||
var deflatedLength = Deflate.Standard.Pack(
|
||||
deflatedBuffer,
|
||||
ref deflatedLength,
|
||||
inflatedBuffer,
|
||||
size,
|
||||
ZlibQuality.Default
|
||||
inflatedBuffer.AsSpan(0, size)
|
||||
);
|
||||
|
||||
if (ce != ZlibError.Okay)
|
||||
if (deflatedLength == 0)
|
||||
{
|
||||
Console.WriteLine("ZLib error: {0} (#{1})", ce, (int)ce);
|
||||
deflatedLength = 0;
|
||||
size = 0;
|
||||
Console.WriteLine("Compression error");
|
||||
}
|
||||
|
||||
Write((byte)(0x20 | i));
|
||||
|
|
@ -247,20 +242,14 @@ namespace Server.Network
|
|||
|
||||
var inflatedBuffer = stairBuffers[i];
|
||||
|
||||
var deflatedLength = deflatedBuffer.Length;
|
||||
var ce = Zlib.Pack(
|
||||
var deflatedLength = Deflate.Standard.Pack(
|
||||
deflatedBuffer,
|
||||
ref deflatedLength,
|
||||
inflatedBuffer,
|
||||
size,
|
||||
ZlibQuality.Default
|
||||
inflatedBuffer.AsSpan(0, size)
|
||||
);
|
||||
|
||||
if (ce != ZlibError.Okay)
|
||||
if (deflatedLength == 0)
|
||||
{
|
||||
Console.WriteLine("ZLib error: {0} (#{1})", ce, (int)ce);
|
||||
deflatedLength = 0;
|
||||
size = 0;
|
||||
Console.WriteLine("Compression error");
|
||||
}
|
||||
|
||||
Write((byte)(9 + i));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue