Changes account packets to functional (#284)
- [X] Moved packets from objects to functions - [X] Fixed bug where characters were showing up with their modded names in the character list Bumps release version
This commit is contained in:
parent
90220feb41
commit
0e02cf0821
19 changed files with 866 additions and 631 deletions
|
|
@ -29,6 +29,10 @@ namespace System.Buffers
|
|||
public int Length { get; }
|
||||
public int Position { get; private set; }
|
||||
|
||||
public CircularBufferWriter(CircularBuffer<byte> buffer) : this(buffer.GetSpan(0), buffer.GetSpan(1))
|
||||
{
|
||||
}
|
||||
|
||||
public CircularBufferWriter(Span<byte> first, Span<byte> second)
|
||||
{
|
||||
_first = first;
|
||||
|
|
@ -153,6 +157,34 @@ namespace System.Buffers
|
|||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void WriteLE(int value)
|
||||
{
|
||||
if (Position < _first.Length)
|
||||
{
|
||||
if (!BinaryPrimitives.TryWriteInt32LittleEndian(_first.Slice(Position), value))
|
||||
{
|
||||
// Not enough space. Split the spans
|
||||
Write((byte)(value >> 24));
|
||||
Write((byte)(value >> 16));
|
||||
Write((byte)(value >> 8));
|
||||
Write((byte)value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Position += 4;
|
||||
}
|
||||
}
|
||||
else if (BinaryPrimitives.TryWriteInt32LittleEndian(_second.Slice(Position - _first.Length), value))
|
||||
{
|
||||
Position += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new OutOfMemoryException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a 4-byte unsigned integer value to the underlying stream.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue