(a00338777) v0.9.2.1

This commit is contained in:
Joonas Rikkonen
2019-08-26 19:58:19 +03:00
parent 0f63da27b2
commit 80698b58b0
311 changed files with 11763 additions and 4507 deletions
@@ -1,5 +1,4 @@
using Lidgren.Network;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -7,6 +6,7 @@ using System.Security.Cryptography;
using System.Reflection;
using System.Text;
using Microsoft.Xna.Framework;
using Barotrauma.Networking;
namespace Barotrauma
{
@@ -313,13 +313,16 @@ namespace Barotrauma
/// <summary>
/// Reads a number of bits from the buffer and inserts them to a new NetBuffer instance
/// </summary>
public static NetBuffer ExtractBits(this NetBuffer originalBuffer, int numberOfBits)
public static IReadMessage ExtractBits(this IReadMessage originalBuffer, int numberOfBits)
{
var buffer = new NetBuffer();
byte[] data = new byte[(int)Math.Ceiling(numberOfBits / (double)8)];
originalBuffer.ReadBits(data, 0, numberOfBits);
buffer.Write(data);
var buffer = new ReadWriteMessage();
for (int i=0;i<numberOfBits;i++)
{
bool bit = originalBuffer.ReadBoolean();
buffer.Write(bit);
}
buffer.BitPosition = 0;
return buffer;
}
@@ -407,5 +410,13 @@ namespace Barotrauma
//}
return destination;
}
public static string ByteArrayToString(byte[] ba)
{
StringBuilder hex = new StringBuilder(ba.Length * 2);
foreach (byte b in ba)
hex.AppendFormat("{0:x2}", b);
return hex.ToString();
}
}
}