diff --git a/Lidgren.Network/NetBuffer.Write.cs b/Lidgren.Network/NetBuffer.Write.cs
index ec19bc2..1a6453f 100644
--- a/Lidgren.Network/NetBuffer.Write.cs
+++ b/Lidgren.Network/NetBuffer.Write.cs
@@ -161,6 +161,18 @@ namespace Lidgren.Network
m_bitLength += 16;
}
+ ///
+ /// Writes a 16 bit unsigned integer at a given offset in the buffer
+ ///
+ [CLSCompliant(false)]
+ public void WriteAt(Int32 offset, UInt16 source)
+ {
+ int newBitLength = Math.Max(m_bitLength, offset + 16);
+ EnsureBufferSize(newBitLength);
+ NetBitWriter.WriteUInt16(source, 16, m_data, offset);
+ m_bitLength = newBitLength;
+ }
+
///
/// Writes an unsigned integer using 1 to 16 bits
///
@@ -183,6 +195,17 @@ namespace Lidgren.Network
m_bitLength += 16;
}
+ ///
+ /// Writes a 16 bit signed integer at a given offset in the buffer
+ ///
+ public void WriteAt(Int32 offset, Int16 source)
+ {
+ int newBitLength = Math.Max(m_bitLength, offset + 16);
+ EnsureBufferSize(newBitLength);
+ NetBitWriter.WriteUInt16((ushort)source, 16, m_data, offset);
+ m_bitLength = newBitLength;
+ }
+
#if UNSAFE
///
/// Writes a 32 bit signed integer
@@ -222,7 +245,7 @@ namespace Lidgren.Network
///
public void WriteAt(Int32 offset, Int32 source)
{
- int newBitLength = Math.Max(m_bitLength + 32, offset + 32);
+ int newBitLength = Math.Max(m_bitLength, offset + 32);
EnsureBufferSize(newBitLength);
NetBitWriter.WriteUInt32((UInt32)source, 32, m_data, offset);
m_bitLength = newBitLength;
@@ -267,9 +290,10 @@ namespace Lidgren.Network
///
/// Writes a 32 bit unsigned integer at a given offset in the buffer
///
+ [CLSCompliant(false)]
public void WriteAt(Int32 offset, UInt32 source)
{
- int newBitLength = Math.Max(m_bitLength + 32, offset + 32);
+ int newBitLength = Math.Max(m_bitLength, offset + 32);
EnsureBufferSize(newBitLength);
NetBitWriter.WriteUInt32(source, 32, m_data, offset);
m_bitLength = newBitLength;
@@ -321,6 +345,18 @@ namespace Lidgren.Network
m_bitLength += 64;
}
+ ///
+ /// Writes a 64 bit unsigned integer at a given offset in the buffer
+ ///
+ [CLSCompliant(false)]
+ public void WriteAt(Int32 offset, UInt64 source)
+ {
+ int newBitLength = Math.Max(m_bitLength, offset + 64);
+ EnsureBufferSize(newBitLength);
+ NetBitWriter.WriteUInt64(source, 64, m_data, offset);
+ m_bitLength = newBitLength;
+ }
+
///
/// Writes an unsigned integer using 1 to 64 bits
///