mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-24 13:45:37 +03:00
In SourceServerQuery, read strings as UTF8
This commit is contained in:
parent
ff1d866374
commit
46f56c24f3
@ -406,9 +406,10 @@ public void Rules()
|
|||||||
filter.Add( "gamedir", "rust" );
|
filter.Add( "gamedir", "rust" );
|
||||||
filter.Add( "secure", "1" );
|
filter.Add( "secure", "1" );
|
||||||
|
|
||||||
|
filter.Add( "addr", "185.97.254.146" );
|
||||||
|
|
||||||
using ( var query = client.ServerList.Internet( filter ) )
|
using ( var query = client.ServerList.Internet( filter ) )
|
||||||
{
|
{
|
||||||
|
|
||||||
for ( int i = 0; i < 1000; i++ )
|
for ( int i = 0; i < 1000; i++ )
|
||||||
{
|
{
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
@ -416,8 +417,8 @@ public void Rules()
|
|||||||
GC.Collect();
|
GC.Collect();
|
||||||
System.Threading.Thread.Sleep( 10 );
|
System.Threading.Thread.Sleep( 10 );
|
||||||
|
|
||||||
if ( query.Responded.Count > 20 )
|
// if ( query.Responded.Count > 20 )
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
if ( query.Finished )
|
if ( query.Finished )
|
||||||
break;
|
break;
|
||||||
@ -425,15 +426,12 @@ public void Rules()
|
|||||||
|
|
||||||
query.Dispose();
|
query.Dispose();
|
||||||
|
|
||||||
var servers = query.Responded.Take( 10 );
|
var servers = query.Responded.Take( 100 );
|
||||||
|
|
||||||
foreach ( var server in servers )
|
|
||||||
{
|
|
||||||
server.FetchRules();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ( var server in servers )
|
foreach ( var server in servers )
|
||||||
{
|
{
|
||||||
|
server.FetchRules();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while ( !server.HasRules )
|
while ( !server.HasRules )
|
||||||
{
|
{
|
||||||
@ -447,7 +445,10 @@ public void Rules()
|
|||||||
|
|
||||||
if ( server.HasRules )
|
if ( server.HasRules )
|
||||||
{
|
{
|
||||||
Console.WriteLine( "SERVER HAS RULES :D" );
|
Console.WriteLine( "" );
|
||||||
|
Console.WriteLine( "" );
|
||||||
|
Console.WriteLine( server.Address );
|
||||||
|
Console.WriteLine( "" );
|
||||||
|
|
||||||
foreach ( var rule in server.Rules )
|
foreach ( var rule in server.Rules )
|
||||||
{
|
{
|
||||||
|
@ -79,7 +79,7 @@ internal static string FormatPrice(string currency, ulong price)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ReadAnsiString( this BinaryReader br, byte[] buffer = null )
|
public static string ReadNullTerminatedUTF8String( this BinaryReader br, byte[] buffer = null )
|
||||||
{
|
{
|
||||||
if ( buffer == null )
|
if ( buffer == null )
|
||||||
buffer = new byte[1024];
|
buffer = new byte[1024];
|
||||||
@ -92,7 +92,7 @@ public static string ReadAnsiString( this BinaryReader br, byte[] buffer = null
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Encoding.ASCII.GetString( buffer, 0, i );
|
return Encoding.UTF8.GetString( buffer, 0, i );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ void GetRules()
|
|||||||
var numRules = br.ReadUInt16();
|
var numRules = br.ReadUInt16();
|
||||||
for ( int index = 0; index < numRules; index++ )
|
for ( int index = 0; index < numRules; index++ )
|
||||||
{
|
{
|
||||||
rules.Add( br.ReadAnsiString( readBuffer ), br.ReadAnsiString( readBuffer ) );
|
rules.Add( br.ReadNullTerminatedUTF8String( readBuffer ), br.ReadNullTerminatedUTF8String( readBuffer ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user