(965c31410a) Unstable v0.10.4.0

This commit is contained in:
Juan Pablo Arce
2020-07-21 08:57:50 -03:00
parent 4f8bd39789
commit 33d3a41104
546 changed files with 45952 additions and 25762 deletions
@@ -3,12 +3,29 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
namespace Steamworks
{
public static partial class Utility
{
static internal T ToType<T>( this IntPtr ptr )
{
if ( ptr == IntPtr.Zero )
return default;
return (T)Marshal.PtrToStructure( ptr, typeof( T ) );
}
static internal object ToType( this IntPtr ptr, System.Type t )
{
if ( ptr == IntPtr.Zero )
return default;
return Marshal.PtrToStructure( ptr, t );
}
static internal uint Swap( uint x )
{
return ((x & 0x000000ff) << 24) +
@@ -80,20 +97,22 @@ namespace Steamworks
}
}
public static string ReadNullTerminatedUTF8String( this BinaryReader br, byte[] buffer = null )
static readonly byte[] readBuffer = new byte[1024 * 8];
public static string ReadNullTerminatedUTF8String( this BinaryReader br )
{
if ( buffer == null )
buffer = new byte[1024];
byte chr;
int i = 0;
while ( (chr = br.ReadByte()) != 0 && i < buffer.Length )
lock ( readBuffer )
{
buffer[i] = chr;
i++;
}
byte chr;
int i = 0;
while ( (chr = br.ReadByte()) != 0 && i < readBuffer.Length )
{
readBuffer[i] = chr;
i++;
}
return Encoding.UTF8.GetString( buffer, 0, i );
return Encoding.UTF8.GetString( readBuffer, 0, i );
}
}
}
}