mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-02-26 21:41:19 +03:00
fixed SourceServerQuery shared buffer errors
This commit is contained in:
parent
127de84c8c
commit
2e6db5fe37
@ -32,7 +32,7 @@ namespace Steamworks
|
||||
}
|
||||
catch ( System.Exception e )
|
||||
{
|
||||
Console.Error.WriteLine( e.Message );
|
||||
//Console.Error.WriteLine( e.Message );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -54,14 +54,14 @@ namespace Steamworks
|
||||
var numRules = br.ReadUInt16();
|
||||
for ( int index = 0; index < numRules; index++ )
|
||||
{
|
||||
rules.Add( br.ReadNullTerminatedUTF8String( readBuffer ), br.ReadNullTerminatedUTF8String( readBuffer ) );
|
||||
rules.Add( br.ReadNullTerminatedUTF8String(), br.ReadNullTerminatedUTF8String() );
|
||||
}
|
||||
}
|
||||
|
||||
return rules;
|
||||
}
|
||||
|
||||
static byte[] readBuffer = new byte[1024 * 8];
|
||||
|
||||
|
||||
static async Task<byte[]> Receive( UdpClient client )
|
||||
{
|
||||
@ -120,10 +120,10 @@ namespace Steamworks
|
||||
return challengeData;
|
||||
}
|
||||
|
||||
static byte[] sendBuffer = new byte[1024];
|
||||
|
||||
static async Task Send( UdpClient client, byte[] message )
|
||||
{
|
||||
var sendBuffer = new byte[message.Length + 4];
|
||||
|
||||
sendBuffer[0] = 0xFF;
|
||||
sendBuffer[1] = 0xFF;
|
||||
sendBuffer[2] = 0xFF;
|
||||
|
@ -80,20 +80,22 @@ namespace Steamworks
|
||||
}
|
||||
}
|
||||
|
||||
public static string ReadNullTerminatedUTF8String( this BinaryReader br, byte[] buffer = null )
|
||||
{
|
||||
if ( buffer == null )
|
||||
buffer = new byte[1024];
|
||||
static byte[] readBuffer = new byte[1024 * 8];
|
||||
|
||||
public static string ReadNullTerminatedUTF8String( this BinaryReader br )
|
||||
{
|
||||
lock ( readBuffer )
|
||||
{
|
||||
byte chr;
|
||||
int i = 0;
|
||||
while ( (chr = br.ReadByte()) != 0 && i < buffer.Length )
|
||||
while ( (chr = br.ReadByte()) != 0 && i < readBuffer.Length )
|
||||
{
|
||||
buffer[i] = chr;
|
||||
readBuffer[i] = chr;
|
||||
i++;
|
||||
}
|
||||
|
||||
return Encoding.UTF8.GetString( buffer, 0, i );
|
||||
return Encoding.UTF8.GetString( readBuffer, 0, i );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user