diff --git a/Lidgren.Network/NetIncomingMessage.Peek.cs b/Lidgren.Network/NetIncomingMessage.Peek.cs index d0f7fb1..bb0e43c 100644 --- a/Lidgren.Network/NetIncomingMessage.Peek.cs +++ b/Lidgren.Network/NetIncomingMessage.Peek.cs @@ -274,13 +274,12 @@ namespace Lidgren.Network if ((m_readPosition & 7) == 0) // read directly { - // endianness is handled inside BitConverter.ToSingle float retval = BitConverter.ToSingle(m_data, m_readPosition >> 3); return retval; } byte[] bytes = PeekBytes(4); - return BitConverter.ToSingle(bytes, 0); // endianness is handled inside BitConverter.ToSingle + return BitConverter.ToSingle(bytes, 0); } /// @@ -298,7 +297,7 @@ namespace Lidgren.Network } byte[] bytes = PeekBytes(8); - return BitConverter.ToDouble(bytes, 0); // endianness is handled inside BitConverter.ToSingle + return BitConverter.ToDouble(bytes, 0); } /// diff --git a/Lidgren.Network/NetIncomingMessage.Read.cs b/Lidgren.Network/NetIncomingMessage.Read.cs index 862a85f..1432e53 100644 --- a/Lidgren.Network/NetIncomingMessage.Read.cs +++ b/Lidgren.Network/NetIncomingMessage.Read.cs @@ -334,14 +334,13 @@ namespace Lidgren.Network if ((m_readPosition & 7) == 0) // read directly { - // endianness is handled inside BitConverter.ToSingle float retval = BitConverter.ToSingle(m_data, m_readPosition >> 3); m_readPosition += 32; return retval; } byte[] bytes = ReadBytes(4); - return BitConverter.ToSingle(bytes, 0); // endianness is handled inside BitConverter.ToSingle + return BitConverter.ToSingle(bytes, 0); } /// @@ -360,7 +359,7 @@ namespace Lidgren.Network } byte[] bytes = ReadBytes(8); - return BitConverter.ToDouble(bytes, 0); // endianness is handled inside BitConverter.ToSingle + return BitConverter.ToDouble(bytes, 0); } // diff --git a/Lidgren.Network/NetPeer.Internal.cs b/Lidgren.Network/NetPeer.Internal.cs index 0289fdc..10e91fc 100644 --- a/Lidgren.Network/NetPeer.Internal.cs +++ b/Lidgren.Network/NetPeer.Internal.cs @@ -46,6 +46,8 @@ namespace Lidgren.Network /// public void RegisterReceivedCallback(SendOrPostCallback callback) { + if (SynchronizationContext.Current == null) + throw new NetException("Need a SynchronizationContext to register callback on correct thread!"); if (m_receiveCallbacks == null) m_receiveCallbacks = new List>(); m_receiveCallbacks.Add(new NetTuple(SynchronizationContext.Current, callback));