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( "secure", "1" );
|
||||
|
||||
filter.Add( "addr", "185.97.254.146" );
|
||||
|
||||
using ( var query = client.ServerList.Internet( filter ) )
|
||||
{
|
||||
|
||||
for ( int i = 0; i < 1000; i++ )
|
||||
{
|
||||
GC.Collect();
|
||||
@ -416,8 +417,8 @@ public void Rules()
|
||||
GC.Collect();
|
||||
System.Threading.Thread.Sleep( 10 );
|
||||
|
||||
if ( query.Responded.Count > 20 )
|
||||
break;
|
||||
// if ( query.Responded.Count > 20 )
|
||||
// break;
|
||||
|
||||
if ( query.Finished )
|
||||
break;
|
||||
@ -425,15 +426,12 @@ public void Rules()
|
||||
|
||||
query.Dispose();
|
||||
|
||||
var servers = query.Responded.Take( 10 );
|
||||
|
||||
foreach ( var server in servers )
|
||||
{
|
||||
server.FetchRules();
|
||||
}
|
||||
var servers = query.Responded.Take( 100 );
|
||||
|
||||
foreach ( var server in servers )
|
||||
{
|
||||
server.FetchRules();
|
||||
|
||||
int i = 0;
|
||||
while ( !server.HasRules )
|
||||
{
|
||||
@ -447,7 +445,10 @@ public void Rules()
|
||||
|
||||
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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
buffer = new byte[1024];
|
||||
@ -92,7 +92,7 @@ public static string ReadAnsiString( this BinaryReader br, byte[] buffer = null
|
||||
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();
|
||||
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