diff --git a/Lidgren.Network/NetIncomingMessage.Read.cs b/Lidgren.Network/NetIncomingMessage.Read.cs
index 5eb0b2f..76a8c19 100644
--- a/Lidgren.Network/NetIncomingMessage.Read.cs
+++ b/Lidgren.Network/NetIncomingMessage.Read.cs
@@ -232,6 +232,22 @@ namespace Lidgren.Network
return (Int32)retval;
}
+ ///
+ /// Reads a 32 bit signed integer written using Write(Int32)
+ ///
+ public bool ReadInt32(out Int32 result)
+ {
+ if (m_bitLength - m_readPosition < 32)
+ {
+ result = 0;
+ return false;
+ }
+
+ result = (Int32)NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
+ m_readPosition += 32;
+ return true;
+ }
+
///
/// Reads a signed integer stored in 1 to 32 bits, written using Write(Int32, Int32)
///
@@ -391,6 +407,29 @@ namespace Lidgren.Network
return BitConverter.ToSingle(bytes, 0);
}
+ ///
+ /// Reads a 32 bit floating point value written using Write(Single)
+ ///
+ public bool ReadSingle(out float result)
+ {
+ if (m_bitLength - m_readPosition < 32)
+ {
+ result = 0.0f;
+ return false;
+ }
+
+ if ((m_readPosition & 7) == 0) // read directly
+ {
+ result = BitConverter.ToSingle(m_data, m_readPosition >> 3);
+ m_readPosition += 32;
+ return true;
+ }
+
+ byte[] bytes = ReadBytes(4);
+ result = BitConverter.ToSingle(bytes, 0);
+ return true;
+ }
+
///
/// Reads a 64 bit floating point value written using Write(Double)
///