38f1ddb...178a853: v0.8.9.1, removed content folder

This commit is contained in:
Joonas Rikkonen
2019-03-18 19:46:58 +02:00
parent 38f1ddb6fe
commit 6c0679c297
1054 changed files with 151673 additions and 144931 deletions
@@ -98,7 +98,14 @@ namespace Barotrauma.Networking
public void ReadBytes(NetIncomingMessage inc)
{
byte[] all = inc.ReadBytes(inc.LengthBytes - inc.PositionInBytes);
int bytesToRead = inc.LengthBytes - inc.PositionInBytes;
if (Received + (ulong)(bytesToRead) > FileSize)
{
//strip out excess bytes
bytesToRead -= (int)((Received + (ulong)bytesToRead) - FileSize);
}
byte[] all = inc.ReadBytes(bytesToRead);
Received += (ulong)all.Length;
WriteStream.Write(all, 0, all.Length);
@@ -259,10 +266,15 @@ namespace Barotrauma.Networking
return;
}
if (activeTransfer.Received + (ulong)(inc.LengthBytes - inc.PositionInBytes) > activeTransfer.FileSize)
//allow one extra byte at the end for the 0 that identifies non-compressed messages
if (activeTransfer.Received + (ulong)(inc.LengthBytes - inc.PositionInBytes) > activeTransfer.FileSize + 1)
{
GameMain.Client.CancelFileTransfer(inc.SequenceChannel);
DebugConsole.ThrowError("File transfer error: Received more data than expected");
DebugConsole.ThrowError("File transfer error: Received more data than expected (total received: " + activeTransfer.Received +
", msg received: " + (inc.LengthBytes - inc.PositionInBytes) +
", msg length: " + inc.LengthBytes +
", msg read: " + inc.PositionInBytes +
", filesize: " + activeTransfer.FileSize);
activeTransfer.Status = FileTransferStatus.Error;
StopTransfer(activeTransfer);
return;