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
Added Int-64 version of WriteRangedInteger
`WriteRangedInteger(long min, long max, long value)` is now available for ranged writings of Int-64 values.
This commit is contained in:
@@ -586,6 +586,23 @@ namespace Lidgren.Network
|
|||||||
return numBits;
|
return numBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes an integer with the least amount of bits need for the specified range
|
||||||
|
/// Returns number of bits written
|
||||||
|
/// </summary>
|
||||||
|
public int WriteRangedInteger(long min, long max, long value)
|
||||||
|
{
|
||||||
|
NetException.Assert(value >= min && value <= max, "Value not within min/max range!");
|
||||||
|
|
||||||
|
ulong range = (ulong)(max - min);
|
||||||
|
int numBits = NetUtility.BitsToHoldUInt64(range);
|
||||||
|
|
||||||
|
ulong rvalue = (ulong)(value - min);
|
||||||
|
Write(rvalue, numBits);
|
||||||
|
|
||||||
|
return numBits;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Write a string
|
/// Write a string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user