Files
sbox-public/engine/Sandbox.Engine/Platform/Steam/Utility/Utility.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

37 lines
729 B
C#

using System.Net;
using System.Runtime.InteropServices;
namespace Steamworks;
internal 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) +
((x & 0x0000ff00) << 8) +
((x & 0x00ff0000) >> 8) +
((x & 0xff000000) >> 24);
}
static internal IPAddress Int32ToIp( uint ipAddress )
{
return new IPAddress( Swap( ipAddress ) );
}
}