You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-17 23:56:30 +09:00
Merge pull request #31 from zsebastian/master
Fixed sublte bug in ReadUInt64(int) and PeekUInt64(int)
This commit is contained in:
@@ -237,7 +237,7 @@ namespace Lidgren.Network
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
||||||
retval |= NetBitWriter.ReadUInt32(m_data, numberOfBits - 32, m_readPosition) << 32;
|
retval |= (UInt64)NetBitWriter.ReadUInt32(m_data, numberOfBits - 32, m_readPosition + 32) << 32;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ namespace Lidgren.Network
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
||||||
retval |= NetBitWriter.ReadUInt32(m_data, numberOfBits - 32, m_readPosition) << 32;
|
retval |= (UInt64)NetBitWriter.ReadUInt32(m_data, numberOfBits - 32, m_readPosition + 32) << 32;
|
||||||
}
|
}
|
||||||
m_readPosition += numberOfBits;
|
m_readPosition += numberOfBits;
|
||||||
return retval;
|
return retval;
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ namespace UnitTests
|
|||||||
msg.Write("duke of earl");
|
msg.Write("duke of earl");
|
||||||
msg.Write((byte)43);
|
msg.Write((byte)43);
|
||||||
msg.Write((ushort)44);
|
msg.Write((ushort)44);
|
||||||
|
msg.Write(UInt64.MaxValue, 64);
|
||||||
msg.Write(true);
|
msg.Write(true);
|
||||||
|
|
||||||
msg.WritePadBits();
|
msg.WritePadBits();
|
||||||
@@ -83,8 +84,13 @@ namespace UnitTests
|
|||||||
throw new NetException("Read/write failure");
|
throw new NetException("Read/write failure");
|
||||||
|
|
||||||
bdr.Append(inc.ReadUInt16());
|
bdr.Append(inc.ReadUInt16());
|
||||||
|
|
||||||
|
if (inc.PeekUInt64(64) != UInt64.MaxValue)
|
||||||
|
throw new NetException("Read/write failure");
|
||||||
|
|
||||||
|
bdr.Append(inc.ReadUInt64());
|
||||||
bdr.Append(inc.ReadBoolean());
|
bdr.Append(inc.ReadBoolean());
|
||||||
|
|
||||||
inc.SkipPadBits();
|
inc.SkipPadBits();
|
||||||
|
|
||||||
bdr.Append(inc.ReadSingle());
|
bdr.Append(inc.ReadSingle());
|
||||||
@@ -96,7 +102,7 @@ namespace UnitTests
|
|||||||
bdr.Append(inc.ReadVariableUInt32());
|
bdr.Append(inc.ReadVariableUInt32());
|
||||||
bdr.Append(inc.ReadVariableInt64());
|
bdr.Append(inc.ReadVariableInt64());
|
||||||
|
|
||||||
if (bdr.ToString().Equals("False-342duke of earl4344True56784521159980224614-4747000048-49"))
|
if (bdr.ToString().Equals("False-342duke of earl434418446744073709551615True56784521159980224614-4747000048-49"))
|
||||||
Console.WriteLine("Read/write tests OK");
|
Console.WriteLine("Read/write tests OK");
|
||||||
else
|
else
|
||||||
throw new NetException("Read/write tests FAILED!");
|
throw new NetException("Read/write tests FAILED!");
|
||||||
|
|||||||
Reference in New Issue
Block a user