You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-17 15:46:33 +09:00
Support for AOT
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Lidgren.Network
|
|||||||
{
|
{
|
||||||
private const string c_readOverflowError = "Trying to read past the buffer size - likely caused by mismatching Write/Reads, different size or order.";
|
private const string c_readOverflowError = "Trying to read past the buffer size - likely caused by mismatching Write/Reads, different size or order.";
|
||||||
private const int c_bufferSize = 64; // Min 8 to hold anything but strings. Increase it if readed strings usally don't fit inside the buffer
|
private const int c_bufferSize = 64; // Min 8 to hold anything but strings. Increase it if readed strings usally don't fit inside the buffer
|
||||||
private static byte[] s_buffer;
|
private static object s_buffer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reads a boolean value (stored as a single bit) written using Write(bool)
|
/// Reads a boolean value (stored as a single bit) written using Write(bool)
|
||||||
@@ -355,7 +355,7 @@ namespace Lidgren.Network
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] bytes = Interlocked.Exchange(ref s_buffer, null) ?? new byte[c_bufferSize];
|
byte[] bytes = (byte[]) Interlocked.Exchange(ref s_buffer, null) ?? new byte[c_bufferSize];
|
||||||
ReadBytes(bytes, 0, 4);
|
ReadBytes(bytes, 0, 4);
|
||||||
float res = BitConverter.ToSingle(bytes, 0);
|
float res = BitConverter.ToSingle(bytes, 0);
|
||||||
s_buffer = bytes;
|
s_buffer = bytes;
|
||||||
@@ -380,7 +380,7 @@ namespace Lidgren.Network
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] bytes = Interlocked.Exchange(ref s_buffer, null) ?? new byte[c_bufferSize];
|
byte[] bytes = (byte[]) Interlocked.Exchange(ref s_buffer, null) ?? new byte[c_bufferSize];
|
||||||
ReadBytes(bytes, 0, 4);
|
ReadBytes(bytes, 0, 4);
|
||||||
result = BitConverter.ToSingle(bytes, 0);
|
result = BitConverter.ToSingle(bytes, 0);
|
||||||
s_buffer = bytes;
|
s_buffer = bytes;
|
||||||
@@ -402,7 +402,7 @@ namespace Lidgren.Network
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] bytes = Interlocked.Exchange(ref s_buffer, null) ?? new byte[c_bufferSize];
|
byte[] bytes = (byte[]) Interlocked.Exchange(ref s_buffer, null) ?? new byte[c_bufferSize];
|
||||||
ReadBytes(bytes, 0, 8);
|
ReadBytes(bytes, 0, 8);
|
||||||
double res = BitConverter.ToDouble(bytes, 0);
|
double res = BitConverter.ToDouble(bytes, 0);
|
||||||
s_buffer = bytes;
|
s_buffer = bytes;
|
||||||
@@ -605,7 +605,7 @@ namespace Lidgren.Network
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (byteLen <= c_bufferSize) {
|
if (byteLen <= c_bufferSize) {
|
||||||
byte[] buffer = Interlocked.Exchange(ref s_buffer, null) ?? new byte[c_bufferSize];
|
byte[] buffer = (byte[]) Interlocked.Exchange(ref s_buffer, null) ?? new byte[c_bufferSize];
|
||||||
ReadBytes(buffer, 0, byteLen);
|
ReadBytes(buffer, 0, byteLen);
|
||||||
string retval = Encoding.UTF8.GetString(buffer, 0, byteLen);
|
string retval = Encoding.UTF8.GetString(buffer, 0, byteLen);
|
||||||
s_buffer = buffer;
|
s_buffer = buffer;
|
||||||
|
|||||||
Reference in New Issue
Block a user