Skip to content

Commit

Permalink
test win build
Browse files Browse the repository at this point in the history
  • Loading branch information
TitleHHHH authored and TitleHHHH committed Oct 27, 2024
1 parent c26de03 commit 0e8981e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 37 deletions.
29 changes: 6 additions & 23 deletions .github/workflows/devbuilds.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: dev-builds
# This workflow represents a set of basic End-to-End tests
on:
push:
branches:
Expand All @@ -9,36 +8,20 @@ on:

jobs:

basic:
runs-on: ${{ matrix.os }}
windows-builds:
runs-on: windows-latest
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
rid: [ win-x86, win-x64, win-arm64 ]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
- run: dotnet --version

- name: Install Pupnet and dpkg
if: ${{ matrix.os == 'ubuntu-latest'}}
run: |
ls Deploy
chmod +x Deploy/PostPublish.sh
dotnet tool install -g KuiperZone.PupNet
sudo apt install dpkg
- name: Run pupnet
if: ${{ matrix.os == 'ubuntu-latest'}}
run: pupnet --runtime linux-x64 --kind deb --output "HolyClient.Desktop-x64.deb"

- name: Upload Deb
if: ${{ matrix.os == 'ubuntu-latest'}}
uses: actions/upload-artifact@v4
with:
name: 'Linux-x64'
path: 'Deploy/bin/HolyClient.Desktop-x64.deb'
- name: Dotnet publish
run: dotnet publish -r ${{matrix.rid}} --self-contained -p:PublishSingleFile=true src/Platforms/HolyClient.Desktop
24 changes: 10 additions & 14 deletions src/McProtoNet/McProtoNet/Net/MinecraftPacketReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed class MinecraftPacketReader
private static readonly MemoryAllocator<byte> memoryAllocator = ArrayPool<byte>.Shared.ToAllocator();


private int _compressionThreshold=-1;
private int _compressionThreshold = -1;

public Stream BaseStream { get; set; }

Expand All @@ -25,7 +25,7 @@ public void Dispose()
public async ValueTask<InputPacket> ReadNextPacketAsync(CancellationToken token = default)
{
var len = await BaseStream.ReadVarIntAsync(token);
if (_compressionThreshold<0)
if (_compressionThreshold < 0)
{
var buffer = memoryAllocator.AllocateExactly(len);
try
Expand All @@ -39,25 +39,24 @@ public async ValueTask<InputPacket> ReadNextPacketAsync(CancellationToken token
throw;
}
}

var sizeUncompressed = await BaseStream.ReadVarIntAsync(token);
if (sizeUncompressed > 0)
{
if (sizeUncompressed < _compressionThreshold)
throw new Exception(
$"Длина sizeUncompressed меньше порога сжатия. sizeUncompressed: {sizeUncompressed} Порог: {_compressionThreshold}");
len -= sizeUncompressed.GetVarIntLength();
var buffer_compress = ArrayPool<byte>.Shared.Rent(len);
try
{
await BaseStream.ReadExactlyAsync(buffer_compress, 0, len, token);

var compressedBuffer = memoryAllocator.AllocateExactly(len);

var memoryOwner = new MemoryOwner<byte>(ArrayPool<byte>.Shared, sizeUncompressed);
try
{
await BaseStream.ReadExactlyAsync(compressedBuffer.Memory, token);
var memoryOwner = memoryAllocator.AllocateExactly(sizeUncompressed);
try
{
DecompressCore(buffer_compress.AsSpan(0, len), memoryOwner.Span);


DecompressCore(compressedBuffer.Span, memoryOwner.Span);
return new InputPacket(memoryOwner);
}
catch
Expand All @@ -68,7 +67,7 @@ public async ValueTask<InputPacket> ReadNextPacketAsync(CancellationToken token
}
finally
{
ArrayPool<byte>.Shared.Return(buffer_compress);
compressedBuffer.Dispose();
}
}

Expand All @@ -94,7 +93,6 @@ public async ValueTask<InputPacket> ReadNextPacketAsync(CancellationToken token
private static void DecompressCore(ReadOnlySpan<byte> bufferCompress, Span<byte> uncompress)
{
var decompressor = new ZlibDecompressor();
//var decompressor = LibDeflateCache.RentDecompressor();
try
{
var status = decompressor.Decompress(
Expand All @@ -113,7 +111,5 @@ private static void DecompressCore(ReadOnlySpan<byte> bufferCompress, Span<byte>
public void EnableCompression(int threshold)
{
_compressionThreshold = threshold;

}

}

0 comments on commit 0e8981e

Please sign in to comment.