Build 0.18.4.0

This commit is contained in:
Markus Isberg
2022-05-31 23:13:05 +09:00
parent 077917fa5d
commit 64db1a6a44
175 changed files with 4916 additions and 2393 deletions
@@ -158,7 +158,7 @@ namespace Barotrauma.Networking
private static void UpdateRead()
{
Span<byte> msgLengthSpan = stackalloc byte[3];
Span<byte> msgLengthSpan = stackalloc byte[4 + 1];
while (!shutDown)
{
CheckPipeConnected(nameof(readStream), readStream);
@@ -182,8 +182,11 @@ namespace Barotrauma.Networking
if (!readBytes(msgLengthSpan)) { shutDown = true; break; }
int msgLength = msgLengthSpan[0] | (msgLengthSpan[1] << 8);
WriteStatus writeStatus = (WriteStatus)msgLengthSpan[2];
int msgLength = msgLengthSpan[0]
| (msgLengthSpan[1] << 8)
| (msgLengthSpan[2] << 16)
| (msgLengthSpan[3] << 24);
WriteStatus writeStatus = (WriteStatus)msgLengthSpan[4];
if (msgLength > 0)
{
@@ -225,12 +228,15 @@ namespace Barotrauma.Networking
// when the function returns; placing it in the loop
// this method is based around would lead to a stack
// overflow real quick!
Span<byte> bytesToWrite = stackalloc byte[3 + msg.Length];
Span<byte> bytesToWrite = stackalloc byte[4 + 1 + msg.Length];
bytesToWrite[0] = (byte)(msg.Length & 0xFF);
bytesToWrite[1] = (byte)((msg.Length >> 8) & 0xFF);
bytesToWrite[2] = (byte)writeStatus;
Span<byte> msgSlice = bytesToWrite.Slice(3, msg.Length);
bytesToWrite[2] = (byte)((msg.Length >> 16) & 0xFF);
bytesToWrite[3] = (byte)((msg.Length >> 24) & 0xFF);
bytesToWrite[4] = (byte)writeStatus;
Span<byte> msgSlice = bytesToWrite.Slice(4 + 1, msg.Length);
msg.AsSpan().CopyTo(msgSlice);
@@ -284,6 +290,12 @@ namespace Barotrauma.Networking
{
if (shutDown) { return; }
if (msg.Length > 0x1fff_ffff)
{
//This message is extremely long and is close to breaking
//ChildServerRelay, so let's not allow this to go through!
return;
}
msgsToWrite.Enqueue(msg);
writeManualResetEvent.Set();
}