1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-17 07:36:32 +09:00

NetConnection.LocalHailMessage exposed. WriteVariableInt64 and ReadVariableInt64 added.

This commit is contained in:
lidgren
2010-12-28 13:13:00 +00:00
parent b83ec10d8d
commit eb056bc9aa
4 changed files with 58 additions and 3 deletions

View File

@@ -363,6 +363,29 @@ namespace Lidgren.Network
}
}
/// <summary>
/// Reads a Int64 written using WriteVariableInt64()
/// </summary>
public Int64 ReadVariableInt64()
{
Int64 num1 = 0;
int num2 = 0;
while (true)
{
if (num2 == 0x23)
throw new FormatException("Bad 7-bit encoded integer");
byte num3 = this.ReadByte();
num1 |= (Int64)((Int64)(num3 & 0x7f) << (num2 & 0x1f));
num2 += 7;
if ((num3 & 0x80) == 0)
{
Int64 sign = (num1 << 63) >> 63;
return sign ^ (num1 >> 1);
}
}
}
/// <summary>
/// Reads a UInt32 written using WriteVariableInt64()
/// </summary>