ReliableNetcode.NET
ReliableNetcode.NET copied to clipboard
Why not directly use Array.Copy and increment Position?
https://github.com/KillaMaaki/ReliableNetcode.NET/blob/09fba6a45ebb6f0d9d2be23bcd15c65b40b6c773/ReliableNetcode/Utils/IO/ByteStream.cs#L198-L202
I guess the Read function could use some love too, something like..
public override int Read(byte[] buffer, int offset, int count)
{
long pos = this.Position;
long len = this.Length;
int readBytes = (int)Math.Min(count, len - pos);
Array.Copy(srcByteArray, pos, buffer, offset, readBytes);
this.Position = pos + readBytes;
return readBytes;
}
I also notice the Write doesn't deal with any buffer overflows like Read does. Not sure if that's important and is dealt with elsewhere.