From 6b26323bf88e84c926dc4cf43ee2827f4962b7c6 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Sat, 13 Apr 2019 22:56:06 +0100 Subject: [PATCH] Struct callback cleanup --- .../Callbacks/ISteamCallback.cs | 2 +- Facepunch.Steamworks/Redux/Apps.cs | 2 +- Facepunch.Steamworks/Redux/Utils.cs | 2 +- .../SteamNative/SteamNative.Callback.cs | 155 +- .../SteamNative/SteamNative.SteamApps.cs | 4 +- .../SteamNative/SteamNative.SteamFriends.cs | 24 +- .../SteamNative.SteamGameServer.cs | 12 +- .../SteamNative.SteamGameServerStats.cs | 8 +- .../SteamNative.SteamHTMLSurface.cs | 4 +- .../SteamNative/SteamNative.SteamInventory.cs | 12 +- .../SteamNative.SteamMatchmaking.cs | 12 +- .../SteamNative.SteamMatchmakingServers.cs | 2 +- .../SteamNative/SteamNative.SteamParties.cs | 12 +- .../SteamNative.SteamRemoteStorage.cs | 84 +- .../SteamNative/SteamNative.SteamUGC.cs | 72 +- .../SteamNative/SteamNative.SteamUser.cs | 12 +- .../SteamNative/SteamNative.SteamUserStats.cs | 40 +- .../SteamNative/SteamNative.SteamUtils.cs | 4 +- .../SteamNative/SteamNative.Structs.cs | 29565 +--------------- Generator/CodeWriter/Class.cs | 6 +- Generator/CodeWriter/Struct.cs | 306 +- 21 files changed, 1963 insertions(+), 28377 deletions(-) diff --git a/Facepunch.Steamworks/Callbacks/ISteamCallback.cs b/Facepunch.Steamworks/Callbacks/ISteamCallback.cs index 5778851..33e296a 100644 --- a/Facepunch.Steamworks/Callbacks/ISteamCallback.cs +++ b/Facepunch.Steamworks/Callbacks/ISteamCallback.cs @@ -6,6 +6,6 @@ public interface ISteamCallback { int GetCallbackId(); int GetStructSize(); - ISteamCallback Fill( IntPtr ptr, int size ); + ISteamCallback Fill( IntPtr ptr ); } } \ No newline at end of file diff --git a/Facepunch.Steamworks/Redux/Apps.cs b/Facepunch.Steamworks/Redux/Apps.cs index 6b092cb..0db7746 100644 --- a/Facepunch.Steamworks/Redux/Apps.cs +++ b/Facepunch.Steamworks/Redux/Apps.cs @@ -235,7 +235,7 @@ public static async Task GetFileDetails( string filename ) } /// - /// Get command line if game was launched via Steam URL, e.g. steam://run////. + /// Get command line if game was launched via Steam URL, e.g. steam://run/appid//command line/. /// This method of passing a connect string (used when joining via rich presence, accepting an /// invite, etc) is preferable to passing the connect string on the operating system command /// line, which is a security risk. In order for rich presence joins to go through this diff --git a/Facepunch.Steamworks/Redux/Utils.cs b/Facepunch.Steamworks/Redux/Utils.cs index 86e8d2c..6db9dc7 100644 --- a/Facepunch.Steamworks/Redux/Utils.cs +++ b/Facepunch.Steamworks/Redux/Utils.cs @@ -47,7 +47,7 @@ internal static bool IsCallComplete( SteamAPICall_t call, out bool failed ) if ( failed ) return null; - t = (T)t.Fill( ptr, size ); + t = (T)t.Fill( ptr ); return t; } diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.Callback.cs b/Facepunch.Steamworks/SteamNative/SteamNative.Callback.cs index 238b63f..a9677fb 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.Callback.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.Callback.cs @@ -119,7 +119,138 @@ private void UnregisterCallback() public virtual bool IsValid { get { return true; } } } - internal abstract class CallResult : CallbackHandle + internal class CallbackHandle : CallbackHandle where T: struct, Steamworks.ISteamCallback + { + T template; + + internal CallbackHandle( Facepunch.Steamworks.BaseSteamworks steamworks ) : base( steamworks ) + { + template = new T(); + + // + // Create the functions we need for the vtable + // + if ( Facepunch.Steamworks.Config.UseThisCall ) + { + // + // Create the VTable by manually allocating the memory and copying across + // + if ( Platform.IsWindows ) + { + vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); + var vTable = new Callback.VTableWinThis + { + ResultA = OnResultThis, + ResultB = OnResultWithInfoThis, + GetSize = OnGetSizeThis, + }; + FuncA = GCHandle.Alloc( vTable.ResultA ); + FuncB = GCHandle.Alloc( vTable.ResultB ); + FuncC = GCHandle.Alloc( vTable.GetSize ); + Marshal.StructureToPtr( vTable, vTablePtr, false ); + } + else + { + vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); + var vTable = new Callback.VTableThis + { + ResultA = OnResultThis, + ResultB = OnResultWithInfoThis, + GetSize = OnGetSizeThis, + }; + FuncA = GCHandle.Alloc( vTable.ResultA ); + FuncB = GCHandle.Alloc( vTable.ResultB ); + FuncC = GCHandle.Alloc( vTable.GetSize ); + Marshal.StructureToPtr( vTable, vTablePtr, false ); + } + } + else + { + // + // Create the VTable by manually allocating the memory and copying across + // + if ( Platform.IsWindows ) + { + vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); + var vTable = new Callback.VTableWin + { + ResultA = OnResult, + ResultB = OnResultWithInfo, + GetSize = OnGetSize, + }; + FuncA = GCHandle.Alloc( vTable.ResultA ); + FuncB = GCHandle.Alloc( vTable.ResultB ); + FuncC = GCHandle.Alloc( vTable.GetSize ); + Marshal.StructureToPtr( vTable, vTablePtr, false ); + } + else + { + vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); + var vTable = new Callback.VTable + { + ResultA = OnResult, + ResultB = OnResultWithInfo, + GetSize = OnGetSize, + }; + FuncA = GCHandle.Alloc( vTable.ResultA ); + FuncB = GCHandle.Alloc( vTable.ResultB ); + FuncC = GCHandle.Alloc( vTable.GetSize ); + Marshal.StructureToPtr( vTable, vTablePtr, false ); + } + } + + // + // Create the callback object + // + var cb = new Callback(); + cb.vTablePtr = vTablePtr; + cb.CallbackFlags = steamworks.IsGameServer ? (byte)SteamNative.Callback.Flags.GameServer : (byte)0; + cb.CallbackId = template.GetCallbackId(); + + // + // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native + // + PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); + + // + // Register the callback with Steam + // + steamworks.native.api.SteamAPI_RegisterCallback( PinnedCallback.AddrOfPinnedObject(), cb.CallbackId ); + + steamworks.RegisterCallbackHandle( this ); + } + + [MonoPInvokeCallback] + internal void OnResultThis( IntPtr self, IntPtr param ) { OnResult( param ); } + [MonoPInvokeCallback] + internal void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) { OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback] + internal int OnGetSizeThis( IntPtr self ) { return OnGetSize(); } + [MonoPInvokeCallback] + internal int OnGetSize() { return template.GetStructSize(); } + + [MonoPInvokeCallback] + internal void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback] + internal void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) + { + if ( failure ) return; + + var value = (T) template.Fill( param ); + + if ( Facepunch.Steamworks.Client.Instance != null ) + Facepunch.Steamworks.Client.Instance.OnCallback( value ); + + if ( Facepunch.Steamworks.Server.Instance != null ) + Facepunch.Steamworks.Server.Instance.OnCallback( value ); + } + } + + internal abstract class CallResult : CallbackHandle { internal SteamAPICall_t Call; public override bool IsValid { get { return Call > 0; } } @@ -146,31 +277,27 @@ internal void Try() } - internal class CallResult : CallResult + internal class CallResult : CallResult where T : struct, Steamworks.ISteamCallback { + T template; + private static byte[] resultBuffer = new byte[1024 * 16]; internal delegate T ConvertFromPointer( IntPtr p ); Action CallbackFunction; - ConvertFromPointer ConvertFromPointerFunction; - internal int ResultSize = -1; - internal int CallbackId = 0; - - internal CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action callbackFunction, ConvertFromPointer fromPointer, int resultSize, int callbackId ) : base( steamworks, call ) + internal CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action callbackFunction ) : base( steamworks, call ) { - ResultSize = resultSize; - CallbackId = callbackId; - CallbackFunction = callbackFunction; - ConvertFromPointerFunction = fromPointer; + template = new T(); + CallbackFunction = callbackFunction; Steamworks.RegisterCallResult( this ); } public override string ToString() { - return $"CallResult( {typeof(T).Name}, {CallbackId}, {ResultSize}b )"; + return $"CallResult( {typeof(T).Name}, {template.GetCallbackId()}, {template.GetStructSize()}b )"; } unsafe internal override void RunCallback() @@ -179,13 +306,13 @@ unsafe internal override void RunCallback() fixed ( byte* ptr = resultBuffer ) { - if ( !Steamworks.native.utils.GetAPICallResult( Call, (IntPtr)ptr, resultBuffer.Length, CallbackId, ref failed ) || failed ) + if ( !Steamworks.native.utils.GetAPICallResult( Call, (IntPtr)ptr, resultBuffer.Length, template.GetCallbackId(), ref failed ) || failed ) { CallbackFunction( default(T), true ); return; } - var val = ConvertFromPointerFunction( (IntPtr)ptr ); + var val = (T) template.Fill( (IntPtr)ptr ); CallbackFunction( val, false ); } } diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamApps.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamApps.cs index 9af4ff8..db5e24d 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamApps.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamApps.cs @@ -182,7 +182,7 @@ public uint GetEarliestPurchaseUnixTime( AppId_t nAppID /*AppId_t*/ ) } // SteamAPICall_t - public CallbackHandle GetFileDetails( string pszFileName /*const char **/, Action CallbackFunction = null /*Action*/ ) + public CallResult GetFileDetails( string pszFileName /*const char **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamApps_GetFileDetails( pszFileName ); @@ -190,7 +190,7 @@ public CallbackHandle GetFileDetails( string pszFileName /*const char **/, Actio if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return FileDetailsResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // uint diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamFriends.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamFriends.cs index 53b6699..99cc338 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamFriends.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamFriends.cs @@ -90,7 +90,7 @@ public SteamAPICall_t DownloadClanActivityCounts( IntPtr psteamIDClans /*class C } // SteamAPICall_t - public CallbackHandle EnumerateFollowingList( uint unStartIndex /*uint32*/, Action CallbackFunction = null /*Action*/ ) + public CallResult EnumerateFollowingList( uint unStartIndex /*uint32*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamFriends_EnumerateFollowingList( unStartIndex ); @@ -98,7 +98,7 @@ public CallbackHandle EnumerateFollowingList( uint unStartIndex /*uint32*/, Acti if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return FriendsEnumerateFollowingList_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // ulong @@ -186,7 +186,7 @@ public int GetCoplayFriendCount() } // SteamAPICall_t - public CallbackHandle GetFollowerCount( CSteamID steamID /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) + public CallResult GetFollowerCount( CSteamID steamID /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamFriends_GetFollowerCount( steamID.Value ); @@ -194,7 +194,7 @@ public CallbackHandle GetFollowerCount( CSteamID steamID /*class CSteamID*/, Act if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return FriendsGetFollowerCount_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // ulong @@ -429,7 +429,7 @@ public bool IsClanPublic( CSteamID steamIDClan /*class CSteamID*/ ) } // SteamAPICall_t - public CallbackHandle IsFollowing( CSteamID steamID /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) + public CallResult IsFollowing( CSteamID steamID /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamFriends_IsFollowing( steamID.Value ); @@ -437,7 +437,7 @@ public CallbackHandle IsFollowing( CSteamID steamID /*class CSteamID*/, Action( steamworks, callback, CallbackFunction ); } // bool @@ -447,7 +447,7 @@ public bool IsUserInSource( CSteamID steamIDUser /*class CSteamID*/, CSteamID st } // SteamAPICall_t - public CallbackHandle JoinClanChatRoom( CSteamID steamIDClan /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) + public CallResult JoinClanChatRoom( CSteamID steamIDClan /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamFriends_JoinClanChatRoom( steamIDClan.Value ); @@ -455,7 +455,7 @@ public CallbackHandle JoinClanChatRoom( CSteamID steamIDClan /*class CSteamID*/, if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return JoinClanChatRoomCompletionResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -477,7 +477,7 @@ public bool ReplyToFriendMessage( CSteamID steamIDFriend /*class CSteamID*/, str } // SteamAPICall_t - public CallbackHandle RequestClanOfficerList( CSteamID steamIDClan /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) + public CallResult RequestClanOfficerList( CSteamID steamIDClan /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamFriends_RequestClanOfficerList( steamIDClan.Value ); @@ -485,7 +485,7 @@ public CallbackHandle RequestClanOfficerList( CSteamID steamIDClan /*class CStea if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return ClanOfficerListResponse_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // void @@ -519,7 +519,7 @@ public bool SetListenForFriendsMessages( bool bInterceptEnabled /*bool*/ ) } // SteamAPICall_t - public CallbackHandle SetPersonaName( string pchPersonaName /*const char **/, Action CallbackFunction = null /*Action*/ ) + public CallResult SetPersonaName( string pchPersonaName /*const char **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamFriends_SetPersonaName( pchPersonaName ); @@ -527,7 +527,7 @@ public CallbackHandle SetPersonaName( string pchPersonaName /*const char **/, Ac if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return SetPersonaNameResponse_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // void diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamGameServer.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamGameServer.cs index 08bd38f..7e5aa83 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamGameServer.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamGameServer.cs @@ -42,7 +42,7 @@ public virtual void Dispose() } // SteamAPICall_t - public CallbackHandle AssociateWithClan( CSteamID steamIDClan /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) + public CallResult AssociateWithClan( CSteamID steamIDClan /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamGameServer_AssociateWithClan( steamIDClan.Value ); @@ -50,7 +50,7 @@ public CallbackHandle AssociateWithClan( CSteamID steamIDClan /*class CSteamID*/ if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return AssociateWithClanResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // BeginAuthSessionResult @@ -90,7 +90,7 @@ public void ClearAllKeyValues() } // SteamAPICall_t - public CallbackHandle ComputeNewPlayerCompatibility( CSteamID steamIDNewPlayer /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) + public CallResult ComputeNewPlayerCompatibility( CSteamID steamIDNewPlayer /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamGameServer_ComputeNewPlayerCompatibility( steamIDNewPlayer.Value ); @@ -98,7 +98,7 @@ public CallbackHandle ComputeNewPlayerCompatibility( CSteamID steamIDNewPlayer / if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return ComputeNewPlayerCompatibilityResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // ulong @@ -150,7 +150,7 @@ public uint GetPublicIP() } // SteamAPICall_t - public CallbackHandle GetServerReputation( Action CallbackFunction = null /*Action*/ ) + public CallResult GetServerReputation( Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamGameServer_GetServerReputation(); @@ -158,7 +158,7 @@ public CallbackHandle GetServerReputation( Action Callback if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return GSReputation_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // ulong diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamGameServerStats.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamGameServerStats.cs index 0060ca6..4a23bcc 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamGameServerStats.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamGameServerStats.cs @@ -66,7 +66,7 @@ public bool GetUserStat0( CSteamID steamIDUser /*class CSteamID*/, string pchNam } // SteamAPICall_t - public CallbackHandle RequestUserStats( CSteamID steamIDUser /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) + public CallResult RequestUserStats( CSteamID steamIDUser /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamGameServerStats_RequestUserStats( steamIDUser.Value ); @@ -74,7 +74,7 @@ public CallbackHandle RequestUserStats( CSteamID steamIDUser /*class CSteamID*/, if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return GSStatsReceived_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -96,7 +96,7 @@ public bool SetUserStat0( CSteamID steamIDUser /*class CSteamID*/, string pchNam } // SteamAPICall_t - public CallbackHandle StoreUserStats( CSteamID steamIDUser /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) + public CallResult StoreUserStats( CSteamID steamIDUser /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamGameServerStats_StoreUserStats( steamIDUser.Value ); @@ -104,7 +104,7 @@ public CallbackHandle StoreUserStats( CSteamID steamIDUser /*class CSteamID*/, A if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return GSStatsStored_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamHTMLSurface.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamHTMLSurface.cs index e9fd0a1..6494d58 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamHTMLSurface.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamHTMLSurface.cs @@ -60,7 +60,7 @@ public void CopyToClipboard( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ ) } // SteamAPICall_t - public CallbackHandle CreateBrowser( string pchUserAgent /*const char **/, string pchUserCSS /*const char **/, Action CallbackFunction = null /*Action*/ ) + public CallResult CreateBrowser( string pchUserAgent /*const char **/, string pchUserCSS /*const char **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamHTMLSurface_CreateBrowser( pchUserAgent, pchUserCSS ); @@ -68,7 +68,7 @@ public CallbackHandle CreateBrowser( string pchUserAgent /*const char **/, strin if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return HTML_BrowserReady_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // void diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamInventory.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamInventory.cs index 4f1ea2d..3041544 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamInventory.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamInventory.cs @@ -235,7 +235,7 @@ public bool RemoveProperty( SteamInventoryUpdateHandle_t handle /*SteamInventory } // SteamAPICall_t - public CallbackHandle RequestEligiblePromoItemDefinitionsIDs( CSteamID steamID /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) + public CallResult RequestEligiblePromoItemDefinitionsIDs( CSteamID steamID /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamInventory_RequestEligiblePromoItemDefinitionsIDs( steamID.Value ); @@ -243,11 +243,11 @@ public CallbackHandle RequestEligiblePromoItemDefinitionsIDs( CSteamID steamID / if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return SteamInventoryEligiblePromoItemDefIDs_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle RequestPrices( Action CallbackFunction = null /*Action*/ ) + public CallResult RequestPrices( Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamInventory_RequestPrices(); @@ -255,7 +255,7 @@ public CallbackHandle RequestPrices( Action( steamworks, callback, CallbackFunction ); } // void @@ -295,7 +295,7 @@ public bool SetProperty2( SteamInventoryUpdateHandle_t handle /*SteamInventoryUp } // SteamAPICall_t - public CallbackHandle StartPurchase( SteamItemDef_t[] pArrayItemDefs /*const SteamItemDef_t **/, uint[] punArrayQuantity /*const uint32 **/, uint unArrayLength /*uint32*/, Action CallbackFunction = null /*Action*/ ) + public CallResult StartPurchase( SteamItemDef_t[] pArrayItemDefs /*const SteamItemDef_t **/, uint[] punArrayQuantity /*const uint32 **/, uint unArrayLength /*uint32*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamInventory_StartPurchase( pArrayItemDefs.Select( x => x.Value ).ToArray(), punArrayQuantity, unArrayLength ); @@ -303,7 +303,7 @@ public CallbackHandle StartPurchase( SteamItemDef_t[] pArrayItemDefs /*const Ste if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return SteamInventoryStartPurchaseResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamInventoryUpdateHandle_t diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamMatchmaking.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamMatchmaking.cs index 6417bef..fdee019 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamMatchmaking.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamMatchmaking.cs @@ -90,7 +90,7 @@ public void AddRequestLobbyListStringFilter( string pchKeyToMatch /*const char * } // SteamAPICall_t - public CallbackHandle CreateLobby( LobbyType eLobbyType /*ELobbyType*/, int cMaxMembers /*int*/, Action CallbackFunction = null /*Action*/ ) + public CallResult CreateLobby( LobbyType eLobbyType /*ELobbyType*/, int cMaxMembers /*int*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamMatchmaking_CreateLobby( eLobbyType, cMaxMembers ); @@ -98,7 +98,7 @@ public CallbackHandle CreateLobby( LobbyType eLobbyType /*ELobbyType*/, int cMax if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return LobbyCreated_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -212,7 +212,7 @@ public bool InviteUserToLobby( CSteamID steamIDLobby /*class CSteamID*/, CSteamI } // SteamAPICall_t - public CallbackHandle JoinLobby( CSteamID steamIDLobby /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) + public CallResult JoinLobby( CSteamID steamIDLobby /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamMatchmaking_JoinLobby( steamIDLobby.Value ); @@ -220,7 +220,7 @@ public CallbackHandle JoinLobby( CSteamID steamIDLobby /*class CSteamID*/, Actio if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return LobbyEnter_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // void @@ -242,7 +242,7 @@ public bool RequestLobbyData( CSteamID steamIDLobby /*class CSteamID*/ ) } // SteamAPICall_t - public CallbackHandle RequestLobbyList( Action CallbackFunction = null /*Action*/ ) + public CallResult RequestLobbyList( Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamMatchmaking_RequestLobbyList(); @@ -250,7 +250,7 @@ public CallbackHandle RequestLobbyList( Action CallbackF if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return LobbyMatchList_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamMatchmakingServers.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamMatchmakingServers.cs index dd34634..5d2e3c6 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamMatchmakingServers.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamMatchmakingServers.cs @@ -66,7 +66,7 @@ public gameserveritem_t GetServerDetails( HServerListRequest hRequest /*HServerL IntPtr struct_pointer; struct_pointer = platform.ISteamMatchmakingServers_GetServerDetails( hRequest.Value, iServer ); if ( struct_pointer == IntPtr.Zero ) return default(gameserveritem_t); - return gameserveritem_t.FromPointer( struct_pointer ); + return new gameserveritem_t().Fill( struct_pointer ); } // bool diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamParties.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamParties.cs index c5d6da0..6f4a3ae 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamParties.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamParties.cs @@ -48,7 +48,7 @@ public void CancelReservation( PartyBeaconID_t ulBeacon /*PartyBeaconID_t*/, CSt } // SteamAPICall_t - public CallbackHandle ChangeNumOpenSlots( PartyBeaconID_t ulBeacon /*PartyBeaconID_t*/, uint unOpenSlots /*uint32*/, Action CallbackFunction = null /*Action*/ ) + public CallResult ChangeNumOpenSlots( PartyBeaconID_t ulBeacon /*PartyBeaconID_t*/, uint unOpenSlots /*uint32*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamParties_ChangeNumOpenSlots( ulBeacon.Value, unOpenSlots ); @@ -56,11 +56,11 @@ public CallbackHandle ChangeNumOpenSlots( PartyBeaconID_t ulBeacon /*PartyBeacon if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return ChangeNumOpenSlotsCallback_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle CreateBeacon( uint unOpenSlots /*uint32*/, ref SteamPartyBeaconLocation_t pBeaconLocation /*struct SteamPartyBeaconLocation_t **/, string pchConnectString /*const char **/, string pchMetadata /*const char **/, Action CallbackFunction = null /*Action*/ ) + public CallResult CreateBeacon( uint unOpenSlots /*uint32*/, ref SteamPartyBeaconLocation_t pBeaconLocation /*struct SteamPartyBeaconLocation_t **/, string pchConnectString /*const char **/, string pchMetadata /*const char **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamParties_CreateBeacon( unOpenSlots, ref pBeaconLocation, pchConnectString, pchMetadata ); @@ -68,7 +68,7 @@ public CallbackHandle CreateBeacon( uint unOpenSlots /*uint32*/, ref SteamPartyB if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return CreateBeaconCallback_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -130,7 +130,7 @@ public bool GetNumAvailableBeaconLocations( IntPtr puNumLocations /*uint32 **/ ) } // SteamAPICall_t - public CallbackHandle JoinParty( PartyBeaconID_t ulBeaconID /*PartyBeaconID_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult JoinParty( PartyBeaconID_t ulBeaconID /*PartyBeaconID_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamParties_JoinParty( ulBeaconID.Value ); @@ -138,7 +138,7 @@ public CallbackHandle JoinParty( PartyBeaconID_t ulBeaconID /*PartyBeaconID_t*/, if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return JoinPartyCallback_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // void diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamRemoteStorage.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamRemoteStorage.cs index 741ec0a..68a3293 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamRemoteStorage.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamRemoteStorage.cs @@ -42,7 +42,7 @@ public virtual void Dispose() } // SteamAPICall_t - public CallbackHandle CommitPublishedFileUpdate( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult CommitPublishedFileUpdate( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_CommitPublishedFileUpdate( updateHandle.Value ); @@ -50,7 +50,7 @@ public CallbackHandle CommitPublishedFileUpdate( PublishedFileUpdateHandle_t upd if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageUpdatePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // PublishedFileUpdateHandle_t @@ -60,7 +60,7 @@ public PublishedFileUpdateHandle_t CreatePublishedFileUpdateRequest( PublishedFi } // SteamAPICall_t - public CallbackHandle DeletePublishedFile( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult DeletePublishedFile( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_DeletePublishedFile( unPublishedFileId.Value ); @@ -68,11 +68,11 @@ public CallbackHandle DeletePublishedFile( PublishedFileId_t unPublishedFileId / if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageDeletePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle EnumeratePublishedFilesByUserAction( WorkshopFileAction eAction /*EWorkshopFileAction*/, uint unStartIndex /*uint32*/, Action CallbackFunction = null /*Action*/ ) + public CallResult EnumeratePublishedFilesByUserAction( WorkshopFileAction eAction /*EWorkshopFileAction*/, uint unStartIndex /*uint32*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_EnumeratePublishedFilesByUserAction( eAction, unStartIndex ); @@ -80,12 +80,12 @@ public CallbackHandle EnumeratePublishedFilesByUserAction( WorkshopFileAction eA if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageEnumeratePublishedFilesByUserActionResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t // using: Detect_StringArray - public CallbackHandle EnumeratePublishedWorkshopFiles( WorkshopEnumerationType eEnumerationType /*EWorkshopEnumerationType*/, uint unStartIndex /*uint32*/, uint unCount /*uint32*/, uint unDays /*uint32*/, string[] pTags /*struct SteamParamStringArray_t **/, ref SteamParamStringArray_t pUserTags /*struct SteamParamStringArray_t **/, Action CallbackFunction = null /*Action*/ ) + public CallResult EnumeratePublishedWorkshopFiles( WorkshopEnumerationType eEnumerationType /*EWorkshopEnumerationType*/, uint unStartIndex /*uint32*/, uint unCount /*uint32*/, uint unDays /*uint32*/, string[] pTags /*struct SteamParamStringArray_t **/, ref SteamParamStringArray_t pUserTags /*struct SteamParamStringArray_t **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; // Create strings @@ -118,11 +118,11 @@ public CallbackHandle EnumeratePublishedWorkshopFiles( WorkshopEnumerationType e if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageEnumerateWorkshopFilesResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle EnumerateUserPublishedFiles( uint unStartIndex /*uint32*/, Action CallbackFunction = null /*Action*/ ) + public CallResult EnumerateUserPublishedFiles( uint unStartIndex /*uint32*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_EnumerateUserPublishedFiles( unStartIndex ); @@ -130,12 +130,12 @@ public CallbackHandle EnumerateUserPublishedFiles( uint unStartIndex /*uint32*/, if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageEnumerateUserPublishedFilesResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t // using: Detect_StringArray - public CallbackHandle EnumerateUserSharedWorkshopFiles( CSteamID steamId /*class CSteamID*/, uint unStartIndex /*uint32*/, string[] pRequiredTags /*struct SteamParamStringArray_t **/, ref SteamParamStringArray_t pExcludedTags /*struct SteamParamStringArray_t **/, Action CallbackFunction = null /*Action*/ ) + public CallResult EnumerateUserSharedWorkshopFiles( CSteamID steamId /*class CSteamID*/, uint unStartIndex /*uint32*/, string[] pRequiredTags /*struct SteamParamStringArray_t **/, ref SteamParamStringArray_t pExcludedTags /*struct SteamParamStringArray_t **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; // Create strings @@ -168,11 +168,11 @@ public CallbackHandle EnumerateUserSharedWorkshopFiles( CSteamID steamId /*class if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageEnumerateUserPublishedFilesResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle EnumerateUserSubscribedFiles( uint unStartIndex /*uint32*/, Action CallbackFunction = null /*Action*/ ) + public CallResult EnumerateUserSubscribedFiles( uint unStartIndex /*uint32*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_EnumerateUserSubscribedFiles( unStartIndex ); @@ -180,7 +180,7 @@ public CallbackHandle EnumerateUserSubscribedFiles( uint unStartIndex /*uint32*/ if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageEnumerateUserSubscribedFilesResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -214,7 +214,7 @@ public int FileRead( string pchFile /*const char **/, IntPtr pvData /*void **/, } // SteamAPICall_t - public CallbackHandle FileReadAsync( string pchFile /*const char **/, uint nOffset /*uint32*/, uint cubToRead /*uint32*/, Action CallbackFunction = null /*Action*/ ) + public CallResult FileReadAsync( string pchFile /*const char **/, uint nOffset /*uint32*/, uint cubToRead /*uint32*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_FileReadAsync( pchFile, nOffset, cubToRead ); @@ -222,7 +222,7 @@ public CallbackHandle FileReadAsync( string pchFile /*const char **/, uint nOffs if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageFileReadAsyncComplete_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -232,7 +232,7 @@ public bool FileReadAsyncComplete( SteamAPICall_t hReadCall /*SteamAPICall_t*/, } // SteamAPICall_t - public CallbackHandle FileShare( string pchFile /*const char **/, Action CallbackFunction = null /*Action*/ ) + public CallResult FileShare( string pchFile /*const char **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_FileShare( pchFile ); @@ -240,7 +240,7 @@ public CallbackHandle FileShare( string pchFile /*const char **/, Action( steamworks, callback, CallbackFunction ); } // bool @@ -250,7 +250,7 @@ public bool FileWrite( string pchFile /*const char **/, IntPtr pvData /*const vo } // SteamAPICall_t - public CallbackHandle FileWriteAsync( string pchFile /*const char **/, IntPtr pvData /*const void **/, uint cubData /*uint32*/, Action CallbackFunction = null /*Action*/ ) + public CallResult FileWriteAsync( string pchFile /*const char **/, IntPtr pvData /*const void **/, uint cubData /*uint32*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_FileWriteAsync( pchFile, (IntPtr) pvData, cubData ); @@ -258,7 +258,7 @@ public CallbackHandle FileWriteAsync( string pchFile /*const char **/, IntPtr pv if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageFileWriteAsyncComplete_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -325,7 +325,7 @@ public long GetFileTimestamp( string pchFile /*const char **/ ) } // SteamAPICall_t - public CallbackHandle GetPublishedFileDetails( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, uint unMaxSecondsOld /*uint32*/, Action CallbackFunction = null /*Action*/ ) + public CallResult GetPublishedFileDetails( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, uint unMaxSecondsOld /*uint32*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_GetPublishedFileDetails( unPublishedFileId.Value, unMaxSecondsOld ); @@ -333,11 +333,11 @@ public CallbackHandle GetPublishedFileDetails( PublishedFileId_t unPublishedFile if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageGetPublishedFileDetailsResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle GetPublishedItemVoteDetails( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult GetPublishedItemVoteDetails( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_GetPublishedItemVoteDetails( unPublishedFileId.Value ); @@ -345,7 +345,7 @@ public CallbackHandle GetPublishedItemVoteDetails( PublishedFileId_t unPublished if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageGetPublishedItemVoteDetailsResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -381,7 +381,7 @@ public bool GetUGCDownloadProgress( UGCHandle_t hContent /*UGCHandle_t*/, out in } // SteamAPICall_t - public CallbackHandle GetUserPublishedItemVoteDetails( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult GetUserPublishedItemVoteDetails( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_GetUserPublishedItemVoteDetails( unPublishedFileId.Value ); @@ -389,7 +389,7 @@ public CallbackHandle GetUserPublishedItemVoteDetails( PublishedFileId_t unPubli if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageGetPublishedItemVoteDetailsResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -406,7 +406,7 @@ public bool IsCloudEnabledForApp() // SteamAPICall_t // using: Detect_StringArray - public CallbackHandle PublishVideo( WorkshopVideoProvider eVideoProvider /*EWorkshopVideoProvider*/, string pchVideoAccount /*const char **/, string pchVideoIdentifier /*const char **/, string pchPreviewFile /*const char **/, AppId_t nConsumerAppId /*AppId_t*/, string pchTitle /*const char **/, string pchDescription /*const char **/, RemoteStoragePublishedFileVisibility eVisibility /*ERemoteStoragePublishedFileVisibility*/, string[] pTags /*struct SteamParamStringArray_t **/, Action CallbackFunction = null /*Action*/ ) + public CallResult PublishVideo( WorkshopVideoProvider eVideoProvider /*EWorkshopVideoProvider*/, string pchVideoAccount /*const char **/, string pchVideoIdentifier /*const char **/, string pchPreviewFile /*const char **/, AppId_t nConsumerAppId /*AppId_t*/, string pchTitle /*const char **/, string pchDescription /*const char **/, RemoteStoragePublishedFileVisibility eVisibility /*ERemoteStoragePublishedFileVisibility*/, string[] pTags /*struct SteamParamStringArray_t **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; // Create strings @@ -439,12 +439,12 @@ public CallbackHandle PublishVideo( WorkshopVideoProvider eVideoProvider /*EWork if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStoragePublishFileProgress_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t // using: Detect_StringArray - public CallbackHandle PublishWorkshopFile( string pchFile /*const char **/, string pchPreviewFile /*const char **/, AppId_t nConsumerAppId /*AppId_t*/, string pchTitle /*const char **/, string pchDescription /*const char **/, RemoteStoragePublishedFileVisibility eVisibility /*ERemoteStoragePublishedFileVisibility*/, string[] pTags /*struct SteamParamStringArray_t **/, WorkshopFileType eWorkshopFileType /*EWorkshopFileType*/, Action CallbackFunction = null /*Action*/ ) + public CallResult PublishWorkshopFile( string pchFile /*const char **/, string pchPreviewFile /*const char **/, AppId_t nConsumerAppId /*AppId_t*/, string pchTitle /*const char **/, string pchDescription /*const char **/, RemoteStoragePublishedFileVisibility eVisibility /*ERemoteStoragePublishedFileVisibility*/, string[] pTags /*struct SteamParamStringArray_t **/, WorkshopFileType eWorkshopFileType /*EWorkshopFileType*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; // Create strings @@ -477,7 +477,7 @@ public CallbackHandle PublishWorkshopFile( string pchFile /*const char **/, stri if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStoragePublishFileProgress_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // void @@ -493,7 +493,7 @@ public bool SetSyncPlatforms( string pchFile /*const char **/, RemoteStoragePlat } // SteamAPICall_t - public CallbackHandle SetUserPublishedFileAction( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, WorkshopFileAction eAction /*EWorkshopFileAction*/, Action CallbackFunction = null /*Action*/ ) + public CallResult SetUserPublishedFileAction( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, WorkshopFileAction eAction /*EWorkshopFileAction*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_SetUserPublishedFileAction( unPublishedFileId.Value, eAction ); @@ -501,11 +501,11 @@ public CallbackHandle SetUserPublishedFileAction( PublishedFileId_t unPublishedF if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageSetUserPublishedFileActionResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle SubscribePublishedFile( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult SubscribePublishedFile( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_SubscribePublishedFile( unPublishedFileId.Value ); @@ -513,11 +513,11 @@ public CallbackHandle SubscribePublishedFile( PublishedFileId_t unPublishedFileI if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageSubscribePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle UGCDownload( UGCHandle_t hContent /*UGCHandle_t*/, uint unPriority /*uint32*/, Action CallbackFunction = null /*Action*/ ) + public CallResult UGCDownload( UGCHandle_t hContent /*UGCHandle_t*/, uint unPriority /*uint32*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_UGCDownload( hContent.Value, unPriority ); @@ -525,11 +525,11 @@ public CallbackHandle UGCDownload( UGCHandle_t hContent /*UGCHandle_t*/, uint un if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageDownloadUGCResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle UGCDownloadToLocation( UGCHandle_t hContent /*UGCHandle_t*/, string pchLocation /*const char **/, uint unPriority /*uint32*/, Action CallbackFunction = null /*Action*/ ) + public CallResult UGCDownloadToLocation( UGCHandle_t hContent /*UGCHandle_t*/, string pchLocation /*const char **/, uint unPriority /*uint32*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_UGCDownloadToLocation( hContent.Value, pchLocation, unPriority ); @@ -537,7 +537,7 @@ public CallbackHandle UGCDownloadToLocation( UGCHandle_t hContent /*UGCHandle_t* if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageDownloadUGCResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // int @@ -547,7 +547,7 @@ public int UGCRead( UGCHandle_t hContent /*UGCHandle_t*/, IntPtr pvData /*void * } // SteamAPICall_t - public CallbackHandle UnsubscribePublishedFile( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult UnsubscribePublishedFile( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_UnsubscribePublishedFile( unPublishedFileId.Value ); @@ -555,7 +555,7 @@ public CallbackHandle UnsubscribePublishedFile( PublishedFileId_t unPublishedFil if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageUnsubscribePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -627,7 +627,7 @@ public bool UpdatePublishedFileVisibility( PublishedFileUpdateHandle_t updateHan } // SteamAPICall_t - public CallbackHandle UpdateUserPublishedItemVote( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, bool bVoteUp /*bool*/, Action CallbackFunction = null /*Action*/ ) + public CallResult UpdateUserPublishedItemVote( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, bool bVoteUp /*bool*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_UpdateUserPublishedItemVote( unPublishedFileId.Value, bVoteUp ); @@ -635,7 +635,7 @@ public CallbackHandle UpdateUserPublishedItemVote( PublishedFileId_t unPublished if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageUpdateUserPublishedItemVoteResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } } diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamUGC.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamUGC.cs index 6a8570f..b10c078 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamUGC.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamUGC.cs @@ -42,7 +42,7 @@ public virtual void Dispose() } // SteamAPICall_t - public CallbackHandle AddAppDependency( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, AppId_t nAppID /*AppId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult AddAppDependency( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, AppId_t nAppID /*AppId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_AddAppDependency( nPublishedFileID.Value, nAppID.Value ); @@ -50,11 +50,11 @@ public CallbackHandle AddAppDependency( PublishedFileId_t nPublishedFileID /*Pub if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return AddAppDependencyResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle AddDependency( PublishedFileId_t nParentPublishedFileID /*PublishedFileId_t*/, PublishedFileId_t nChildPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult AddDependency( PublishedFileId_t nParentPublishedFileID /*PublishedFileId_t*/, PublishedFileId_t nChildPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_AddDependency( nParentPublishedFileID.Value, nChildPublishedFileID.Value ); @@ -62,7 +62,7 @@ public CallbackHandle AddDependency( PublishedFileId_t nParentPublishedFileID /* if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return AddUGCDependencyResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -90,7 +90,7 @@ public bool AddItemPreviewVideo( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, } // SteamAPICall_t - public CallbackHandle AddItemToFavorites( AppId_t nAppId /*AppId_t*/, PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult AddItemToFavorites( AppId_t nAppId /*AppId_t*/, PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_AddItemToFavorites( nAppId.Value, nPublishedFileID.Value ); @@ -98,7 +98,7 @@ public CallbackHandle AddItemToFavorites( AppId_t nAppId /*AppId_t*/, PublishedF if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return UserFavoriteItemsListChanged_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -120,7 +120,7 @@ public bool BInitWorkshopForGameServer( DepotId_t unWorkshopDepotID /*DepotId_t* } // SteamAPICall_t - public CallbackHandle CreateItem( AppId_t nConsumerAppId /*AppId_t*/, WorkshopFileType eFileType /*EWorkshopFileType*/, Action CallbackFunction = null /*Action*/ ) + public CallResult CreateItem( AppId_t nConsumerAppId /*AppId_t*/, WorkshopFileType eFileType /*EWorkshopFileType*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_CreateItem( nConsumerAppId.Value, eFileType ); @@ -128,7 +128,7 @@ public CallbackHandle CreateItem( AppId_t nConsumerAppId /*AppId_t*/, WorkshopFi if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return CreateItemResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // UGCQueryHandle_t @@ -161,7 +161,7 @@ public UGCQueryHandle_t CreateQueryUserUGCRequest( AccountID_t unAccountID /*Acc } // SteamAPICall_t - public CallbackHandle DeleteItem( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult DeleteItem( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_DeleteItem( nPublishedFileID.Value ); @@ -169,7 +169,7 @@ public CallbackHandle DeleteItem( PublishedFileId_t nPublishedFileID /*Published if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return DeleteItemResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -179,7 +179,7 @@ public bool DownloadItem( PublishedFileId_t nPublishedFileID /*PublishedFileId_t } // SteamAPICall_t - public CallbackHandle GetAppDependencies( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult GetAppDependencies( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_GetAppDependencies( nPublishedFileID.Value ); @@ -187,7 +187,7 @@ public CallbackHandle GetAppDependencies( PublishedFileId_t nPublishedFileID /*P if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return GetAppDependenciesResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -333,7 +333,7 @@ public uint GetSubscribedItems( PublishedFileId_t* pvecPublishedFileID /*Publish } // SteamAPICall_t - public CallbackHandle GetUserItemVote( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult GetUserItemVote( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_GetUserItemVote( nPublishedFileID.Value ); @@ -341,7 +341,7 @@ public CallbackHandle GetUserItemVote( PublishedFileId_t nPublishedFileID /*Publ if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return GetUserItemVoteResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -351,7 +351,7 @@ public bool ReleaseQueryUGCRequest( UGCQueryHandle_t handle /*UGCQueryHandle_t*/ } // SteamAPICall_t - public CallbackHandle RemoveAppDependency( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, AppId_t nAppID /*AppId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult RemoveAppDependency( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, AppId_t nAppID /*AppId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_RemoveAppDependency( nPublishedFileID.Value, nAppID.Value ); @@ -359,11 +359,11 @@ public CallbackHandle RemoveAppDependency( PublishedFileId_t nPublishedFileID /* if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoveAppDependencyResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle RemoveDependency( PublishedFileId_t nParentPublishedFileID /*PublishedFileId_t*/, PublishedFileId_t nChildPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult RemoveDependency( PublishedFileId_t nParentPublishedFileID /*PublishedFileId_t*/, PublishedFileId_t nChildPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_RemoveDependency( nParentPublishedFileID.Value, nChildPublishedFileID.Value ); @@ -371,11 +371,11 @@ public CallbackHandle RemoveDependency( PublishedFileId_t nParentPublishedFileID if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoveUGCDependencyResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle RemoveItemFromFavorites( AppId_t nAppId /*AppId_t*/, PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult RemoveItemFromFavorites( AppId_t nAppId /*AppId_t*/, PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_RemoveItemFromFavorites( nAppId.Value, nPublishedFileID.Value ); @@ -383,7 +383,7 @@ public CallbackHandle RemoveItemFromFavorites( AppId_t nAppId /*AppId_t*/, Publi if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return UserFavoriteItemsListChanged_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -405,7 +405,7 @@ public SteamAPICall_t RequestUGCDetails( PublishedFileId_t nPublishedFileID /*Pu } // SteamAPICall_t - public CallbackHandle SendQueryUGCRequest( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult SendQueryUGCRequest( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_SendQueryUGCRequest( handle.Value ); @@ -413,7 +413,7 @@ public CallbackHandle SendQueryUGCRequest( UGCQueryHandle_t handle /*UGCQueryHan if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return SteamUGCQueryCompleted_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -581,7 +581,7 @@ public bool SetSearchText( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, string } // SteamAPICall_t - public CallbackHandle SetUserItemVote( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, bool bVoteUp /*bool*/, Action CallbackFunction = null /*Action*/ ) + public CallResult SetUserItemVote( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, bool bVoteUp /*bool*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_SetUserItemVote( nPublishedFileID.Value, bVoteUp ); @@ -589,7 +589,7 @@ public CallbackHandle SetUserItemVote( PublishedFileId_t nPublishedFileID /*Publ if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return SetUserItemVoteResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // UGCUpdateHandle_t @@ -600,7 +600,7 @@ public UGCUpdateHandle_t StartItemUpdate( AppId_t nConsumerAppId /*AppId_t*/, Pu // with: Detect_VectorReturn // SteamAPICall_t - public CallbackHandle StartPlaytimeTracking( PublishedFileId_t[] pvecPublishedFileID /*PublishedFileId_t **/, Action CallbackFunction = null /*Action*/ ) + public CallResult StartPlaytimeTracking( PublishedFileId_t[] pvecPublishedFileID /*PublishedFileId_t **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; var unNumPublishedFileIDs = (uint) pvecPublishedFileID.Length; @@ -612,12 +612,12 @@ public CallbackHandle StartPlaytimeTracking( PublishedFileId_t[] pvecPublishedFi if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return StartPlaytimeTrackingResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // with: Detect_VectorReturn // SteamAPICall_t - public CallbackHandle StopPlaytimeTracking( PublishedFileId_t[] pvecPublishedFileID /*PublishedFileId_t **/, Action CallbackFunction = null /*Action*/ ) + public CallResult StopPlaytimeTracking( PublishedFileId_t[] pvecPublishedFileID /*PublishedFileId_t **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; var unNumPublishedFileIDs = (uint) pvecPublishedFileID.Length; @@ -629,11 +629,11 @@ public CallbackHandle StopPlaytimeTracking( PublishedFileId_t[] pvecPublishedFil if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return StopPlaytimeTrackingResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle StopPlaytimeTrackingForAllItems( Action CallbackFunction = null /*Action*/ ) + public CallResult StopPlaytimeTrackingForAllItems( Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_StopPlaytimeTrackingForAllItems(); @@ -641,11 +641,11 @@ public CallbackHandle StopPlaytimeTrackingForAllItems( Action( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle SubmitItemUpdate( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchChangeNote /*const char **/, Action CallbackFunction = null /*Action*/ ) + public CallResult SubmitItemUpdate( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchChangeNote /*const char **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_SubmitItemUpdate( handle.Value, pchChangeNote ); @@ -653,11 +653,11 @@ public CallbackHandle SubmitItemUpdate( UGCUpdateHandle_t handle /*UGCUpdateHand if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return SubmitItemUpdateResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle SubscribeItem( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult SubscribeItem( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_SubscribeItem( nPublishedFileID.Value ); @@ -665,7 +665,7 @@ public CallbackHandle SubscribeItem( PublishedFileId_t nPublishedFileID /*Publis if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageSubscribePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // void @@ -675,7 +675,7 @@ public void SuspendDownloads( bool bSuspend /*bool*/ ) } // SteamAPICall_t - public CallbackHandle UnsubscribeItem( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult UnsubscribeItem( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUGC_UnsubscribeItem( nPublishedFileID.Value ); @@ -683,7 +683,7 @@ public CallbackHandle UnsubscribeItem( PublishedFileId_t nPublishedFileID /*Publ if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return RemoteStorageUnsubscribePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamUser.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamUser.cs index 266afd3..899c4b4 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamUser.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamUser.cs @@ -138,7 +138,7 @@ public HSteamUser GetHSteamUser() } // SteamAPICall_t - public CallbackHandle GetMarketEligibility( Action CallbackFunction = null /*Action*/ ) + public CallResult GetMarketEligibility( Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUser_GetMarketEligibility(); @@ -146,7 +146,7 @@ public CallbackHandle GetMarketEligibility( Action( steamworks, callback, CallbackFunction ); } // int @@ -192,7 +192,7 @@ public int InitiateGameConnection( IntPtr pAuthBlob /*void **/, int cbMaxAuthBlo } // SteamAPICall_t - public CallbackHandle RequestEncryptedAppTicket( IntPtr pDataToInclude /*void **/, int cbDataToInclude /*int*/, Action CallbackFunction = null /*Action*/ ) + public CallResult RequestEncryptedAppTicket( IntPtr pDataToInclude /*void **/, int cbDataToInclude /*int*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUser_RequestEncryptedAppTicket( (IntPtr) pDataToInclude, cbDataToInclude ); @@ -200,11 +200,11 @@ public CallbackHandle RequestEncryptedAppTicket( IntPtr pDataToInclude /*void ** if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return EncryptedAppTicketResponse_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle RequestStoreAuthURL( string pchRedirectURL /*const char **/, Action CallbackFunction = null /*Action*/ ) + public CallResult RequestStoreAuthURL( string pchRedirectURL /*const char **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUser_RequestStoreAuthURL( pchRedirectURL ); @@ -212,7 +212,7 @@ public CallbackHandle RequestStoreAuthURL( string pchRedirectURL /*const char ** if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return StoreAuthURLResponse_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // void diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamUserStats.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamUserStats.cs index c38acc1..1d92cf9 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamUserStats.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamUserStats.cs @@ -42,7 +42,7 @@ public virtual void Dispose() } // SteamAPICall_t - public CallbackHandle AttachLeaderboardUGC( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, UGCHandle_t hUGC /*UGCHandle_t*/, Action CallbackFunction = null /*Action*/ ) + public CallResult AttachLeaderboardUGC( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, UGCHandle_t hUGC /*UGCHandle_t*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUserStats_AttachLeaderboardUGC( hSteamLeaderboard.Value, hUGC.Value ); @@ -50,7 +50,7 @@ public CallbackHandle AttachLeaderboardUGC( SteamLeaderboard_t hSteamLeaderboard if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return LeaderboardUGCSet_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -60,7 +60,7 @@ public bool ClearAchievement( string pchName /*const char **/ ) } // SteamAPICall_t - public CallbackHandle DownloadLeaderboardEntries( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, LeaderboardDataRequest eLeaderboardDataRequest /*ELeaderboardDataRequest*/, int nRangeStart /*int*/, int nRangeEnd /*int*/, Action CallbackFunction = null /*Action*/ ) + public CallResult DownloadLeaderboardEntries( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, LeaderboardDataRequest eLeaderboardDataRequest /*ELeaderboardDataRequest*/, int nRangeStart /*int*/, int nRangeEnd /*int*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUserStats_DownloadLeaderboardEntries( hSteamLeaderboard.Value, eLeaderboardDataRequest, nRangeStart, nRangeEnd ); @@ -68,11 +68,11 @@ public CallbackHandle DownloadLeaderboardEntries( SteamLeaderboard_t hSteamLeade if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return LeaderboardScoresDownloaded_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle DownloadLeaderboardEntriesForUsers( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, IntPtr prgUsers /*class CSteamID **/, int cUsers /*int*/, Action CallbackFunction = null /*Action*/ ) + public CallResult DownloadLeaderboardEntriesForUsers( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, IntPtr prgUsers /*class CSteamID **/, int cUsers /*int*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUserStats_DownloadLeaderboardEntriesForUsers( hSteamLeaderboard.Value, (IntPtr) prgUsers, cUsers ); @@ -80,11 +80,11 @@ public CallbackHandle DownloadLeaderboardEntriesForUsers( SteamLeaderboard_t hSt if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return LeaderboardScoresDownloaded_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle FindLeaderboard( string pchLeaderboardName /*const char **/, Action CallbackFunction = null /*Action*/ ) + public CallResult FindLeaderboard( string pchLeaderboardName /*const char **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUserStats_FindLeaderboard( pchLeaderboardName ); @@ -92,11 +92,11 @@ public CallbackHandle FindLeaderboard( string pchLeaderboardName /*const char ** if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return LeaderboardFindResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle FindOrCreateLeaderboard( string pchLeaderboardName /*const char **/, LeaderboardSortMethod eLeaderboardSortMethod /*ELeaderboardSortMethod*/, LeaderboardDisplayType eLeaderboardDisplayType /*ELeaderboardDisplayType*/, Action CallbackFunction = null /*Action*/ ) + public CallResult FindOrCreateLeaderboard( string pchLeaderboardName /*const char **/, LeaderboardSortMethod eLeaderboardSortMethod /*ELeaderboardSortMethod*/, LeaderboardDisplayType eLeaderboardDisplayType /*ELeaderboardDisplayType*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUserStats_FindOrCreateLeaderboard( pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType ); @@ -104,7 +104,7 @@ public CallbackHandle FindOrCreateLeaderboard( string pchLeaderboardName /*const if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return LeaderboardFindResult_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -241,7 +241,7 @@ public uint GetNumAchievements() } // SteamAPICall_t - public CallbackHandle GetNumberOfCurrentPlayers( Action CallbackFunction = null /*Action*/ ) + public CallResult GetNumberOfCurrentPlayers( Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUserStats_GetNumberOfCurrentPlayers(); @@ -249,7 +249,7 @@ public CallbackHandle GetNumberOfCurrentPlayers( Action( steamworks, callback, CallbackFunction ); } // bool @@ -301,7 +301,7 @@ public bool RequestCurrentStats() } // SteamAPICall_t - public CallbackHandle RequestGlobalAchievementPercentages( Action CallbackFunction = null /*Action*/ ) + public CallResult RequestGlobalAchievementPercentages( Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUserStats_RequestGlobalAchievementPercentages(); @@ -309,11 +309,11 @@ public CallbackHandle RequestGlobalAchievementPercentages( Action( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle RequestGlobalStats( int nHistoryDays /*int*/, Action CallbackFunction = null /*Action*/ ) + public CallResult RequestGlobalStats( int nHistoryDays /*int*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUserStats_RequestGlobalStats( nHistoryDays ); @@ -321,11 +321,11 @@ public CallbackHandle RequestGlobalStats( int nHistoryDays /*int*/, Action( steamworks, callback, CallbackFunction ); } // SteamAPICall_t - public CallbackHandle RequestUserStats( CSteamID steamIDUser /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) + public CallResult RequestUserStats( CSteamID steamIDUser /*class CSteamID*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUserStats_RequestUserStats( steamIDUser.Value ); @@ -333,7 +333,7 @@ public CallbackHandle RequestUserStats( CSteamID steamIDUser /*class CSteamID*/, if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return UserStatsReceived_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // bool @@ -373,7 +373,7 @@ public bool UpdateAvgRateStat( string pchName /*const char **/, float flCountThi } // SteamAPICall_t - public CallbackHandle UploadLeaderboardScore( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, LeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod /*ELeaderboardUploadScoreMethod*/, int nScore /*int32*/, int[] pScoreDetails /*const int32 **/, int cScoreDetailsCount /*int*/, Action CallbackFunction = null /*Action*/ ) + public CallResult UploadLeaderboardScore( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, LeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod /*ELeaderboardUploadScoreMethod*/, int nScore /*int32*/, int[] pScoreDetails /*const int32 **/, int cScoreDetailsCount /*int*/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUserStats_UploadLeaderboardScore( hSteamLeaderboard.Value, eLeaderboardUploadScoreMethod, nScore, pScoreDetails, cScoreDetailsCount ); @@ -381,7 +381,7 @@ public CallbackHandle UploadLeaderboardScore( SteamLeaderboard_t hSteamLeaderboa if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return LeaderboardScoreUploaded_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } } diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamUtils.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamUtils.cs index 898eea7..2d7e273 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamUtils.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamUtils.cs @@ -48,7 +48,7 @@ public bool BOverlayNeedsPresent() } // SteamAPICall_t - public CallbackHandle CheckFileSignature( string szFileName /*const char **/, Action CallbackFunction = null /*Action*/ ) + public CallResult CheckFileSignature( string szFileName /*const char **/, Action CallbackFunction = null /*Action*/ ) { SteamAPICall_t callback = 0; callback = platform.ISteamUtils_CheckFileSignature( szFileName ); @@ -56,7 +56,7 @@ public CallbackHandle CheckFileSignature( string szFileName /*const char **/, Ac if ( CallbackFunction == null ) return null; if ( callback == 0 ) return null; - return CheckFileSignature_t.CallResult( steamworks, callback, CallbackFunction ); + return new CallResult( steamworks, callback, CallbackFunction ); } // SteamAPICallFailure diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.Structs.cs b/Facepunch.Steamworks/SteamNative/SteamNative.Structs.cs index febbb8a..819c61d 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.Structs.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.Structs.cs @@ -11,20 +11,11 @@ public struct CallbackMsg_t internal IntPtr ParamPtr; // m_pubParam uint8 * internal int ParamCount; // m_cubParam int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static CallbackMsg_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((CallbackMsg_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((CallbackMsg_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public CallbackMsg_t Fill( IntPtr p ) => Platform.PackSmall ? ((CallbackMsg_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((CallbackMsg_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -46,35 +37,21 @@ public struct Pack8 public static implicit operator CallbackMsg_t ( CallbackMsg_t.Pack8 d ) => new CallbackMsg_t{ SteamUser = d.SteamUser,Callback = d.Callback,ParamPtr = d.ParamPtr,ParamCount = d.ParamCount, }; } + #endregion } public struct SteamServerConnectFailure_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult [MarshalAs(UnmanagedType.I1)] internal bool StillRetrying; // m_bStillRetrying _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamServerConnectFailure_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamServerConnectFailure_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamServerConnectFailure_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamServerConnectFailure_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamServerConnectFailure_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -94,159 +71,19 @@ public struct Pack8 public static implicit operator SteamServerConnectFailure_t ( SteamServerConnectFailure_t.Pack8 d ) => new SteamServerConnectFailure_t{ Result = d.Result,StillRetrying = d.StillRetrying, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamServersDisconnected_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 3; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamServersDisconnected_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamServersDisconnected_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamServersDisconnected_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 3; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamServersDisconnected_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamServersDisconnected_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -262,163 +99,23 @@ public struct Pack8 public static implicit operator SteamServersDisconnected_t ( SteamServersDisconnected_t.Pack8 d ) => new SteamServersDisconnected_t{ Result = d.Result, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct ClientGameServerDeny_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 13; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint AppID; // m_uAppID uint32 internal uint GameServerIP; // m_unGameServerIP uint32 internal ushort GameServerPort; // m_usGameServerPort uint16 internal ushort Secure; // m_bSecure uint16 internal uint Reason; // m_uReason uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static ClientGameServerDeny_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((ClientGameServerDeny_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ClientGameServerDeny_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 13; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((ClientGameServerDeny_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ClientGameServerDeny_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -442,161 +139,21 @@ public struct Pack8 public static implicit operator ClientGameServerDeny_t ( ClientGameServerDeny_t.Pack8 d ) => new ClientGameServerDeny_t{ AppID = d.AppID,GameServerIP = d.GameServerIP,GameServerPort = d.GameServerPort,Secure = d.Secure,Reason = d.Reason, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct ValidateAuthTicketResponse_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 43; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamID; // m_SteamID class CSteamID internal AuthSessionResponse AuthSessionResponse; // m_eAuthSessionResponse enum EAuthSessionResponse internal ulong OwnerSteamID; // m_OwnerSteamID class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static ValidateAuthTicketResponse_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((ValidateAuthTicketResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ValidateAuthTicketResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 43; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((ValidateAuthTicketResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ValidateAuthTicketResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -616,161 +173,21 @@ public struct Pack8 public static implicit operator ValidateAuthTicketResponse_t ( ValidateAuthTicketResponse_t.Pack8 d ) => new ValidateAuthTicketResponse_t{ SteamID = d.SteamID,AuthSessionResponse = d.AuthSessionResponse,OwnerSteamID = d.OwnerSteamID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct MicroTxnAuthorizationResponse_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 52; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint AppID; // m_unAppID uint32 internal ulong OrderID; // m_ulOrderID uint64 internal byte Authorized; // m_bAuthorized uint8 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static MicroTxnAuthorizationResponse_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((MicroTxnAuthorizationResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MicroTxnAuthorizationResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 52; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((MicroTxnAuthorizationResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MicroTxnAuthorizationResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -790,159 +207,19 @@ public struct Pack8 public static implicit operator MicroTxnAuthorizationResponse_t ( MicroTxnAuthorizationResponse_t.Pack8 d ) => new MicroTxnAuthorizationResponse_t{ AppID = d.AppID,OrderID = d.OrderID,Authorized = d.Authorized, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct EncryptedAppTicketResponse_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 54; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static EncryptedAppTicketResponse_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((EncryptedAppTicketResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((EncryptedAppTicketResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 54; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((EncryptedAppTicketResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((EncryptedAppTicketResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -958,165 +235,20 @@ public struct Pack8 public static implicit operator EncryptedAppTicketResponse_t ( EncryptedAppTicketResponse_t.Pack8 d ) => new EncryptedAppTicketResponse_t{ Result = d.Result, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GetAuthSessionTicketResponse_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 63; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint AuthTicket; // m_hAuthTicket HAuthTicket internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GetAuthSessionTicketResponse_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GetAuthSessionTicketResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GetAuthSessionTicketResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 63; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GetAuthSessionTicketResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GetAuthSessionTicketResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -1134,160 +266,20 @@ public struct Pack8 public static implicit operator GetAuthSessionTicketResponse_t ( GetAuthSessionTicketResponse_t.Pack8 d ) => new GetAuthSessionTicketResponse_t{ AuthTicket = d.AuthTicket,Result = d.Result, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GameWebCallback_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 64; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] internal string URL; // m_szURL char [256] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GameWebCallback_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GameWebCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameWebCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 64; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GameWebCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameWebCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -1305,160 +297,20 @@ public struct Pack8 public static implicit operator GameWebCallback_t ( GameWebCallback_t.Pack8 d ) => new GameWebCallback_t{ URL = d.URL, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct StoreAuthURLResponse_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 65; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)] internal string URL; // m_szURL char [512] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static StoreAuthURLResponse_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((StoreAuthURLResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((StoreAuthURLResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 65; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((StoreAuthURLResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((StoreAuthURLResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -1476,148 +328,11 @@ public struct Pack8 public static implicit operator StoreAuthURLResponse_t ( StoreAuthURLResponse_t.Pack8 d ) => new StoreAuthURLResponse_t{ URL = d.URL, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct MarketEligibilityResponse_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 66; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } [MarshalAs(UnmanagedType.I1)] internal bool Allowed; // m_bAllowed _Bool internal MarketNotAllowedReasonFlags NotAllowedReason; // m_eNotAllowedReason enum EMarketNotAllowedReasonFlags @@ -1625,20 +340,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal int CdaySteamGuardRequiredDays; // m_cdaySteamGuardRequiredDays int internal int CdayNewDeviceCooldown; // m_cdayNewDeviceCooldown int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static MarketEligibilityResponse_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((MarketEligibilityResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MarketEligibilityResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 66; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((MarketEligibilityResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MarketEligibilityResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -1664,137 +371,7 @@ public struct Pack8 public static implicit operator MarketEligibilityResponse_t ( MarketEligibilityResponse_t.Pack8 d ) => new MarketEligibilityResponse_t{ Allowed = d.Allowed,NotAllowedReason = d.NotAllowedReason,TAllowedAtTime = d.TAllowedAtTime,CdaySteamGuardRequiredDays = d.CdaySteamGuardRequiredDays,CdayNewDeviceCooldown = d.CdayNewDeviceCooldown, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct FriendGameInfo_t @@ -1805,20 +382,11 @@ public struct FriendGameInfo_t internal ushort QueryPort; // m_usQueryPort uint16 internal ulong SteamIDLobby; // m_steamIDLobby class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static FriendGameInfo_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((FriendGameInfo_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FriendGameInfo_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public FriendGameInfo_t Fill( IntPtr p ) => Platform.PackSmall ? ((FriendGameInfo_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FriendGameInfo_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -1842,6 +410,7 @@ public struct Pack8 public static implicit operator FriendGameInfo_t ( FriendGameInfo_t.Pack8 d ) => new FriendGameInfo_t{ GameID = d.GameID,GameIP = d.GameIP,GamePort = d.GamePort,QueryPort = d.QueryPort,SteamIDLobby = d.SteamIDLobby, }; } + #endregion } public struct FriendSessionStateInfo_t @@ -1849,20 +418,11 @@ public struct FriendSessionStateInfo_t internal uint IOnlineSessionInstances; // m_uiOnlineSessionInstances uint32 internal byte IPublishedToFriendsSessionInstance; // m_uiPublishedToFriendsSessionInstance uint8 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static FriendSessionStateInfo_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((FriendSessionStateInfo_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FriendSessionStateInfo_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public FriendSessionStateInfo_t Fill( IntPtr p ) => Platform.PackSmall ? ((FriendSessionStateInfo_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FriendSessionStateInfo_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -1880,34 +440,20 @@ public struct Pack8 public static implicit operator FriendSessionStateInfo_t ( FriendSessionStateInfo_t.Pack8 d ) => new FriendSessionStateInfo_t{ IOnlineSessionInstances = d.IOnlineSessionInstances,IPublishedToFriendsSessionInstance = d.IPublishedToFriendsSessionInstance, }; } + #endregion } public struct PersonaStateChange_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 4; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamID; // m_ulSteamID uint64 internal int ChangeFlags; // m_nChangeFlags int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static PersonaStateChange_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((PersonaStateChange_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((PersonaStateChange_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 4; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((PersonaStateChange_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((PersonaStateChange_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -1925,159 +471,19 @@ public struct Pack8 public static implicit operator PersonaStateChange_t ( PersonaStateChange_t.Pack8 d ) => new PersonaStateChange_t{ SteamID = d.SteamID,ChangeFlags = d.ChangeFlags, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GameOverlayActivated_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 31; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal byte Active; // m_bActive uint8 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GameOverlayActivated_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GameOverlayActivated_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameOverlayActivated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 31; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GameOverlayActivated_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameOverlayActivated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -2093,162 +499,22 @@ public struct Pack8 public static implicit operator GameOverlayActivated_t ( GameOverlayActivated_t.Pack8 d ) => new GameOverlayActivated_t{ Active = d.Active, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GameServerChangeRequested_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 32; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] internal string Server; // m_rgchServer char [64] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] internal string Password; // m_rgchPassword char [64] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GameServerChangeRequested_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GameServerChangeRequested_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameServerChangeRequested_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 32; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GameServerChangeRequested_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameServerChangeRequested_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -2270,160 +536,20 @@ public struct Pack8 public static implicit operator GameServerChangeRequested_t ( GameServerChangeRequested_t.Pack8 d ) => new GameServerChangeRequested_t{ Server = d.Server,Password = d.Password, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GameLobbyJoinRequested_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 33; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDLobby; // m_steamIDLobby class CSteamID internal ulong SteamIDFriend; // m_steamIDFriend class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GameLobbyJoinRequested_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GameLobbyJoinRequested_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameLobbyJoinRequested_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 33; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GameLobbyJoinRequested_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameLobbyJoinRequested_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -2441,162 +567,22 @@ public struct Pack8 public static implicit operator GameLobbyJoinRequested_t ( GameLobbyJoinRequested_t.Pack8 d ) => new GameLobbyJoinRequested_t{ SteamIDLobby = d.SteamIDLobby,SteamIDFriend = d.SteamIDFriend, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct AvatarImageLoaded_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 34; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamID; // m_steamID class CSteamID internal int Image; // m_iImage int internal int Wide; // m_iWide int internal int Tall; // m_iTall int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static AvatarImageLoaded_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((AvatarImageLoaded_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((AvatarImageLoaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 34; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((AvatarImageLoaded_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((AvatarImageLoaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -2618,161 +604,21 @@ public struct Pack8 public static implicit operator AvatarImageLoaded_t ( AvatarImageLoaded_t.Pack8 d ) => new AvatarImageLoaded_t{ SteamID = d.SteamID,Image = d.Image,Wide = d.Wide,Tall = d.Tall, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct ClanOfficerListResponse_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 35; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDClan; // m_steamIDClan class CSteamID internal int COfficers; // m_cOfficers int internal byte Success; // m_bSuccess uint8 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static ClanOfficerListResponse_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((ClanOfficerListResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ClanOfficerListResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 35; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((ClanOfficerListResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ClanOfficerListResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -2792,165 +638,20 @@ public struct Pack8 public static implicit operator ClanOfficerListResponse_t ( ClanOfficerListResponse_t.Pack8 d ) => new ClanOfficerListResponse_t{ SteamIDClan = d.SteamIDClan,COfficers = d.COfficers,Success = d.Success, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct FriendRichPresenceUpdate_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 36; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDFriend; // m_steamIDFriend class CSteamID internal uint AppID; // m_nAppID AppId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static FriendRichPresenceUpdate_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((FriendRichPresenceUpdate_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FriendRichPresenceUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 36; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((FriendRichPresenceUpdate_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FriendRichPresenceUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -2968,161 +669,21 @@ public struct Pack8 public static implicit operator FriendRichPresenceUpdate_t ( FriendRichPresenceUpdate_t.Pack8 d ) => new FriendRichPresenceUpdate_t{ SteamIDFriend = d.SteamIDFriend,AppID = d.AppID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GameRichPresenceJoinRequested_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 37; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDFriend; // m_steamIDFriend class CSteamID [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] internal string Connect; // m_rgchConnect char [256] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GameRichPresenceJoinRequested_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GameRichPresenceJoinRequested_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameRichPresenceJoinRequested_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 37; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GameRichPresenceJoinRequested_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameRichPresenceJoinRequested_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -3142,161 +703,21 @@ public struct Pack8 public static implicit operator GameRichPresenceJoinRequested_t ( GameRichPresenceJoinRequested_t.Pack8 d ) => new GameRichPresenceJoinRequested_t{ SteamIDFriend = d.SteamIDFriend,Connect = d.Connect, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GameConnectedClanChatMsg_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 38; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDClanChat; // m_steamIDClanChat class CSteamID internal ulong SteamIDUser; // m_steamIDUser class CSteamID internal int MessageID; // m_iMessageID int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GameConnectedClanChatMsg_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GameConnectedClanChatMsg_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameConnectedClanChatMsg_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 38; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GameConnectedClanChatMsg_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameConnectedClanChatMsg_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -3316,160 +737,20 @@ public struct Pack8 public static implicit operator GameConnectedClanChatMsg_t ( GameConnectedClanChatMsg_t.Pack8 d ) => new GameConnectedClanChatMsg_t{ SteamIDClanChat = d.SteamIDClanChat,SteamIDUser = d.SteamIDUser,MessageID = d.MessageID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GameConnectedChatJoin_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 39; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDClanChat; // m_steamIDClanChat class CSteamID internal ulong SteamIDUser; // m_steamIDUser class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GameConnectedChatJoin_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GameConnectedChatJoin_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameConnectedChatJoin_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 39; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GameConnectedChatJoin_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameConnectedChatJoin_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -3487,143 +768,11 @@ public struct Pack8 public static implicit operator GameConnectedChatJoin_t ( GameConnectedChatJoin_t.Pack8 d ) => new GameConnectedChatJoin_t{ SteamIDClanChat = d.SteamIDClanChat,SteamIDUser = d.SteamIDUser, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GameConnectedChatLeave_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 40; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDClanChat; // m_steamIDClanChat class CSteamID internal ulong SteamIDUser; // m_steamIDUser class CSteamID [MarshalAs(UnmanagedType.I1)] @@ -3631,20 +780,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) [MarshalAs(UnmanagedType.I1)] internal bool Dropped; // m_bDropped _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GameConnectedChatLeave_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GameConnectedChatLeave_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameConnectedChatLeave_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 40; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GameConnectedChatLeave_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameConnectedChatLeave_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -3670,160 +811,20 @@ public struct Pack8 public static implicit operator GameConnectedChatLeave_t ( GameConnectedChatLeave_t.Pack8 d ) => new GameConnectedChatLeave_t{ SteamIDClanChat = d.SteamIDClanChat,SteamIDUser = d.SteamIDUser,Kicked = d.Kicked,Dropped = d.Dropped, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct DownloadClanActivityCountsResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 41; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } [MarshalAs(UnmanagedType.I1)] internal bool Success; // m_bSuccess _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static DownloadClanActivityCountsResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((DownloadClanActivityCountsResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((DownloadClanActivityCountsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 41; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((DownloadClanActivityCountsResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((DownloadClanActivityCountsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -3841,160 +842,20 @@ public struct Pack8 public static implicit operator DownloadClanActivityCountsResult_t ( DownloadClanActivityCountsResult_t.Pack8 d ) => new DownloadClanActivityCountsResult_t{ Success = d.Success, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct JoinClanChatRoomCompletionResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 42; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDClanChat; // m_steamIDClanChat class CSteamID internal ChatRoomEnterResponse ChatRoomEnterResponse; // m_eChatRoomEnterResponse enum EChatRoomEnterResponse - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static JoinClanChatRoomCompletionResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((JoinClanChatRoomCompletionResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((JoinClanChatRoomCompletionResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 42; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((JoinClanChatRoomCompletionResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((JoinClanChatRoomCompletionResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -4012,165 +873,20 @@ public struct Pack8 public static implicit operator JoinClanChatRoomCompletionResult_t ( JoinClanChatRoomCompletionResult_t.Pack8 d ) => new JoinClanChatRoomCompletionResult_t{ SteamIDClanChat = d.SteamIDClanChat,ChatRoomEnterResponse = d.ChatRoomEnterResponse, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GameConnectedFriendChatMsg_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 43; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDUser; // m_steamIDUser class CSteamID internal int MessageID; // m_iMessageID int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GameConnectedFriendChatMsg_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GameConnectedFriendChatMsg_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameConnectedFriendChatMsg_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 43; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GameConnectedFriendChatMsg_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GameConnectedFriendChatMsg_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -4188,161 +904,21 @@ public struct Pack8 public static implicit operator GameConnectedFriendChatMsg_t ( GameConnectedFriendChatMsg_t.Pack8 d ) => new GameConnectedFriendChatMsg_t{ SteamIDUser = d.SteamIDUser,MessageID = d.MessageID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct FriendsGetFollowerCount_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 44; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong SteamID; // m_steamID class CSteamID internal int Count; // m_nCount int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static FriendsGetFollowerCount_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((FriendsGetFollowerCount_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FriendsGetFollowerCount_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 44; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((FriendsGetFollowerCount_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FriendsGetFollowerCount_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -4362,167 +938,22 @@ public struct Pack8 public static implicit operator FriendsGetFollowerCount_t ( FriendsGetFollowerCount_t.Pack8 d ) => new FriendsGetFollowerCount_t{ Result = d.Result,SteamID = d.SteamID,Count = d.Count, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct FriendsIsFollowing_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 45; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong SteamID; // m_steamID class CSteamID [MarshalAs(UnmanagedType.I1)] internal bool IsFollowing; // m_bIsFollowing _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static FriendsIsFollowing_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((FriendsIsFollowing_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FriendsIsFollowing_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 45; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((FriendsIsFollowing_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FriendsIsFollowing_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -4544,168 +975,23 @@ public struct Pack8 public static implicit operator FriendsIsFollowing_t ( FriendsIsFollowing_t.Pack8 d ) => new FriendsIsFollowing_t{ Result = d.Result,SteamID = d.SteamID,IsFollowing = d.IsFollowing, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct FriendsEnumerateFollowingList_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 46; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50, ArraySubType = UnmanagedType.U8)] internal ulong[] GSteamID; // m_rgSteamID class CSteamID [50] internal int ResultsReturned; // m_nResultsReturned int32 internal int TotalResultCount; // m_nTotalResultCount int32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static FriendsEnumerateFollowingList_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((FriendsEnumerateFollowingList_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FriendsEnumerateFollowingList_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 46; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((FriendsEnumerateFollowingList_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FriendsEnumerateFollowingList_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -4729,168 +1015,23 @@ public struct Pack8 public static implicit operator FriendsEnumerateFollowingList_t ( FriendsEnumerateFollowingList_t.Pack8 d ) => new FriendsEnumerateFollowingList_t{ Result = d.Result,GSteamID = d.GSteamID,ResultsReturned = d.ResultsReturned,TotalResultCount = d.TotalResultCount, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SetPersonaNameResponse_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamFriends + 47; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } [MarshalAs(UnmanagedType.I1)] internal bool Success; // m_bSuccess _Bool [MarshalAs(UnmanagedType.I1)] internal bool LocalSuccess; // m_bLocalSuccess _Bool internal Result Result; // m_result enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SetPersonaNameResponse_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SetPersonaNameResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SetPersonaNameResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamFriends + 47; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SetPersonaNameResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SetPersonaNameResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -4914,164 +1055,19 @@ public struct Pack8 public static implicit operator SetPersonaNameResponse_t ( SetPersonaNameResponse_t.Pack8 d ) => new SetPersonaNameResponse_t{ Success = d.Success,LocalSuccess = d.LocalSuccess,Result = d.Result, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LowBatteryPower_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUtils + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal byte MinutesBatteryLeft; // m_nMinutesBatteryLeft uint8 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LowBatteryPower_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LowBatteryPower_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LowBatteryPower_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUtils + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LowBatteryPower_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LowBatteryPower_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -5087,161 +1083,21 @@ public struct Pack8 public static implicit operator LowBatteryPower_t ( LowBatteryPower_t.Pack8 d ) => new LowBatteryPower_t{ MinutesBatteryLeft = d.MinutesBatteryLeft, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamAPICallCompleted_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUtils + 3; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong AsyncCall; // m_hAsyncCall SteamAPICall_t internal int Callback; // m_iCallback int internal uint ParamCount; // m_cubParam uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamAPICallCompleted_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamAPICallCompleted_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamAPICallCompleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUtils + 3; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamAPICallCompleted_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamAPICallCompleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -5261,159 +1117,19 @@ public struct Pack8 public static implicit operator SteamAPICallCompleted_t ( SteamAPICallCompleted_t.Pack8 d ) => new SteamAPICallCompleted_t{ AsyncCall = d.AsyncCall,Callback = d.Callback,ParamCount = d.ParamCount, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct CheckFileSignature_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUtils + 5; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal CheckFileSignature CheckFileSignature; // m_eCheckFileSignature enum ECheckFileSignature - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static CheckFileSignature_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((CheckFileSignature_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((CheckFileSignature_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUtils + 5; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((CheckFileSignature_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((CheckFileSignature_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -5429,166 +1145,21 @@ public struct Pack8 public static implicit operator CheckFileSignature_t ( CheckFileSignature_t.Pack8 d ) => new CheckFileSignature_t{ CheckFileSignature = d.CheckFileSignature, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GamepadTextInputDismissed_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUtils + 14; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } [MarshalAs(UnmanagedType.I1)] internal bool Submitted; // m_bSubmitted _Bool internal uint SubmittedText; // m_unSubmittedText uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GamepadTextInputDismissed_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GamepadTextInputDismissed_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GamepadTextInputDismissed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUtils + 14; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GamepadTextInputDismissed_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GamepadTextInputDismissed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -5608,132 +1179,7 @@ public struct Pack8 public static implicit operator GamepadTextInputDismissed_t ( GamepadTextInputDismissed_t.Pack8 d ) => new GamepadTextInputDismissed_t{ Submitted = d.Submitted,SubmittedText = d.SubmittedText, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct MatchMakingKeyValuePair_t @@ -5743,20 +1189,11 @@ public struct MatchMakingKeyValuePair_t [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] internal string Value; // m_szValue char [256] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static MatchMakingKeyValuePair_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((MatchMakingKeyValuePair_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MatchMakingKeyValuePair_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public MatchMakingKeyValuePair_t Fill( IntPtr p ) => Platform.PackSmall ? ((MatchMakingKeyValuePair_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MatchMakingKeyValuePair_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -5778,6 +1215,7 @@ public struct Pack8 public static implicit operator MatchMakingKeyValuePair_t ( MatchMakingKeyValuePair_t.Pack8 d ) => new MatchMakingKeyValuePair_t{ Key = d.Key,Value = d.Value, }; } + #endregion } public struct servernetadr_t @@ -5786,20 +1224,11 @@ public struct servernetadr_t internal ushort QueryPort; // m_usQueryPort uint16 internal uint IP; // m_unIP uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static servernetadr_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((servernetadr_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((servernetadr_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public servernetadr_t Fill( IntPtr p ) => Platform.PackSmall ? ((servernetadr_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((servernetadr_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -5819,6 +1248,7 @@ public struct Pack8 public static implicit operator servernetadr_t ( servernetadr_t.Pack8 d ) => new servernetadr_t{ ConnectionPort = d.ConnectionPort,QueryPort = d.QueryPort,IP = d.IP, }; } + #endregion } public struct gameserveritem_t @@ -5851,20 +1281,11 @@ public struct gameserveritem_t internal string GameTags; // m_szGameTags char [128] internal ulong SteamID; // m_steamID class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static gameserveritem_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((gameserveritem_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((gameserveritem_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public gameserveritem_t Fill( IntPtr p ) => Platform.PackSmall ? ((gameserveritem_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((gameserveritem_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -5932,6 +1353,7 @@ public struct Pack8 public static implicit operator gameserveritem_t ( gameserveritem_t.Pack8 d ) => new gameserveritem_t{ NetAdr = d.NetAdr,Ping = d.Ping,HadSuccessfulResponse = d.HadSuccessfulResponse,DoNotRefresh = d.DoNotRefresh,GameDir = d.GameDir,Map = d.Map,GameDescription = d.GameDescription,AppID = d.AppID,Players = d.Players,MaxPlayers = d.MaxPlayers,BotPlayers = d.BotPlayers,Password = d.Password,Secure = d.Secure,TimeLastPlayed = d.TimeLastPlayed,ServerVersion = d.ServerVersion,ServerName = d.ServerName,GameTags = d.GameTags,SteamID = d.SteamID, }; } + #endregion } public struct SteamPartyBeaconLocation_t @@ -5939,20 +1361,11 @@ public struct SteamPartyBeaconLocation_t internal SteamPartyBeaconLocationType Type; // m_eType enum ESteamPartyBeaconLocationType internal ulong LocationID; // m_ulLocationID uint64 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamPartyBeaconLocation_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamPartyBeaconLocation_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamPartyBeaconLocation_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public SteamPartyBeaconLocation_t Fill( IntPtr p ) => Platform.PackSmall ? ((SteamPartyBeaconLocation_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamPartyBeaconLocation_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -5970,17 +1383,11 @@ public struct Pack8 public static implicit operator SteamPartyBeaconLocation_t ( SteamPartyBeaconLocation_t.Pack8 d ) => new SteamPartyBeaconLocation_t{ Type = d.Type,LocationID = d.LocationID, }; } + #endregion } public struct FavoritesListChanged_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMatchmaking + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint IP; // m_nIP uint32 internal uint QueryPort; // m_nQueryPort uint32 internal uint ConnPort; // m_nConnPort uint32 @@ -5990,20 +1397,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal bool Add; // m_bAdd _Bool internal uint AccountId; // m_unAccountId AccountID_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static FavoritesListChanged_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((FavoritesListChanged_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FavoritesListChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((FavoritesListChanged_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FavoritesListChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -6033,161 +1432,21 @@ public struct Pack8 public static implicit operator FavoritesListChanged_t ( FavoritesListChanged_t.Pack8 d ) => new FavoritesListChanged_t{ IP = d.IP,QueryPort = d.QueryPort,ConnPort = d.ConnPort,AppID = d.AppID,Flags = d.Flags,Add = d.Add,AccountId = d.AccountId, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LobbyInvite_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMatchmaking + 3; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDUser; // m_ulSteamIDUser uint64 internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal ulong GameID; // m_ulGameID uint64 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LobbyInvite_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LobbyInvite_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyInvite_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 3; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LobbyInvite_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyInvite_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -6207,163 +1466,23 @@ public struct Pack8 public static implicit operator LobbyInvite_t ( LobbyInvite_t.Pack8 d ) => new LobbyInvite_t{ SteamIDUser = d.SteamIDUser,SteamIDLobby = d.SteamIDLobby,GameID = d.GameID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LobbyEnter_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMatchmaking + 4; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal uint GfChatPermissions; // m_rgfChatPermissions uint32 [MarshalAs(UnmanagedType.I1)] internal bool Locked; // m_bLocked _Bool internal uint EChatRoomEnterResponse; // m_EChatRoomEnterResponse uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LobbyEnter_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LobbyEnter_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyEnter_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 4; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LobbyEnter_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyEnter_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -6387,166 +1506,21 @@ public struct Pack8 public static implicit operator LobbyEnter_t ( LobbyEnter_t.Pack8 d ) => new LobbyEnter_t{ SteamIDLobby = d.SteamIDLobby,GfChatPermissions = d.GfChatPermissions,Locked = d.Locked,EChatRoomEnterResponse = d.EChatRoomEnterResponse, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LobbyDataUpdate_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMatchmaking + 5; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal ulong SteamIDMember; // m_ulSteamIDMember uint64 internal byte Success; // m_bSuccess uint8 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LobbyDataUpdate_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LobbyDataUpdate_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyDataUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 5; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LobbyDataUpdate_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyDataUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -6566,162 +1540,22 @@ public struct Pack8 public static implicit operator LobbyDataUpdate_t ( LobbyDataUpdate_t.Pack8 d ) => new LobbyDataUpdate_t{ SteamIDLobby = d.SteamIDLobby,SteamIDMember = d.SteamIDMember,Success = d.Success, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LobbyChatUpdate_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMatchmaking + 6; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal ulong SteamIDUserChanged; // m_ulSteamIDUserChanged uint64 internal ulong SteamIDMakingChange; // m_ulSteamIDMakingChange uint64 internal uint GfChatMemberStateChange; // m_rgfChatMemberStateChange uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LobbyChatUpdate_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LobbyChatUpdate_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyChatUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 6; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LobbyChatUpdate_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyChatUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -6743,162 +1577,22 @@ public struct Pack8 public static implicit operator LobbyChatUpdate_t ( LobbyChatUpdate_t.Pack8 d ) => new LobbyChatUpdate_t{ SteamIDLobby = d.SteamIDLobby,SteamIDUserChanged = d.SteamIDUserChanged,SteamIDMakingChange = d.SteamIDMakingChange,GfChatMemberStateChange = d.GfChatMemberStateChange, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LobbyChatMsg_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMatchmaking + 7; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal ulong SteamIDUser; // m_ulSteamIDUser uint64 internal byte ChatEntryType; // m_eChatEntryType uint8 internal uint ChatID; // m_iChatID uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LobbyChatMsg_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LobbyChatMsg_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyChatMsg_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 7; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LobbyChatMsg_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyChatMsg_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -6920,162 +1614,22 @@ public struct Pack8 public static implicit operator LobbyChatMsg_t ( LobbyChatMsg_t.Pack8 d ) => new LobbyChatMsg_t{ SteamIDLobby = d.SteamIDLobby,SteamIDUser = d.SteamIDUser,ChatEntryType = d.ChatEntryType,ChatID = d.ChatID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LobbyGameCreated_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMatchmaking + 9; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal ulong SteamIDGameServer; // m_ulSteamIDGameServer uint64 internal uint IP; // m_unIP uint32 internal ushort Port; // m_usPort uint16 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LobbyGameCreated_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LobbyGameCreated_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyGameCreated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 9; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LobbyGameCreated_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyGameCreated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -7097,159 +1651,19 @@ public struct Pack8 public static implicit operator LobbyGameCreated_t ( LobbyGameCreated_t.Pack8 d ) => new LobbyGameCreated_t{ SteamIDLobby = d.SteamIDLobby,SteamIDGameServer = d.SteamIDGameServer,IP = d.IP,Port = d.Port, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LobbyMatchList_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMatchmaking + 10; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint LobbiesMatching; // m_nLobbiesMatching uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LobbyMatchList_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LobbyMatchList_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyMatchList_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 10; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LobbyMatchList_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyMatchList_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -7265,166 +1679,21 @@ public struct Pack8 public static implicit operator LobbyMatchList_t ( LobbyMatchList_t.Pack8 d ) => new LobbyMatchList_t{ LobbiesMatching = d.LobbiesMatching, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LobbyKicked_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMatchmaking + 12; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 internal ulong SteamIDAdmin; // m_ulSteamIDAdmin uint64 internal byte KickedDueToDisconnect; // m_bKickedDueToDisconnect uint8 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LobbyKicked_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LobbyKicked_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyKicked_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 12; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LobbyKicked_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyKicked_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -7444,160 +1713,20 @@ public struct Pack8 public static implicit operator LobbyKicked_t ( LobbyKicked_t.Pack8 d ) => new LobbyKicked_t{ SteamIDLobby = d.SteamIDLobby,SteamIDAdmin = d.SteamIDAdmin,KickedDueToDisconnect = d.KickedDueToDisconnect, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LobbyCreated_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMatchmaking + 13; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong SteamIDLobby; // m_ulSteamIDLobby uint64 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LobbyCreated_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LobbyCreated_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyCreated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 13; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LobbyCreated_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LobbyCreated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -7615,166 +1744,21 @@ public struct Pack8 public static implicit operator LobbyCreated_t ( LobbyCreated_t.Pack8 d ) => new LobbyCreated_t{ Result = d.Result,SteamIDLobby = d.SteamIDLobby, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct PSNGameBootInviteResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMatchmaking + 15; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } [MarshalAs(UnmanagedType.I1)] internal bool GameBootInviteExists; // m_bGameBootInviteExists _Bool internal ulong SteamIDLobby; // m_steamIDLobby class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static PSNGameBootInviteResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((PSNGameBootInviteResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((PSNGameBootInviteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 15; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((PSNGameBootInviteResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((PSNGameBootInviteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -7794,159 +1778,19 @@ public struct Pack8 public static implicit operator PSNGameBootInviteResult_t ( PSNGameBootInviteResult_t.Pack8 d ) => new PSNGameBootInviteResult_t{ GameBootInviteExists = d.GameBootInviteExists,SteamIDLobby = d.SteamIDLobby, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct FavoritesListAccountsUpdated_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMatchmaking + 16; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static FavoritesListAccountsUpdated_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((FavoritesListAccountsUpdated_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FavoritesListAccountsUpdated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMatchmaking + 16; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((FavoritesListAccountsUpdated_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FavoritesListAccountsUpdated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -7962,143 +1806,11 @@ public struct Pack8 public static implicit operator FavoritesListAccountsUpdated_t ( FavoritesListAccountsUpdated_t.Pack8 d ) => new FavoritesListAccountsUpdated_t{ Result = d.Result, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SearchForGameProgressCallback_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameSearch + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong LSearchID; // m_ullSearchID uint64 internal Result Result; // m_eResult enum EResult internal ulong LobbyID; // m_lobbyID class CSteamID @@ -8106,20 +1818,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal int SecondsRemainingEstimate; // m_nSecondsRemainingEstimate int32 internal int CPlayersSearching; // m_cPlayersSearching int32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SearchForGameProgressCallback_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SearchForGameProgressCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SearchForGameProgressCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SearchForGameProgressCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SearchForGameProgressCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -8145,143 +1849,11 @@ public struct Pack8 public static implicit operator SearchForGameProgressCallback_t ( SearchForGameProgressCallback_t.Pack8 d ) => new SearchForGameProgressCallback_t{ LSearchID = d.LSearchID,Result = d.Result,LobbyID = d.LobbyID,SteamIDEndedSearch = d.SteamIDEndedSearch,SecondsRemainingEstimate = d.SecondsRemainingEstimate,CPlayersSearching = d.CPlayersSearching, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SearchForGameResultCallback_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameSearch + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong LSearchID; // m_ullSearchID uint64 internal Result Result; // m_eResult enum EResult internal int CountPlayersInGame; // m_nCountPlayersInGame int32 @@ -8290,20 +1862,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) [MarshalAs(UnmanagedType.I1)] internal bool FinalCallback; // m_bFinalCallback _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SearchForGameResultCallback_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SearchForGameResultCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SearchForGameResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SearchForGameResultCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SearchForGameResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -8331,160 +1895,20 @@ public struct Pack8 public static implicit operator SearchForGameResultCallback_t ( SearchForGameResultCallback_t.Pack8 d ) => new SearchForGameResultCallback_t{ LSearchID = d.LSearchID,Result = d.Result,CountPlayersInGame = d.CountPlayersInGame,CountAcceptedGame = d.CountAcceptedGame,SteamIDHost = d.SteamIDHost,FinalCallback = d.FinalCallback, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RequestPlayersForGameProgressCallback_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameSearch + 11; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong LSearchID; // m_ullSearchID uint64 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RequestPlayersForGameProgressCallback_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RequestPlayersForGameProgressCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RequestPlayersForGameProgressCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 11; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RequestPlayersForGameProgressCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RequestPlayersForGameProgressCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -8502,143 +1926,11 @@ public struct Pack8 public static implicit operator RequestPlayersForGameProgressCallback_t ( RequestPlayersForGameProgressCallback_t.Pack8 d ) => new RequestPlayersForGameProgressCallback_t{ Result = d.Result,LSearchID = d.LSearchID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RequestPlayersForGameResultCallback_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameSearch + 12; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong LSearchID; // m_ullSearchID uint64 internal ulong SteamIDPlayerFound; // m_SteamIDPlayerFound class CSteamID @@ -8650,20 +1942,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal int SuggestedTeamIndex; // m_nSuggestedTeamIndex int32 internal ulong LUniqueGameID; // m_ullUniqueGameID uint64 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RequestPlayersForGameResultCallback_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RequestPlayersForGameResultCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RequestPlayersForGameResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 12; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RequestPlayersForGameResultCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RequestPlayersForGameResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -8697,161 +1981,21 @@ public struct Pack8 public static implicit operator RequestPlayersForGameResultCallback_t ( RequestPlayersForGameResultCallback_t.Pack8 d ) => new RequestPlayersForGameResultCallback_t{ Result = d.Result,LSearchID = d.LSearchID,SteamIDPlayerFound = d.SteamIDPlayerFound,SteamIDLobby = d.SteamIDLobby,PlayerAcceptState = d.PlayerAcceptState,PlayerIndex = d.PlayerIndex,TotalPlayersFound = d.TotalPlayersFound,TotalPlayersAcceptedGame = d.TotalPlayersAcceptedGame,SuggestedTeamIndex = d.SuggestedTeamIndex,LUniqueGameID = d.LUniqueGameID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RequestPlayersForGameFinalResultCallback_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameSearch + 13; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong LSearchID; // m_ullSearchID uint64 internal ulong LUniqueGameID; // m_ullUniqueGameID uint64 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RequestPlayersForGameFinalResultCallback_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RequestPlayersForGameFinalResultCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RequestPlayersForGameFinalResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 13; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RequestPlayersForGameFinalResultCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RequestPlayersForGameFinalResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -8871,161 +2015,21 @@ public struct Pack8 public static implicit operator RequestPlayersForGameFinalResultCallback_t ( RequestPlayersForGameFinalResultCallback_t.Pack8 d ) => new RequestPlayersForGameFinalResultCallback_t{ Result = d.Result,LSearchID = d.LSearchID,LUniqueGameID = d.LUniqueGameID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SubmitPlayerResultResultCallback_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameSearch + 14; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong UllUniqueGameID; // ullUniqueGameID uint64 internal ulong SteamIDPlayer; // steamIDPlayer class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SubmitPlayerResultResultCallback_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SubmitPlayerResultResultCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SubmitPlayerResultResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 14; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SubmitPlayerResultResultCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SubmitPlayerResultResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -9045,160 +2049,20 @@ public struct Pack8 public static implicit operator SubmitPlayerResultResultCallback_t ( SubmitPlayerResultResultCallback_t.Pack8 d ) => new SubmitPlayerResultResultCallback_t{ Result = d.Result,UllUniqueGameID = d.UllUniqueGameID,SteamIDPlayer = d.SteamIDPlayer, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct EndGameResultCallback_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameSearch + 15; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong UllUniqueGameID; // ullUniqueGameID uint64 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static EndGameResultCallback_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((EndGameResultCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((EndGameResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameSearch + 15; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((EndGameResultCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((EndGameResultCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -9216,163 +2080,23 @@ public struct Pack8 public static implicit operator EndGameResultCallback_t ( EndGameResultCallback_t.Pack8 d ) => new EndGameResultCallback_t{ Result = d.Result,UllUniqueGameID = d.UllUniqueGameID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct JoinPartyCallback_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamParties + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong BeaconID; // m_ulBeaconID PartyBeaconID_t internal ulong SteamIDBeaconOwner; // m_SteamIDBeaconOwner class CSteamID [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] internal string ConnectString; // m_rgchConnectString char [256] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static JoinPartyCallback_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((JoinPartyCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((JoinPartyCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamParties + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((JoinPartyCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((JoinPartyCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -9396,165 +2120,20 @@ public struct Pack8 public static implicit operator JoinPartyCallback_t ( JoinPartyCallback_t.Pack8 d ) => new JoinPartyCallback_t{ Result = d.Result,BeaconID = d.BeaconID,SteamIDBeaconOwner = d.SteamIDBeaconOwner,ConnectString = d.ConnectString, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct CreateBeaconCallback_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamParties + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong BeaconID; // m_ulBeaconID PartyBeaconID_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static CreateBeaconCallback_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((CreateBeaconCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((CreateBeaconCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamParties + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((CreateBeaconCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((CreateBeaconCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -9572,165 +2151,20 @@ public struct Pack8 public static implicit operator CreateBeaconCallback_t ( CreateBeaconCallback_t.Pack8 d ) => new CreateBeaconCallback_t{ Result = d.Result,BeaconID = d.BeaconID, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct ReservationNotificationCallback_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamParties + 3; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong BeaconID; // m_ulBeaconID PartyBeaconID_t internal ulong SteamIDJoiner; // m_steamIDJoiner class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static ReservationNotificationCallback_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((ReservationNotificationCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ReservationNotificationCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamParties + 3; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((ReservationNotificationCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ReservationNotificationCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -9748,159 +2182,19 @@ public struct Pack8 public static implicit operator ReservationNotificationCallback_t ( ReservationNotificationCallback_t.Pack8 d ) => new ReservationNotificationCallback_t{ BeaconID = d.BeaconID,SteamIDJoiner = d.SteamIDJoiner, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct ChangeNumOpenSlotsCallback_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamParties + 4; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static ChangeNumOpenSlotsCallback_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((ChangeNumOpenSlotsCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ChangeNumOpenSlotsCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamParties + 4; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((ChangeNumOpenSlotsCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ChangeNumOpenSlotsCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -9916,137 +2210,7 @@ public struct Pack8 public static implicit operator ChangeNumOpenSlotsCallback_t ( ChangeNumOpenSlotsCallback_t.Pack8 d ) => new ChangeNumOpenSlotsCallback_t{ Result = d.Result, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamParamStringArray_t @@ -10054,20 +2218,11 @@ public struct SteamParamStringArray_t internal IntPtr Strings; // m_ppStrings const char ** internal int NumStrings; // m_nNumStrings int32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamParamStringArray_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamParamStringArray_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamParamStringArray_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public SteamParamStringArray_t Fill( IntPtr p ) => Platform.PackSmall ? ((SteamParamStringArray_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamParamStringArray_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -10085,35 +2240,21 @@ public struct Pack8 public static implicit operator SteamParamStringArray_t ( SteamParamStringArray_t.Pack8 d ) => new SteamParamStringArray_t{ Strings = d.Strings,NumStrings = d.NumStrings, }; } + #endregion } public struct RemoteStorageAppSyncedClient_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint AppID; // m_nAppID AppId_t internal Result Result; // m_eResult enum EResult internal int NumDownloads; // m_unNumDownloads int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageAppSyncedClient_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageAppSyncedClient_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageAppSyncedClient_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageAppSyncedClient_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageAppSyncedClient_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -10133,161 +2274,21 @@ public struct Pack8 public static implicit operator RemoteStorageAppSyncedClient_t ( RemoteStorageAppSyncedClient_t.Pack8 d ) => new RemoteStorageAppSyncedClient_t{ AppID = d.AppID,Result = d.Result,NumDownloads = d.NumDownloads, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageAppSyncedServer_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint AppID; // m_nAppID AppId_t internal Result Result; // m_eResult enum EResult internal int NumUploads; // m_unNumUploads int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageAppSyncedServer_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageAppSyncedServer_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageAppSyncedServer_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageAppSyncedServer_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageAppSyncedServer_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -10307,143 +2308,11 @@ public struct Pack8 public static implicit operator RemoteStorageAppSyncedServer_t ( RemoteStorageAppSyncedServer_t.Pack8 d ) => new RemoteStorageAppSyncedServer_t{ AppID = d.AppID,Result = d.Result,NumUploads = d.NumUploads, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageAppSyncProgress_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 3; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] internal string CurrentFile; // m_rgchCurrentFile char [260] internal uint AppID; // m_nAppID AppId_t @@ -10452,20 +2321,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) [MarshalAs(UnmanagedType.I1)] internal bool Uploading; // m_bUploading _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageAppSyncProgress_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageAppSyncProgress_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageAppSyncProgress_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 3; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageAppSyncProgress_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageAppSyncProgress_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -10493,160 +2354,20 @@ public struct Pack8 public static implicit operator RemoteStorageAppSyncProgress_t ( RemoteStorageAppSyncProgress_t.Pack8 d ) => new RemoteStorageAppSyncProgress_t{ CurrentFile = d.CurrentFile,AppID = d.AppID,BytesTransferredThisChunk = d.BytesTransferredThisChunk,DAppPercentComplete = d.DAppPercentComplete,Uploading = d.Uploading, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageAppSyncStatusCheck_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 5; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint AppID; // m_nAppID AppId_t internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageAppSyncStatusCheck_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageAppSyncStatusCheck_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageAppSyncStatusCheck_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 5; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageAppSyncStatusCheck_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageAppSyncStatusCheck_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -10664,162 +2385,22 @@ public struct Pack8 public static implicit operator RemoteStorageAppSyncStatusCheck_t ( RemoteStorageAppSyncStatusCheck_t.Pack8 d ) => new RemoteStorageAppSyncStatusCheck_t{ AppID = d.AppID,Result = d.Result, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageFileShareResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 7; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong File; // m_hFile UGCHandle_t [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] internal string Filename; // m_rgchFilename char [260] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageFileShareResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageFileShareResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageFileShareResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 7; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageFileShareResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageFileShareResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -10841,167 +2422,22 @@ public struct Pack8 public static implicit operator RemoteStorageFileShareResult_t ( RemoteStorageFileShareResult_t.Pack8 d ) => new RemoteStorageFileShareResult_t{ Result = d.Result,File = d.File,Filename = d.Filename, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStoragePublishFileResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 9; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t [MarshalAs(UnmanagedType.I1)] internal bool UserNeedsToAcceptWorkshopLegalAgreement; // m_bUserNeedsToAcceptWorkshopLegalAgreement _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStoragePublishFileResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStoragePublishFileResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStoragePublishFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 9; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStoragePublishFileResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStoragePublishFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -11023,160 +2459,20 @@ public struct Pack8 public static implicit operator RemoteStoragePublishFileResult_t ( RemoteStoragePublishFileResult_t.Pack8 d ) => new RemoteStoragePublishFileResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId,UserNeedsToAcceptWorkshopLegalAgreement = d.UserNeedsToAcceptWorkshopLegalAgreement, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageDeletePublishedFileResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 11; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageDeletePublishedFileResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageDeletePublishedFileResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageDeletePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 11; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageDeletePublishedFileResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageDeletePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -11194,168 +2490,23 @@ public struct Pack8 public static implicit operator RemoteStorageDeletePublishedFileResult_t ( RemoteStorageDeletePublishedFileResult_t.Pack8 d ) => new RemoteStorageDeletePublishedFileResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageEnumerateUserPublishedFilesResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 12; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal int ResultsReturned; // m_nResultsReturned int32 internal int TotalResultCount; // m_nTotalResultCount int32 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50, ArraySubType = UnmanagedType.U8)] internal ulong[] GPublishedFileId; // m_rgPublishedFileId PublishedFileId_t [50] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageEnumerateUserPublishedFilesResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageEnumerateUserPublishedFilesResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageEnumerateUserPublishedFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 12; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageEnumerateUserPublishedFilesResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageEnumerateUserPublishedFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -11379,165 +2530,20 @@ public struct Pack8 public static implicit operator RemoteStorageEnumerateUserPublishedFilesResult_t ( RemoteStorageEnumerateUserPublishedFilesResult_t.Pack8 d ) => new RemoteStorageEnumerateUserPublishedFilesResult_t{ Result = d.Result,ResultsReturned = d.ResultsReturned,TotalResultCount = d.TotalResultCount,GPublishedFileId = d.GPublishedFileId, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageSubscribePublishedFileResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 13; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageSubscribePublishedFileResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageSubscribePublishedFileResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageSubscribePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 13; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageSubscribePublishedFileResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageSubscribePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -11555,148 +2561,11 @@ public struct Pack8 public static implicit operator RemoteStorageSubscribePublishedFileResult_t ( RemoteStorageSubscribePublishedFileResult_t.Pack8 d ) => new RemoteStorageSubscribePublishedFileResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageEnumerateUserSubscribedFilesResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 14; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal int ResultsReturned; // m_nResultsReturned int32 internal int TotalResultCount; // m_nTotalResultCount int32 @@ -11705,20 +2574,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50, ArraySubType = UnmanagedType.U4)] internal uint[] GRTimeSubscribed; // m_rgRTimeSubscribed uint32 [50] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageEnumerateUserSubscribedFilesResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageEnumerateUserSubscribedFilesResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageEnumerateUserSubscribedFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 14; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageEnumerateUserSubscribedFilesResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageEnumerateUserSubscribedFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -11746,165 +2607,20 @@ public struct Pack8 public static implicit operator RemoteStorageEnumerateUserSubscribedFilesResult_t ( RemoteStorageEnumerateUserSubscribedFilesResult_t.Pack8 d ) => new RemoteStorageEnumerateUserSubscribedFilesResult_t{ Result = d.Result,ResultsReturned = d.ResultsReturned,TotalResultCount = d.TotalResultCount,GPublishedFileId = d.GPublishedFileId,GRTimeSubscribed = d.GRTimeSubscribed, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageUnsubscribePublishedFileResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 15; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageUnsubscribePublishedFileResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageUnsubscribePublishedFileResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageUnsubscribePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 15; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageUnsubscribePublishedFileResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageUnsubscribePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -11922,167 +2638,22 @@ public struct Pack8 public static implicit operator RemoteStorageUnsubscribePublishedFileResult_t ( RemoteStorageUnsubscribePublishedFileResult_t.Pack8 d ) => new RemoteStorageUnsubscribePublishedFileResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageUpdatePublishedFileResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 16; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t [MarshalAs(UnmanagedType.I1)] internal bool UserNeedsToAcceptWorkshopLegalAgreement; // m_bUserNeedsToAcceptWorkshopLegalAgreement _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageUpdatePublishedFileResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageUpdatePublishedFileResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageUpdatePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 16; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageUpdatePublishedFileResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageUpdatePublishedFileResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -12104,148 +2675,11 @@ public struct Pack8 public static implicit operator RemoteStorageUpdatePublishedFileResult_t ( RemoteStorageUpdatePublishedFileResult_t.Pack8 d ) => new RemoteStorageUpdatePublishedFileResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId,UserNeedsToAcceptWorkshopLegalAgreement = d.UserNeedsToAcceptWorkshopLegalAgreement, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageDownloadUGCResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 17; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong File; // m_hFile UGCHandle_t internal uint AppID; // m_nAppID AppId_t @@ -12254,20 +2688,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal string PchFileName; // m_pchFileName char [260] internal ulong SteamIDOwner; // m_ulSteamIDOwner uint64 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageDownloadUGCResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageDownloadUGCResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageDownloadUGCResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 17; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageDownloadUGCResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageDownloadUGCResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -12295,148 +2721,11 @@ public struct Pack8 public static implicit operator RemoteStorageDownloadUGCResult_t ( RemoteStorageDownloadUGCResult_t.Pack8 d ) => new RemoteStorageDownloadUGCResult_t{ Result = d.Result,File = d.File,AppID = d.AppID,SizeInBytes = d.SizeInBytes,PchFileName = d.PchFileName,SteamIDOwner = d.SteamIDOwner, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageGetPublishedFileDetailsResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 18; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal uint CreatorAppID; // m_nCreatorAppID AppId_t @@ -12467,20 +2756,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) [MarshalAs(UnmanagedType.I1)] internal bool AcceptedForUse; // m_bAcceptedForUse _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageGetPublishedFileDetailsResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageGetPublishedFileDetailsResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageGetPublishedFileDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 18; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageGetPublishedFileDetailsResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageGetPublishedFileDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -12552,148 +2833,11 @@ public struct Pack8 public static implicit operator RemoteStorageGetPublishedFileDetailsResult_t ( RemoteStorageGetPublishedFileDetailsResult_t.Pack8 d ) => new RemoteStorageGetPublishedFileDetailsResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId,CreatorAppID = d.CreatorAppID,ConsumerAppID = d.ConsumerAppID,Title = d.Title,Description = d.Description,File = d.File,PreviewFile = d.PreviewFile,SteamIDOwner = d.SteamIDOwner,TimeCreated = d.TimeCreated,TimeUpdated = d.TimeUpdated,Visibility = d.Visibility,Banned = d.Banned,Tags = d.Tags,TagsTruncated = d.TagsTruncated,PchFileName = d.PchFileName,FileSize = d.FileSize,PreviewFileSize = d.PreviewFileSize,URL = d.URL,FileType = d.FileType,AcceptedForUse = d.AcceptedForUse, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageEnumerateWorkshopFilesResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 19; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal int ResultsReturned; // m_nResultsReturned int32 internal int TotalResultCount; // m_nTotalResultCount int32 @@ -12704,20 +2848,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal uint AppId; // m_nAppId AppId_t internal uint StartIndex; // m_unStartIndex uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageEnumerateWorkshopFilesResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageEnumerateWorkshopFilesResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageEnumerateWorkshopFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 19; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageEnumerateWorkshopFilesResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageEnumerateWorkshopFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -12749,148 +2885,11 @@ public struct Pack8 public static implicit operator RemoteStorageEnumerateWorkshopFilesResult_t ( RemoteStorageEnumerateWorkshopFilesResult_t.Pack8 d ) => new RemoteStorageEnumerateWorkshopFilesResult_t{ Result = d.Result,ResultsReturned = d.ResultsReturned,TotalResultCount = d.TotalResultCount,GPublishedFileId = d.GPublishedFileId,GScore = d.GScore,AppId = d.AppId,StartIndex = d.StartIndex, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageGetPublishedItemVoteDetailsResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 20; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_unPublishedFileId PublishedFileId_t internal int VotesFor; // m_nVotesFor int32 @@ -12898,20 +2897,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal int Reports; // m_nReports int32 internal float FScore; // m_fScore float - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageGetPublishedItemVoteDetailsResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageGetPublishedItemVoteDetailsResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageGetPublishedItemVoteDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 20; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageGetPublishedItemVoteDetailsResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageGetPublishedItemVoteDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -12937,165 +2928,20 @@ public struct Pack8 public static implicit operator RemoteStorageGetPublishedItemVoteDetailsResult_t ( RemoteStorageGetPublishedItemVoteDetailsResult_t.Pack8 d ) => new RemoteStorageGetPublishedItemVoteDetailsResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId,VotesFor = d.VotesFor,VotesAgainst = d.VotesAgainst,Reports = d.Reports,FScore = d.FScore, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStoragePublishedFileSubscribed_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 21; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal uint AppID; // m_nAppID AppId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStoragePublishedFileSubscribed_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStoragePublishedFileSubscribed_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStoragePublishedFileSubscribed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 21; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStoragePublishedFileSubscribed_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStoragePublishedFileSubscribed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -13113,160 +2959,20 @@ public struct Pack8 public static implicit operator RemoteStoragePublishedFileSubscribed_t ( RemoteStoragePublishedFileSubscribed_t.Pack8 d ) => new RemoteStoragePublishedFileSubscribed_t{ PublishedFileId = d.PublishedFileId,AppID = d.AppID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStoragePublishedFileUnsubscribed_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 22; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal uint AppID; // m_nAppID AppId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStoragePublishedFileUnsubscribed_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStoragePublishedFileUnsubscribed_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStoragePublishedFileUnsubscribed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 22; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStoragePublishedFileUnsubscribed_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStoragePublishedFileUnsubscribed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -13284,160 +2990,20 @@ public struct Pack8 public static implicit operator RemoteStoragePublishedFileUnsubscribed_t ( RemoteStoragePublishedFileUnsubscribed_t.Pack8 d ) => new RemoteStoragePublishedFileUnsubscribed_t{ PublishedFileId = d.PublishedFileId,AppID = d.AppID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStoragePublishedFileDeleted_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 23; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal uint AppID; // m_nAppID AppId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStoragePublishedFileDeleted_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStoragePublishedFileDeleted_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStoragePublishedFileDeleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 23; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStoragePublishedFileDeleted_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStoragePublishedFileDeleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -13455,160 +3021,20 @@ public struct Pack8 public static implicit operator RemoteStoragePublishedFileDeleted_t ( RemoteStoragePublishedFileDeleted_t.Pack8 d ) => new RemoteStoragePublishedFileDeleted_t{ PublishedFileId = d.PublishedFileId,AppID = d.AppID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageUpdateUserPublishedItemVoteResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 24; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageUpdateUserPublishedItemVoteResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageUpdateUserPublishedItemVoteResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageUpdateUserPublishedItemVoteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 24; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageUpdateUserPublishedItemVoteResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageUpdateUserPublishedItemVoteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -13626,166 +3052,21 @@ public struct Pack8 public static implicit operator RemoteStorageUpdateUserPublishedItemVoteResult_t ( RemoteStorageUpdateUserPublishedItemVoteResult_t.Pack8 d ) => new RemoteStorageUpdateUserPublishedItemVoteResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageUserVoteDetails_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 25; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal WorkshopVote Vote; // m_eVote enum EWorkshopVote - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageUserVoteDetails_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageUserVoteDetails_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageUserVoteDetails_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 25; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageUserVoteDetails_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageUserVoteDetails_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -13805,163 +3086,23 @@ public struct Pack8 public static implicit operator RemoteStorageUserVoteDetails_t ( RemoteStorageUserVoteDetails_t.Pack8 d ) => new RemoteStorageUserVoteDetails_t{ Result = d.Result,PublishedFileId = d.PublishedFileId,Vote = d.Vote, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageEnumerateUserSharedWorkshopFilesResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 26; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal int ResultsReturned; // m_nResultsReturned int32 internal int TotalResultCount; // m_nTotalResultCount int32 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50, ArraySubType = UnmanagedType.U8)] internal ulong[] GPublishedFileId; // m_rgPublishedFileId PublishedFileId_t [50] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageEnumerateUserSharedWorkshopFilesResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageEnumerateUserSharedWorkshopFilesResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageEnumerateUserSharedWorkshopFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 26; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageEnumerateUserSharedWorkshopFilesResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageEnumerateUserSharedWorkshopFilesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -13985,161 +3126,21 @@ public struct Pack8 public static implicit operator RemoteStorageEnumerateUserSharedWorkshopFilesResult_t ( RemoteStorageEnumerateUserSharedWorkshopFilesResult_t.Pack8 d ) => new RemoteStorageEnumerateUserSharedWorkshopFilesResult_t{ Result = d.Result,ResultsReturned = d.ResultsReturned,TotalResultCount = d.TotalResultCount,GPublishedFileId = d.GPublishedFileId, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageSetUserPublishedFileActionResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 27; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal WorkshopFileAction Action; // m_eAction enum EWorkshopFileAction - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageSetUserPublishedFileActionResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageSetUserPublishedFileActionResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageSetUserPublishedFileActionResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 27; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageSetUserPublishedFileActionResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageSetUserPublishedFileActionResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -14159,148 +3160,11 @@ public struct Pack8 public static implicit operator RemoteStorageSetUserPublishedFileActionResult_t ( RemoteStorageSetUserPublishedFileActionResult_t.Pack8 d ) => new RemoteStorageSetUserPublishedFileActionResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId,Action = d.Action, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageEnumeratePublishedFilesByUserActionResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 28; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal WorkshopFileAction Action; // m_eAction enum EWorkshopFileAction internal int ResultsReturned; // m_nResultsReturned int32 @@ -14310,20 +3174,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50, ArraySubType = UnmanagedType.U4)] internal uint[] GRTimeUpdated; // m_rgRTimeUpdated uint32 [50] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageEnumeratePublishedFilesByUserActionResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageEnumeratePublishedFilesByUserActionResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageEnumeratePublishedFilesByUserActionResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 28; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageEnumeratePublishedFilesByUserActionResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageEnumeratePublishedFilesByUserActionResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -14353,166 +3209,21 @@ public struct Pack8 public static implicit operator RemoteStorageEnumeratePublishedFilesByUserActionResult_t ( RemoteStorageEnumeratePublishedFilesByUserActionResult_t.Pack8 d ) => new RemoteStorageEnumeratePublishedFilesByUserActionResult_t{ Result = d.Result,Action = d.Action,ResultsReturned = d.ResultsReturned,TotalResultCount = d.TotalResultCount,GPublishedFileId = d.GPublishedFileId,GRTimeUpdated = d.GRTimeUpdated, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStoragePublishFileProgress_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 29; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal double DPercentFile; // m_dPercentFile double [MarshalAs(UnmanagedType.I1)] internal bool Preview; // m_bPreview _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStoragePublishFileProgress_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStoragePublishFileProgress_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStoragePublishFileProgress_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 29; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStoragePublishFileProgress_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStoragePublishFileProgress_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -14532,166 +3243,21 @@ public struct Pack8 public static implicit operator RemoteStoragePublishFileProgress_t ( RemoteStoragePublishFileProgress_t.Pack8 d ) => new RemoteStoragePublishFileProgress_t{ DPercentFile = d.DPercentFile,Preview = d.Preview, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStoragePublishedFileUpdated_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 30; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal uint AppID; // m_nAppID AppId_t internal ulong Unused; // m_ulUnused uint64 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStoragePublishedFileUpdated_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStoragePublishedFileUpdated_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStoragePublishedFileUpdated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 30; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStoragePublishedFileUpdated_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStoragePublishedFileUpdated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -14711,159 +3277,19 @@ public struct Pack8 public static implicit operator RemoteStoragePublishedFileUpdated_t ( RemoteStoragePublishedFileUpdated_t.Pack8 d ) => new RemoteStoragePublishedFileUpdated_t{ PublishedFileId = d.PublishedFileId,AppID = d.AppID,Unused = d.Unused, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageFileWriteAsyncComplete_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 31; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageFileWriteAsyncComplete_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageFileWriteAsyncComplete_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageFileWriteAsyncComplete_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 31; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageFileWriteAsyncComplete_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageFileWriteAsyncComplete_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -14879,167 +3305,22 @@ public struct Pack8 public static implicit operator RemoteStorageFileWriteAsyncComplete_t ( RemoteStorageFileWriteAsyncComplete_t.Pack8 d ) => new RemoteStorageFileWriteAsyncComplete_t{ Result = d.Result, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoteStorageFileReadAsyncComplete_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientRemoteStorage + 32; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong FileReadAsync; // m_hFileReadAsync SteamAPICall_t internal Result Result; // m_eResult enum EResult internal uint Offset; // m_nOffset uint32 internal uint Read; // m_cubRead uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoteStorageFileReadAsyncComplete_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoteStorageFileReadAsyncComplete_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageFileReadAsyncComplete_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientRemoteStorage + 32; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoteStorageFileReadAsyncComplete_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoteStorageFileReadAsyncComplete_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -15061,137 +3342,7 @@ public struct Pack8 public static implicit operator RemoteStorageFileReadAsyncComplete_t ( RemoteStorageFileReadAsyncComplete_t.Pack8 d ) => new RemoteStorageFileReadAsyncComplete_t{ FileReadAsync = d.FileReadAsync,Result = d.Result,Offset = d.Offset,Read = d.Read, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LeaderboardEntry_t @@ -15202,20 +3353,11 @@ public struct LeaderboardEntry_t internal int CDetails; // m_cDetails int32 internal ulong UGC; // m_hUGC UGCHandle_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LeaderboardEntry_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LeaderboardEntry_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LeaderboardEntry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public LeaderboardEntry_t Fill( IntPtr p ) => Platform.PackSmall ? ((LeaderboardEntry_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LeaderboardEntry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -15239,35 +3381,21 @@ public struct Pack8 public static implicit operator LeaderboardEntry_t ( LeaderboardEntry_t.Pack8 d ) => new LeaderboardEntry_t{ SteamIDUser = d.SteamIDUser,GlobalRank = d.GlobalRank,Score = d.Score,CDetails = d.CDetails,UGC = d.UGC, }; } + #endregion } public struct UserStatsReceived_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong GameID; // m_nGameID uint64 internal Result Result; // m_eResult enum EResult internal ulong SteamIDUser; // m_steamIDUser class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static UserStatsReceived_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((UserStatsReceived_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((UserStatsReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((UserStatsReceived_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((UserStatsReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -15287,165 +3415,20 @@ public struct Pack8 public static implicit operator UserStatsReceived_t ( UserStatsReceived_t.Pack8 d ) => new UserStatsReceived_t{ GameID = d.GameID,Result = d.Result,SteamIDUser = d.SteamIDUser, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct UserStatsStored_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong GameID; // m_nGameID uint64 internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static UserStatsStored_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((UserStatsStored_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((UserStatsStored_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((UserStatsStored_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((UserStatsStored_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -15463,143 +3446,11 @@ public struct Pack8 public static implicit operator UserStatsStored_t ( UserStatsStored_t.Pack8 d ) => new UserStatsStored_t{ GameID = d.GameID,Result = d.Result, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct UserAchievementStored_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 3; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong GameID; // m_nGameID uint64 [MarshalAs(UnmanagedType.I1)] internal bool GroupAchievement; // m_bGroupAchievement _Bool @@ -15608,20 +3459,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal uint CurProgress; // m_nCurProgress uint32 internal uint MaxProgress; // m_nMaxProgress uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static UserAchievementStored_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((UserAchievementStored_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((UserAchievementStored_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 3; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((UserAchievementStored_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((UserAchievementStored_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -15649,160 +3492,20 @@ public struct Pack8 public static implicit operator UserAchievementStored_t ( UserAchievementStored_t.Pack8 d ) => new UserAchievementStored_t{ GameID = d.GameID,GroupAchievement = d.GroupAchievement,AchievementName = d.AchievementName,CurProgress = d.CurProgress,MaxProgress = d.MaxProgress, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LeaderboardFindResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 4; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamLeaderboard; // m_hSteamLeaderboard SteamLeaderboard_t internal byte LeaderboardFound; // m_bLeaderboardFound uint8 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LeaderboardFindResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LeaderboardFindResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LeaderboardFindResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 4; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LeaderboardFindResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LeaderboardFindResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -15820,166 +3523,21 @@ public struct Pack8 public static implicit operator LeaderboardFindResult_t ( LeaderboardFindResult_t.Pack8 d ) => new LeaderboardFindResult_t{ SteamLeaderboard = d.SteamLeaderboard,LeaderboardFound = d.LeaderboardFound, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LeaderboardScoresDownloaded_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 5; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamLeaderboard; // m_hSteamLeaderboard SteamLeaderboard_t internal ulong SteamLeaderboardEntries; // m_hSteamLeaderboardEntries SteamLeaderboardEntries_t internal int CEntryCount; // m_cEntryCount int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LeaderboardScoresDownloaded_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LeaderboardScoresDownloaded_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LeaderboardScoresDownloaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 5; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LeaderboardScoresDownloaded_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LeaderboardScoresDownloaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -15999,148 +3557,11 @@ public struct Pack8 public static implicit operator LeaderboardScoresDownloaded_t ( LeaderboardScoresDownloaded_t.Pack8 d ) => new LeaderboardScoresDownloaded_t{ SteamLeaderboard = d.SteamLeaderboard,SteamLeaderboardEntries = d.SteamLeaderboardEntries,CEntryCount = d.CEntryCount, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LeaderboardScoreUploaded_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 6; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal byte Success; // m_bSuccess uint8 internal ulong SteamLeaderboard; // m_hSteamLeaderboard SteamLeaderboard_t internal int Score; // m_nScore int32 @@ -16148,20 +3569,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal int GlobalRankNew; // m_nGlobalRankNew int internal int GlobalRankPrevious; // m_nGlobalRankPrevious int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LeaderboardScoreUploaded_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LeaderboardScoreUploaded_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LeaderboardScoreUploaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 6; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LeaderboardScoreUploaded_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LeaderboardScoreUploaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -16187,165 +3600,20 @@ public struct Pack8 public static implicit operator LeaderboardScoreUploaded_t ( LeaderboardScoreUploaded_t.Pack8 d ) => new LeaderboardScoreUploaded_t{ Success = d.Success,SteamLeaderboard = d.SteamLeaderboard,Score = d.Score,ScoreChanged = d.ScoreChanged,GlobalRankNew = d.GlobalRankNew,GlobalRankPrevious = d.GlobalRankPrevious, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct NumberOfCurrentPlayers_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 7; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal byte Success; // m_bSuccess uint8 internal int CPlayers; // m_cPlayers int32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static NumberOfCurrentPlayers_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((NumberOfCurrentPlayers_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((NumberOfCurrentPlayers_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 7; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((NumberOfCurrentPlayers_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((NumberOfCurrentPlayers_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -16363,164 +3631,19 @@ public struct Pack8 public static implicit operator NumberOfCurrentPlayers_t ( NumberOfCurrentPlayers_t.Pack8 d ) => new NumberOfCurrentPlayers_t{ Success = d.Success,CPlayers = d.CPlayers, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct UserStatsUnloaded_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 8; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDUser; // m_steamIDUser class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static UserStatsUnloaded_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((UserStatsUnloaded_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((UserStatsUnloaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 8; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((UserStatsUnloaded_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((UserStatsUnloaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -16536,143 +3659,11 @@ public struct Pack8 public static implicit operator UserStatsUnloaded_t ( UserStatsUnloaded_t.Pack8 d ) => new UserStatsUnloaded_t{ SteamIDUser = d.SteamIDUser, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct UserAchievementIconFetched_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 9; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong GameID; // m_nGameID class CGameID [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] internal string AchievementName; // m_rgchAchievementName char [128] @@ -16680,20 +3671,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal bool Achieved; // m_bAchieved _Bool internal int IconHandle; // m_nIconHandle int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static UserAchievementIconFetched_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((UserAchievementIconFetched_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((UserAchievementIconFetched_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 9; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((UserAchievementIconFetched_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((UserAchievementIconFetched_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -16719,160 +3702,20 @@ public struct Pack8 public static implicit operator UserAchievementIconFetched_t ( UserAchievementIconFetched_t.Pack8 d ) => new UserAchievementIconFetched_t{ GameID = d.GameID,AchievementName = d.AchievementName,Achieved = d.Achieved,IconHandle = d.IconHandle, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GlobalAchievementPercentagesReady_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 10; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong GameID; // m_nGameID uint64 internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GlobalAchievementPercentagesReady_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GlobalAchievementPercentagesReady_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GlobalAchievementPercentagesReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 10; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GlobalAchievementPercentagesReady_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GlobalAchievementPercentagesReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -16890,165 +3733,20 @@ public struct Pack8 public static implicit operator GlobalAchievementPercentagesReady_t ( GlobalAchievementPercentagesReady_t.Pack8 d ) => new GlobalAchievementPercentagesReady_t{ GameID = d.GameID,Result = d.Result, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LeaderboardUGCSet_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 11; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong SteamLeaderboard; // m_hSteamLeaderboard SteamLeaderboard_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LeaderboardUGCSet_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LeaderboardUGCSet_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LeaderboardUGCSet_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 11; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LeaderboardUGCSet_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LeaderboardUGCSet_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -17066,166 +3764,21 @@ public struct Pack8 public static implicit operator LeaderboardUGCSet_t ( LeaderboardUGCSet_t.Pack8 d ) => new LeaderboardUGCSet_t{ Result = d.Result,SteamLeaderboard = d.SteamLeaderboard, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct PS3TrophiesInstalled_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 12; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong GameID; // m_nGameID uint64 internal Result Result; // m_eResult enum EResult internal ulong RequiredDiskSpace; // m_ulRequiredDiskSpace uint64 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static PS3TrophiesInstalled_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((PS3TrophiesInstalled_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((PS3TrophiesInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 12; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((PS3TrophiesInstalled_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((PS3TrophiesInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -17245,160 +3798,20 @@ public struct Pack8 public static implicit operator PS3TrophiesInstalled_t ( PS3TrophiesInstalled_t.Pack8 d ) => new PS3TrophiesInstalled_t{ GameID = d.GameID,Result = d.Result,RequiredDiskSpace = d.RequiredDiskSpace, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GlobalStatsReceived_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 12; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong GameID; // m_nGameID uint64 internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GlobalStatsReceived_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GlobalStatsReceived_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GlobalStatsReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 12; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GlobalStatsReceived_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GlobalStatsReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -17416,164 +3829,19 @@ public struct Pack8 public static implicit operator GlobalStatsReceived_t ( GlobalStatsReceived_t.Pack8 d ) => new GlobalStatsReceived_t{ GameID = d.GameID,Result = d.Result, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct DlcInstalled_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamApps + 5; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint AppID; // m_nAppID AppId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static DlcInstalled_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((DlcInstalled_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((DlcInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamApps + 5; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((DlcInstalled_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((DlcInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -17589,160 +3857,20 @@ public struct Pack8 public static implicit operator DlcInstalled_t ( DlcInstalled_t.Pack8 d ) => new DlcInstalled_t{ AppID = d.AppID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RegisterActivationCodeResponse_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamApps + 8; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal RegisterActivationCodeResult Result; // m_eResult enum ERegisterActivationCodeResult internal uint PackageRegistered; // m_unPackageRegistered uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RegisterActivationCodeResponse_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RegisterActivationCodeResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RegisterActivationCodeResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamApps + 8; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RegisterActivationCodeResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RegisterActivationCodeResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -17760,163 +3888,23 @@ public struct Pack8 public static implicit operator RegisterActivationCodeResponse_t ( RegisterActivationCodeResponse_t.Pack8 d ) => new RegisterActivationCodeResponse_t{ Result = d.Result,PackageRegistered = d.PackageRegistered, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct AppProofOfPurchaseKeyResponse_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamApps + 21; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal uint AppID; // m_nAppID uint32 internal uint CchKeyLength; // m_cchKeyLength uint32 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 240)] internal string Key; // m_rgchKey char [240] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static AppProofOfPurchaseKeyResponse_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((AppProofOfPurchaseKeyResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((AppProofOfPurchaseKeyResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamApps + 21; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((AppProofOfPurchaseKeyResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((AppProofOfPurchaseKeyResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -17940,163 +3928,23 @@ public struct Pack8 public static implicit operator AppProofOfPurchaseKeyResponse_t ( AppProofOfPurchaseKeyResponse_t.Pack8 d ) => new AppProofOfPurchaseKeyResponse_t{ Result = d.Result,AppID = d.AppID,CchKeyLength = d.CchKeyLength,Key = d.Key, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct FileDetailsResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamApps + 23; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong FileSize; // m_ulFileSize uint64 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] // m_FileSHA internal byte[] FileSHA; // m_FileSHA uint8 [20] internal uint Flags; // m_unFlags uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static FileDetailsResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((FileDetailsResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FileDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamApps + 23; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((FileDetailsResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((FileDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -18120,137 +3968,7 @@ public struct Pack8 public static implicit operator FileDetailsResult_t ( FileDetailsResult_t.Pack8 d ) => new FileDetailsResult_t{ Result = d.Result,FileSize = d.FileSize,FileSHA = d.FileSHA,Flags = d.Flags, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct P2PSessionState_t @@ -18264,20 +3982,11 @@ public struct P2PSessionState_t internal uint RemoteIP; // m_nRemoteIP uint32 internal ushort RemotePort; // m_nRemotePort uint16 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static P2PSessionState_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((P2PSessionState_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((P2PSessionState_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public P2PSessionState_t Fill( IntPtr p ) => Platform.PackSmall ? ((P2PSessionState_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((P2PSessionState_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -18307,33 +4016,19 @@ public struct Pack8 public static implicit operator P2PSessionState_t ( P2PSessionState_t.Pack8 d ) => new P2PSessionState_t{ ConnectionActive = d.ConnectionActive,Connecting = d.Connecting,P2PSessionError = d.P2PSessionError,UsingRelay = d.UsingRelay,BytesQueuedForSend = d.BytesQueuedForSend,PacketsQueuedForSend = d.PacketsQueuedForSend,RemoteIP = d.RemoteIP,RemotePort = d.RemotePort, }; } + #endregion } public struct P2PSessionRequest_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamNetworking + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDRemote; // m_steamIDRemote class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static P2PSessionRequest_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((P2PSessionRequest_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((P2PSessionRequest_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamNetworking + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((P2PSessionRequest_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((P2PSessionRequest_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -18349,160 +4044,20 @@ public struct Pack8 public static implicit operator P2PSessionRequest_t ( P2PSessionRequest_t.Pack8 d ) => new P2PSessionRequest_t{ SteamIDRemote = d.SteamIDRemote, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct P2PSessionConnectFail_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamNetworking + 3; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDRemote; // m_steamIDRemote class CSteamID internal byte P2PSessionError; // m_eP2PSessionError uint8 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static P2PSessionConnectFail_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((P2PSessionConnectFail_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((P2PSessionConnectFail_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamNetworking + 3; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((P2PSessionConnectFail_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((P2PSessionConnectFail_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -18520,162 +4075,22 @@ public struct Pack8 public static implicit operator P2PSessionConnectFail_t ( P2PSessionConnectFail_t.Pack8 d ) => new P2PSessionConnectFail_t{ SteamIDRemote = d.SteamIDRemote,P2PSessionError = d.P2PSessionError, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SocketStatusCallback_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamNetworking + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint Socket; // m_hSocket SNetSocket_t internal uint ListenSocket; // m_hListenSocket SNetListenSocket_t internal ulong SteamIDRemote; // m_steamIDRemote class CSteamID internal int SNetSocketState; // m_eSNetSocketState int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SocketStatusCallback_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SocketStatusCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SocketStatusCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamNetworking + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SocketStatusCallback_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SocketStatusCallback_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -18697,160 +4112,20 @@ public struct Pack8 public static implicit operator SocketStatusCallback_t ( SocketStatusCallback_t.Pack8 d ) => new SocketStatusCallback_t{ Socket = d.Socket,ListenSocket = d.ListenSocket,SteamIDRemote = d.SteamIDRemote,SNetSocketState = d.SNetSocketState, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct ScreenshotReady_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamScreenshots + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint Local; // m_hLocal ScreenshotHandle internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static ScreenshotReady_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((ScreenshotReady_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ScreenshotReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamScreenshots + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((ScreenshotReady_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ScreenshotReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -18868,159 +4143,19 @@ public struct Pack8 public static implicit operator ScreenshotReady_t ( ScreenshotReady_t.Pack8 d ) => new ScreenshotReady_t{ Local = d.Local,Result = d.Result, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct VolumeHasChanged_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMusic + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal float NewVolume; // m_flNewVolume float - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static VolumeHasChanged_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((VolumeHasChanged_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((VolumeHasChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMusic + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((VolumeHasChanged_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((VolumeHasChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -19036,160 +4171,20 @@ public struct Pack8 public static implicit operator VolumeHasChanged_t ( VolumeHasChanged_t.Pack8 d ) => new VolumeHasChanged_t{ NewVolume = d.NewVolume, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct MusicPlayerWantsShuffled_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMusicRemote + 9; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } [MarshalAs(UnmanagedType.I1)] internal bool Shuffled; // m_bShuffled _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static MusicPlayerWantsShuffled_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((MusicPlayerWantsShuffled_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MusicPlayerWantsShuffled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMusicRemote + 9; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((MusicPlayerWantsShuffled_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MusicPlayerWantsShuffled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -19207,160 +4202,20 @@ public struct Pack8 public static implicit operator MusicPlayerWantsShuffled_t ( MusicPlayerWantsShuffled_t.Pack8 d ) => new MusicPlayerWantsShuffled_t{ Shuffled = d.Shuffled, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct MusicPlayerWantsLooped_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMusicRemote + 10; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } [MarshalAs(UnmanagedType.I1)] internal bool Looped; // m_bLooped _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static MusicPlayerWantsLooped_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((MusicPlayerWantsLooped_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MusicPlayerWantsLooped_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMusicRemote + 10; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((MusicPlayerWantsLooped_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MusicPlayerWantsLooped_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -19378,159 +4233,19 @@ public struct Pack8 public static implicit operator MusicPlayerWantsLooped_t ( MusicPlayerWantsLooped_t.Pack8 d ) => new MusicPlayerWantsLooped_t{ Looped = d.Looped, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct MusicPlayerWantsVolume_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMusic + 11; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal float NewVolume; // m_flNewVolume float - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static MusicPlayerWantsVolume_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((MusicPlayerWantsVolume_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MusicPlayerWantsVolume_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMusic + 11; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((MusicPlayerWantsVolume_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MusicPlayerWantsVolume_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -19546,159 +4261,19 @@ public struct Pack8 public static implicit operator MusicPlayerWantsVolume_t ( MusicPlayerWantsVolume_t.Pack8 d ) => new MusicPlayerWantsVolume_t{ NewVolume = d.NewVolume, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct MusicPlayerSelectsQueueEntry_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMusic + 12; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal int NID; // nID int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static MusicPlayerSelectsQueueEntry_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((MusicPlayerSelectsQueueEntry_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MusicPlayerSelectsQueueEntry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMusic + 12; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((MusicPlayerSelectsQueueEntry_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MusicPlayerSelectsQueueEntry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -19714,159 +4289,19 @@ public struct Pack8 public static implicit operator MusicPlayerSelectsQueueEntry_t ( MusicPlayerSelectsQueueEntry_t.Pack8 d ) => new MusicPlayerSelectsQueueEntry_t{ NID = d.NID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct MusicPlayerSelectsPlaylistEntry_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMusic + 13; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal int NID; // nID int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static MusicPlayerSelectsPlaylistEntry_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((MusicPlayerSelectsPlaylistEntry_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MusicPlayerSelectsPlaylistEntry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMusic + 13; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((MusicPlayerSelectsPlaylistEntry_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MusicPlayerSelectsPlaylistEntry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -19882,159 +4317,19 @@ public struct Pack8 public static implicit operator MusicPlayerSelectsPlaylistEntry_t ( MusicPlayerSelectsPlaylistEntry_t.Pack8 d ) => new MusicPlayerSelectsPlaylistEntry_t{ NID = d.NID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct MusicPlayerWantsPlayingRepeatStatus_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamMusicRemote + 14; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal int PlayingRepeatStatus; // m_nPlayingRepeatStatus int - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static MusicPlayerWantsPlayingRepeatStatus_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((MusicPlayerWantsPlayingRepeatStatus_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MusicPlayerWantsPlayingRepeatStatus_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamMusicRemote + 14; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((MusicPlayerWantsPlayingRepeatStatus_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((MusicPlayerWantsPlayingRepeatStatus_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -20050,143 +4345,11 @@ public struct Pack8 public static implicit operator MusicPlayerWantsPlayingRepeatStatus_t ( MusicPlayerWantsPlayingRepeatStatus_t.Pack8 d ) => new MusicPlayerWantsPlayingRepeatStatus_t{ PlayingRepeatStatus = d.PlayingRepeatStatus, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTTPRequestCompleted_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientHTTP + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint Request; // m_hRequest HTTPRequestHandle internal ulong ContextValue; // m_ulContextValue uint64 [MarshalAs(UnmanagedType.I1)] @@ -20194,20 +4357,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal HTTPStatusCode StatusCode; // m_eStatusCode enum EHTTPStatusCode internal uint BodySize; // m_unBodySize uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTTPRequestCompleted_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTTPRequestCompleted_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTTPRequestCompleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientHTTP + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTTPRequestCompleted_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTTPRequestCompleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -20233,160 +4388,20 @@ public struct Pack8 public static implicit operator HTTPRequestCompleted_t ( HTTPRequestCompleted_t.Pack8 d ) => new HTTPRequestCompleted_t{ Request = d.Request,ContextValue = d.ContextValue,RequestSuccessful = d.RequestSuccessful,StatusCode = d.StatusCode,BodySize = d.BodySize, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTTPRequestHeadersReceived_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientHTTP + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint Request; // m_hRequest HTTPRequestHandle internal ulong ContextValue; // m_ulContextValue uint64 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTTPRequestHeadersReceived_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTTPRequestHeadersReceived_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTTPRequestHeadersReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientHTTP + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTTPRequestHeadersReceived_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTTPRequestHeadersReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -20404,162 +4419,22 @@ public struct Pack8 public static implicit operator HTTPRequestHeadersReceived_t ( HTTPRequestHeadersReceived_t.Pack8 d ) => new HTTPRequestHeadersReceived_t{ Request = d.Request,ContextValue = d.ContextValue, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTTPRequestDataReceived_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientHTTP + 3; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint Request; // m_hRequest HTTPRequestHandle internal ulong ContextValue; // m_ulContextValue uint64 internal uint COffset; // m_cOffset uint32 internal uint CBytesReceived; // m_cBytesReceived uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTTPRequestDataReceived_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTTPRequestDataReceived_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTTPRequestDataReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientHTTP + 3; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTTPRequestDataReceived_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTTPRequestDataReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -20581,132 +4456,7 @@ public struct Pack8 public static implicit operator HTTPRequestDataReceived_t ( HTTPRequestDataReceived_t.Pack8 d ) => new HTTPRequestDataReceived_t{ Request = d.Request,ContextValue = d.ContextValue,COffset = d.COffset,CBytesReceived = d.CBytesReceived, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamUGCDetails_t @@ -20746,20 +4496,11 @@ public struct SteamUGCDetails_t internal float Score; // m_flScore float internal uint NumChildren; // m_unNumChildren uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamUGCDetails_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamUGCDetails_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamUGCDetails_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public SteamUGCDetails_t Fill( IntPtr p ) => Platform.PackSmall ? ((SteamUGCDetails_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamUGCDetails_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -20841,17 +4582,11 @@ public struct Pack8 public static implicit operator SteamUGCDetails_t ( SteamUGCDetails_t.Pack8 d ) => new SteamUGCDetails_t{ PublishedFileId = d.PublishedFileId,Result = d.Result,FileType = d.FileType,CreatorAppID = d.CreatorAppID,ConsumerAppID = d.ConsumerAppID,Title = d.Title,Description = d.Description,SteamIDOwner = d.SteamIDOwner,TimeCreated = d.TimeCreated,TimeUpdated = d.TimeUpdated,TimeAddedToUserList = d.TimeAddedToUserList,Visibility = d.Visibility,Banned = d.Banned,AcceptedForUse = d.AcceptedForUse,TagsTruncated = d.TagsTruncated,Tags = d.Tags,File = d.File,PreviewFile = d.PreviewFile,PchFileName = d.PchFileName,FileSize = d.FileSize,PreviewFileSize = d.PreviewFileSize,URL = d.URL,VotesUp = d.VotesUp,VotesDown = d.VotesDown,Score = d.Score,NumChildren = d.NumChildren, }; } + #endregion } public struct SteamUGCQueryCompleted_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong Handle; // m_handle UGCQueryHandle_t internal Result Result; // m_eResult enum EResult internal uint NumResultsReturned; // m_unNumResultsReturned uint32 @@ -20861,20 +4596,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] internal string NextCursor; // m_rgchNextCursor char [256] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamUGCQueryCompleted_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamUGCQueryCompleted_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamUGCQueryCompleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamUGCQueryCompleted_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamUGCQueryCompleted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -20904,166 +4631,21 @@ public struct Pack8 public static implicit operator SteamUGCQueryCompleted_t ( SteamUGCQueryCompleted_t.Pack8 d ) => new SteamUGCQueryCompleted_t{ Handle = d.Handle,Result = d.Result,NumResultsReturned = d.NumResultsReturned,TotalMatchingResults = d.TotalMatchingResults,CachedData = d.CachedData,NextCursor = d.NextCursor, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamUGCRequestUGCDetailsResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal SteamUGCDetails_t Details; // m_details struct SteamUGCDetails_t [MarshalAs(UnmanagedType.I1)] internal bool CachedData; // m_bCachedData _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamUGCRequestUGCDetailsResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamUGCRequestUGCDetailsResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamUGCRequestUGCDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamUGCRequestUGCDetailsResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamUGCRequestUGCDetailsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -21083,162 +4665,22 @@ public struct Pack8 public static implicit operator SteamUGCRequestUGCDetailsResult_t ( SteamUGCRequestUGCDetailsResult_t.Pack8 d ) => new SteamUGCRequestUGCDetailsResult_t{ Details = d.Details,CachedData = d.CachedData, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct CreateItemResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 3; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t [MarshalAs(UnmanagedType.I1)] internal bool UserNeedsToAcceptWorkshopLegalAgreement; // m_bUserNeedsToAcceptWorkshopLegalAgreement _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static CreateItemResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((CreateItemResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((CreateItemResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 3; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((CreateItemResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((CreateItemResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -21260,167 +4702,22 @@ public struct Pack8 public static implicit operator CreateItemResult_t ( CreateItemResult_t.Pack8 d ) => new CreateItemResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId,UserNeedsToAcceptWorkshopLegalAgreement = d.UserNeedsToAcceptWorkshopLegalAgreement, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SubmitItemUpdateResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 4; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult [MarshalAs(UnmanagedType.I1)] internal bool UserNeedsToAcceptWorkshopLegalAgreement; // m_bUserNeedsToAcceptWorkshopLegalAgreement _Bool internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SubmitItemUpdateResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SubmitItemUpdateResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SubmitItemUpdateResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 4; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SubmitItemUpdateResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SubmitItemUpdateResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -21442,166 +4739,21 @@ public struct Pack8 public static implicit operator SubmitItemUpdateResult_t ( SubmitItemUpdateResult_t.Pack8 d ) => new SubmitItemUpdateResult_t{ Result = d.Result,UserNeedsToAcceptWorkshopLegalAgreement = d.UserNeedsToAcceptWorkshopLegalAgreement,PublishedFileId = d.PublishedFileId, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct DownloadItemResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 6; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint AppID; // m_unAppID AppId_t internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static DownloadItemResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((DownloadItemResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((DownloadItemResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 6; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((DownloadItemResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((DownloadItemResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -21621,162 +4773,22 @@ public struct Pack8 public static implicit operator DownloadItemResult_t ( DownloadItemResult_t.Pack8 d ) => new DownloadItemResult_t{ AppID = d.AppID,PublishedFileId = d.PublishedFileId,Result = d.Result, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct UserFavoriteItemsListChanged_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 7; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal Result Result; // m_eResult enum EResult [MarshalAs(UnmanagedType.I1)] internal bool WasAddRequest; // m_bWasAddRequest _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static UserFavoriteItemsListChanged_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((UserFavoriteItemsListChanged_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((UserFavoriteItemsListChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 7; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((UserFavoriteItemsListChanged_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((UserFavoriteItemsListChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -21798,167 +4810,22 @@ public struct Pack8 public static implicit operator UserFavoriteItemsListChanged_t ( UserFavoriteItemsListChanged_t.Pack8 d ) => new UserFavoriteItemsListChanged_t{ PublishedFileId = d.PublishedFileId,Result = d.Result,WasAddRequest = d.WasAddRequest, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SetUserItemVoteResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 8; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal Result Result; // m_eResult enum EResult [MarshalAs(UnmanagedType.I1)] internal bool VoteUp; // m_bVoteUp _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SetUserItemVoteResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SetUserItemVoteResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SetUserItemVoteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 8; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SetUserItemVoteResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SetUserItemVoteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -21980,148 +4847,11 @@ public struct Pack8 public static implicit operator SetUserItemVoteResult_t ( SetUserItemVoteResult_t.Pack8 d ) => new SetUserItemVoteResult_t{ PublishedFileId = d.PublishedFileId,Result = d.Result,VoteUp = d.VoteUp, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GetUserItemVoteResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 9; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal Result Result; // m_eResult enum EResult [MarshalAs(UnmanagedType.I1)] @@ -22131,20 +4861,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) [MarshalAs(UnmanagedType.I1)] internal bool VoteSkipped; // m_bVoteSkipped _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GetUserItemVoteResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GetUserItemVoteResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GetUserItemVoteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 9; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GetUserItemVoteResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GetUserItemVoteResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -22174,164 +4896,19 @@ public struct Pack8 public static implicit operator GetUserItemVoteResult_t ( GetUserItemVoteResult_t.Pack8 d ) => new GetUserItemVoteResult_t{ PublishedFileId = d.PublishedFileId,Result = d.Result,VotedUp = d.VotedUp,VotedDown = d.VotedDown,VoteSkipped = d.VoteSkipped, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct StartPlaytimeTrackingResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 10; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static StartPlaytimeTrackingResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((StartPlaytimeTrackingResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((StartPlaytimeTrackingResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 10; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((StartPlaytimeTrackingResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((StartPlaytimeTrackingResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -22347,164 +4924,19 @@ public struct Pack8 public static implicit operator StartPlaytimeTrackingResult_t ( StartPlaytimeTrackingResult_t.Pack8 d ) => new StartPlaytimeTrackingResult_t{ Result = d.Result, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct StopPlaytimeTrackingResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 11; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static StopPlaytimeTrackingResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((StopPlaytimeTrackingResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((StopPlaytimeTrackingResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 11; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((StopPlaytimeTrackingResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((StopPlaytimeTrackingResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -22520,166 +4952,21 @@ public struct Pack8 public static implicit operator StopPlaytimeTrackingResult_t ( StopPlaytimeTrackingResult_t.Pack8 d ) => new StopPlaytimeTrackingResult_t{ Result = d.Result, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct AddUGCDependencyResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 12; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal ulong ChildPublishedFileId; // m_nChildPublishedFileId PublishedFileId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static AddUGCDependencyResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((AddUGCDependencyResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((AddUGCDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 12; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((AddUGCDependencyResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((AddUGCDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -22699,166 +4986,21 @@ public struct Pack8 public static implicit operator AddUGCDependencyResult_t ( AddUGCDependencyResult_t.Pack8 d ) => new AddUGCDependencyResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId,ChildPublishedFileId = d.ChildPublishedFileId, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoveUGCDependencyResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 13; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal ulong ChildPublishedFileId; // m_nChildPublishedFileId PublishedFileId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoveUGCDependencyResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoveUGCDependencyResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoveUGCDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 13; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoveUGCDependencyResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoveUGCDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -22878,166 +5020,21 @@ public struct Pack8 public static implicit operator RemoveUGCDependencyResult_t ( RemoveUGCDependencyResult_t.Pack8 d ) => new RemoveUGCDependencyResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId,ChildPublishedFileId = d.ChildPublishedFileId, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct AddAppDependencyResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 14; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal uint AppID; // m_nAppID AppId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static AddAppDependencyResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((AddAppDependencyResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((AddAppDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 14; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((AddAppDependencyResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((AddAppDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -23057,166 +5054,21 @@ public struct Pack8 public static implicit operator AddAppDependencyResult_t ( AddAppDependencyResult_t.Pack8 d ) => new AddAppDependencyResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId,AppID = d.AppID, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct RemoveAppDependencyResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 15; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t internal uint AppID; // m_nAppID AppId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static RemoveAppDependencyResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((RemoveAppDependencyResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoveAppDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 15; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((RemoveAppDependencyResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((RemoveAppDependencyResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -23236,148 +5088,11 @@ public struct Pack8 public static implicit operator RemoveAppDependencyResult_t ( RemoveAppDependencyResult_t.Pack8 d ) => new RemoveAppDependencyResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId,AppID = d.AppID, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GetAppDependenciesResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 16; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32, ArraySubType = UnmanagedType.U4)] @@ -23385,20 +5100,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal uint NumAppDependencies; // m_nNumAppDependencies uint32 internal uint TotalNumAppDependencies; // m_nTotalNumAppDependencies uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GetAppDependenciesResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GetAppDependenciesResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GetAppDependenciesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 16; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GetAppDependenciesResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GetAppDependenciesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -23424,165 +5131,20 @@ public struct Pack8 public static implicit operator GetAppDependenciesResult_t ( GetAppDependenciesResult_t.Pack8 d ) => new GetAppDependenciesResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId,GAppIDs = d.GAppIDs,NumAppDependencies = d.NumAppDependencies,TotalNumAppDependencies = d.TotalNumAppDependencies, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct DeleteItemResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 17; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static DeleteItemResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((DeleteItemResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((DeleteItemResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 17; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((DeleteItemResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((DeleteItemResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -23600,164 +5162,19 @@ public struct Pack8 public static implicit operator DeleteItemResult_t ( DeleteItemResult_t.Pack8 d ) => new DeleteItemResult_t{ Result = d.Result,PublishedFileId = d.PublishedFileId, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamAppInstalled_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamAppList + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint AppID; // m_nAppID AppId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamAppInstalled_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamAppInstalled_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamAppInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamAppList + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamAppInstalled_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamAppInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -23773,159 +5190,19 @@ public struct Pack8 public static implicit operator SteamAppInstalled_t ( SteamAppInstalled_t.Pack8 d ) => new SteamAppInstalled_t{ AppID = d.AppID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamAppUninstalled_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamAppList + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint AppID; // m_nAppID AppId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamAppUninstalled_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamAppUninstalled_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamAppUninstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamAppList + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamAppUninstalled_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamAppUninstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -23941,159 +5218,19 @@ public struct Pack8 public static implicit operator SteamAppUninstalled_t ( SteamAppUninstalled_t.Pack8 d ) => new SteamAppUninstalled_t{ AppID = d.AppID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_BrowserReady_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_BrowserReady_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_BrowserReady_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_BrowserReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_BrowserReady_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_BrowserReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -24109,137 +5246,7 @@ public struct Pack8 public static implicit operator HTML_BrowserReady_t ( HTML_BrowserReady_t.Pack8 d ) => new HTML_BrowserReady_t{ UnBrowserHandle = d.UnBrowserHandle, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_NeedsPaint_t @@ -24257,20 +5264,11 @@ public struct HTML_NeedsPaint_t internal float FlPageScale; // flPageScale float internal uint UnPageSerial; // unPageSerial uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_NeedsPaint_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_NeedsPaint_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_NeedsPaint_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public HTML_NeedsPaint_t Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_NeedsPaint_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_NeedsPaint_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -24308,6 +5306,7 @@ public struct Pack8 public static implicit operator HTML_NeedsPaint_t ( HTML_NeedsPaint_t.Pack8 d ) => new HTML_NeedsPaint_t{ UnBrowserHandle = d.UnBrowserHandle,PBGRA = d.PBGRA,UnWide = d.UnWide,UnTall = d.UnTall,UnUpdateX = d.UnUpdateX,UnUpdateY = d.UnUpdateY,UnUpdateWide = d.UnUpdateWide,UnUpdateTall = d.UnUpdateTall,UnScrollX = d.UnScrollX,UnScrollY = d.UnScrollY,FlPageScale = d.FlPageScale,UnPageSerial = d.UnPageSerial, }; } + #endregion } public struct HTML_StartRequest_t @@ -24319,20 +5318,11 @@ public struct HTML_StartRequest_t [MarshalAs(UnmanagedType.I1)] internal bool BIsRedirect; // bIsRedirect _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_StartRequest_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_StartRequest_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_StartRequest_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public HTML_StartRequest_t Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_StartRequest_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_StartRequest_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -24358,26 +5348,18 @@ public struct Pack8 public static implicit operator HTML_StartRequest_t ( HTML_StartRequest_t.Pack8 d ) => new HTML_StartRequest_t{ UnBrowserHandle = d.UnBrowserHandle,PchURL = d.PchURL,PchTarget = d.PchTarget,PchPostData = d.PchPostData,BIsRedirect = d.BIsRedirect, }; } + #endregion } public struct HTML_CloseBrowser_t { internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_CloseBrowser_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_CloseBrowser_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_CloseBrowser_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public HTML_CloseBrowser_t Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_CloseBrowser_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_CloseBrowser_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -24393,17 +5375,11 @@ public struct Pack8 public static implicit operator HTML_CloseBrowser_t ( HTML_CloseBrowser_t.Pack8 d ) => new HTML_CloseBrowser_t{ UnBrowserHandle = d.UnBrowserHandle, }; } + #endregion } public struct HTML_URLChanged_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 5; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchURL; // pchURL const char * internal string PchPostData; // pchPostData const char * @@ -24413,20 +5389,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) [MarshalAs(UnmanagedType.I1)] internal bool BNewNavigation; // bNewNavigation _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_URLChanged_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_URLChanged_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_URLChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 5; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_URLChanged_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_URLChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -24456,161 +5424,21 @@ public struct Pack8 public static implicit operator HTML_URLChanged_t ( HTML_URLChanged_t.Pack8 d ) => new HTML_URLChanged_t{ UnBrowserHandle = d.UnBrowserHandle,PchURL = d.PchURL,PchPostData = d.PchPostData,BIsRedirect = d.BIsRedirect,PchPageTitle = d.PchPageTitle,BNewNavigation = d.BNewNavigation, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_FinishedRequest_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 6; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchURL; // pchURL const char * internal string PchPageTitle; // pchPageTitle const char * - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_FinishedRequest_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_FinishedRequest_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_FinishedRequest_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 6; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_FinishedRequest_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_FinishedRequest_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -24630,160 +5458,20 @@ public struct Pack8 public static implicit operator HTML_FinishedRequest_t ( HTML_FinishedRequest_t.Pack8 d ) => new HTML_FinishedRequest_t{ UnBrowserHandle = d.UnBrowserHandle,PchURL = d.PchURL,PchPageTitle = d.PchPageTitle, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_OpenLinkInNewTab_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 7; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchURL; // pchURL const char * - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_OpenLinkInNewTab_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_OpenLinkInNewTab_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_OpenLinkInNewTab_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 7; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_OpenLinkInNewTab_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_OpenLinkInNewTab_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -24801,160 +5489,20 @@ public struct Pack8 public static implicit operator HTML_OpenLinkInNewTab_t ( HTML_OpenLinkInNewTab_t.Pack8 d ) => new HTML_OpenLinkInNewTab_t{ UnBrowserHandle = d.UnBrowserHandle,PchURL = d.PchURL, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_ChangedTitle_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 8; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchTitle; // pchTitle const char * - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_ChangedTitle_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_ChangedTitle_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_ChangedTitle_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 8; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_ChangedTitle_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_ChangedTitle_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -24972,161 +5520,21 @@ public struct Pack8 public static implicit operator HTML_ChangedTitle_t ( HTML_ChangedTitle_t.Pack8 d ) => new HTML_ChangedTitle_t{ UnBrowserHandle = d.UnBrowserHandle,PchTitle = d.PchTitle, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_SearchResults_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 9; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal uint UnResults; // unResults uint32 internal uint UnCurrentMatch; // unCurrentMatch uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_SearchResults_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_SearchResults_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_SearchResults_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 9; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_SearchResults_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_SearchResults_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -25146,163 +5554,23 @@ public struct Pack8 public static implicit operator HTML_SearchResults_t ( HTML_SearchResults_t.Pack8 d ) => new HTML_SearchResults_t{ UnBrowserHandle = d.UnBrowserHandle,UnResults = d.UnResults,UnCurrentMatch = d.UnCurrentMatch, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_CanGoBackAndForward_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 10; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser [MarshalAs(UnmanagedType.I1)] internal bool BCanGoBack; // bCanGoBack _Bool [MarshalAs(UnmanagedType.I1)] internal bool BCanGoForward; // bCanGoForward _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_CanGoBackAndForward_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_CanGoBackAndForward_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_CanGoBackAndForward_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 10; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_CanGoBackAndForward_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_CanGoBackAndForward_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -25326,143 +5594,11 @@ public struct Pack8 public static implicit operator HTML_CanGoBackAndForward_t ( HTML_CanGoBackAndForward_t.Pack8 d ) => new HTML_CanGoBackAndForward_t{ UnBrowserHandle = d.UnBrowserHandle,BCanGoBack = d.BCanGoBack,BCanGoForward = d.BCanGoForward, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_HorizontalScroll_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 11; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal uint UnScrollMax; // unScrollMax uint32 internal uint UnScrollCurrent; // unScrollCurrent uint32 @@ -25471,20 +5607,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal bool BVisible; // bVisible _Bool internal uint UnPageSize; // unPageSize uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_HorizontalScroll_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_HorizontalScroll_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_HorizontalScroll_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 11; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_HorizontalScroll_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_HorizontalScroll_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -25512,143 +5640,11 @@ public struct Pack8 public static implicit operator HTML_HorizontalScroll_t ( HTML_HorizontalScroll_t.Pack8 d ) => new HTML_HorizontalScroll_t{ UnBrowserHandle = d.UnBrowserHandle,UnScrollMax = d.UnScrollMax,UnScrollCurrent = d.UnScrollCurrent,FlPageScale = d.FlPageScale,BVisible = d.BVisible,UnPageSize = d.UnPageSize, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_VerticalScroll_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 12; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal uint UnScrollMax; // unScrollMax uint32 internal uint UnScrollCurrent; // unScrollCurrent uint32 @@ -25657,20 +5653,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal bool BVisible; // bVisible _Bool internal uint UnPageSize; // unPageSize uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_VerticalScroll_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_VerticalScroll_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_VerticalScroll_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 12; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_VerticalScroll_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_VerticalScroll_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -25698,143 +5686,11 @@ public struct Pack8 public static implicit operator HTML_VerticalScroll_t ( HTML_VerticalScroll_t.Pack8 d ) => new HTML_VerticalScroll_t{ UnBrowserHandle = d.UnBrowserHandle,UnScrollMax = d.UnScrollMax,UnScrollCurrent = d.UnScrollCurrent,FlPageScale = d.FlPageScale,BVisible = d.BVisible,UnPageSize = d.UnPageSize, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_LinkAtPosition_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 13; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal uint X; // x uint32 internal uint Y; // y uint32 @@ -25844,20 +5700,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) [MarshalAs(UnmanagedType.I1)] internal bool BLiveLink; // bLiveLink _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_LinkAtPosition_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_LinkAtPosition_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_LinkAtPosition_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 13; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_LinkAtPosition_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_LinkAtPosition_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -25887,160 +5735,20 @@ public struct Pack8 public static implicit operator HTML_LinkAtPosition_t ( HTML_LinkAtPosition_t.Pack8 d ) => new HTML_LinkAtPosition_t{ UnBrowserHandle = d.UnBrowserHandle,X = d.X,Y = d.Y,PchURL = d.PchURL,BInput = d.BInput,BLiveLink = d.BLiveLink, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_JSAlert_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 14; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchMessage; // pchMessage const char * - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_JSAlert_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_JSAlert_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_JSAlert_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 14; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_JSAlert_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_JSAlert_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -26058,160 +5766,20 @@ public struct Pack8 public static implicit operator HTML_JSAlert_t ( HTML_JSAlert_t.Pack8 d ) => new HTML_JSAlert_t{ UnBrowserHandle = d.UnBrowserHandle,PchMessage = d.PchMessage, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_JSConfirm_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 15; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchMessage; // pchMessage const char * - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_JSConfirm_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_JSConfirm_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_JSConfirm_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 15; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_JSConfirm_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_JSConfirm_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -26229,161 +5797,21 @@ public struct Pack8 public static implicit operator HTML_JSConfirm_t ( HTML_JSConfirm_t.Pack8 d ) => new HTML_JSConfirm_t{ UnBrowserHandle = d.UnBrowserHandle,PchMessage = d.PchMessage, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_FileOpenDialog_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 16; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchTitle; // pchTitle const char * internal string PchInitialFile; // pchInitialFile const char * - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_FileOpenDialog_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_FileOpenDialog_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_FileOpenDialog_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 16; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_FileOpenDialog_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_FileOpenDialog_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -26403,143 +5831,11 @@ public struct Pack8 public static implicit operator HTML_FileOpenDialog_t ( HTML_FileOpenDialog_t.Pack8 d ) => new HTML_FileOpenDialog_t{ UnBrowserHandle = d.UnBrowserHandle,PchTitle = d.PchTitle,PchInitialFile = d.PchInitialFile, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_NewWindow_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 21; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchURL; // pchURL const char * internal uint UnX; // unX uint32 @@ -26548,20 +5844,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal uint UnTall; // unTall uint32 internal uint UnNewWindow_BrowserHandle_IGNORE; // unNewWindow_BrowserHandle_IGNORE HHTMLBrowser - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_NewWindow_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_NewWindow_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_NewWindow_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 21; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_NewWindow_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_NewWindow_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -26589,160 +5877,20 @@ public struct Pack8 public static implicit operator HTML_NewWindow_t ( HTML_NewWindow_t.Pack8 d ) => new HTML_NewWindow_t{ UnBrowserHandle = d.UnBrowserHandle,PchURL = d.PchURL,UnX = d.UnX,UnY = d.UnY,UnWide = d.UnWide,UnTall = d.UnTall,UnNewWindow_BrowserHandle_IGNORE = d.UnNewWindow_BrowserHandle_IGNORE, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_SetCursor_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 22; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal uint EMouseCursor; // eMouseCursor uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_SetCursor_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_SetCursor_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_SetCursor_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 22; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_SetCursor_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_SetCursor_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -26760,160 +5908,20 @@ public struct Pack8 public static implicit operator HTML_SetCursor_t ( HTML_SetCursor_t.Pack8 d ) => new HTML_SetCursor_t{ UnBrowserHandle = d.UnBrowserHandle,EMouseCursor = d.EMouseCursor, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_StatusText_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 23; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchMsg; // pchMsg const char * - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_StatusText_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_StatusText_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_StatusText_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 23; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_StatusText_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_StatusText_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -26931,160 +5939,20 @@ public struct Pack8 public static implicit operator HTML_StatusText_t ( HTML_StatusText_t.Pack8 d ) => new HTML_StatusText_t{ UnBrowserHandle = d.UnBrowserHandle,PchMsg = d.PchMsg, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_ShowToolTip_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 24; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchMsg; // pchMsg const char * - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_ShowToolTip_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_ShowToolTip_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_ShowToolTip_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 24; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_ShowToolTip_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_ShowToolTip_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -27102,160 +5970,20 @@ public struct Pack8 public static implicit operator HTML_ShowToolTip_t ( HTML_ShowToolTip_t.Pack8 d ) => new HTML_ShowToolTip_t{ UnBrowserHandle = d.UnBrowserHandle,PchMsg = d.PchMsg, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_UpdateToolTip_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 25; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal string PchMsg; // pchMsg const char * - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_UpdateToolTip_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_UpdateToolTip_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_UpdateToolTip_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 25; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_UpdateToolTip_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_UpdateToolTip_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -27273,159 +6001,19 @@ public struct Pack8 public static implicit operator HTML_UpdateToolTip_t ( HTML_UpdateToolTip_t.Pack8 d ) => new HTML_UpdateToolTip_t{ UnBrowserHandle = d.UnBrowserHandle,PchMsg = d.PchMsg, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_HideToolTip_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 26; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_HideToolTip_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_HideToolTip_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_HideToolTip_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 26; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_HideToolTip_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_HideToolTip_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -27441,160 +6029,20 @@ public struct Pack8 public static implicit operator HTML_HideToolTip_t ( HTML_HideToolTip_t.Pack8 d ) => new HTML_HideToolTip_t{ UnBrowserHandle = d.UnBrowserHandle, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct HTML_BrowserRestarted_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamHTMLSurface + 27; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint UnBrowserHandle; // unBrowserHandle HHTMLBrowser internal uint UnOldBrowserHandle; // unOldBrowserHandle HHTMLBrowser - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static HTML_BrowserRestarted_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((HTML_BrowserRestarted_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_BrowserRestarted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamHTMLSurface + 27; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((HTML_BrowserRestarted_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((HTML_BrowserRestarted_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -27612,132 +6060,7 @@ public struct Pack8 public static implicit operator HTML_BrowserRestarted_t ( HTML_BrowserRestarted_t.Pack8 d ) => new HTML_BrowserRestarted_t{ UnBrowserHandle = d.UnBrowserHandle,UnOldBrowserHandle = d.UnOldBrowserHandle, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamItemDetails_t @@ -27747,20 +6070,11 @@ public struct SteamItemDetails_t internal ushort Quantity; // m_unQuantity uint16 internal ushort Flags; // m_unFlags uint16 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamItemDetails_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamItemDetails_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamItemDetails_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public SteamItemDetails_t Fill( IntPtr p ) => Platform.PackSmall ? ((SteamItemDetails_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamItemDetails_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -27782,34 +6096,20 @@ public struct Pack8 public static implicit operator SteamItemDetails_t ( SteamItemDetails_t.Pack8 d ) => new SteamItemDetails_t{ ItemId = d.ItemId,Definition = d.Definition,Quantity = d.Quantity,Flags = d.Flags, }; } + #endregion } public struct SteamInventoryResultReady_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientInventory + 0; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal int Handle; // m_handle SteamInventoryResult_t internal Result Result; // m_result enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamInventoryResultReady_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamInventoryResultReady_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamInventoryResultReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientInventory + 0; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamInventoryResultReady_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamInventoryResultReady_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -27827,159 +6127,19 @@ public struct Pack8 public static implicit operator SteamInventoryResultReady_t ( SteamInventoryResultReady_t.Pack8 d ) => new SteamInventoryResultReady_t{ Handle = d.Handle,Result = d.Result, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamInventoryFullUpdate_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientInventory + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal int Handle; // m_handle SteamInventoryResult_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamInventoryFullUpdate_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamInventoryFullUpdate_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamInventoryFullUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientInventory + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamInventoryFullUpdate_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamInventoryFullUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -27995,163 +6155,23 @@ public struct Pack8 public static implicit operator SteamInventoryFullUpdate_t ( SteamInventoryFullUpdate_t.Pack8 d ) => new SteamInventoryFullUpdate_t{ Handle = d.Handle, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamInventoryEligiblePromoItemDefIDs_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientInventory + 3; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_result enum EResult internal ulong SteamID; // m_steamID class CSteamID internal int UmEligiblePromoItemDefs; // m_numEligiblePromoItemDefs int [MarshalAs(UnmanagedType.I1)] internal bool CachedData; // m_bCachedData _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamInventoryEligiblePromoItemDefIDs_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamInventoryEligiblePromoItemDefIDs_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamInventoryEligiblePromoItemDefIDs_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientInventory + 3; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamInventoryEligiblePromoItemDefIDs_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamInventoryEligiblePromoItemDefIDs_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -28175,166 +6195,21 @@ public struct Pack8 public static implicit operator SteamInventoryEligiblePromoItemDefIDs_t ( SteamInventoryEligiblePromoItemDefIDs_t.Pack8 d ) => new SteamInventoryEligiblePromoItemDefIDs_t{ Result = d.Result,SteamID = d.SteamID,UmEligiblePromoItemDefs = d.UmEligiblePromoItemDefs,CachedData = d.CachedData, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamInventoryStartPurchaseResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientInventory + 4; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_result enum EResult internal ulong OrderID; // m_ulOrderID uint64 internal ulong TransID; // m_ulTransID uint64 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamInventoryStartPurchaseResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamInventoryStartPurchaseResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamInventoryStartPurchaseResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientInventory + 4; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamInventoryStartPurchaseResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamInventoryStartPurchaseResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -28354,166 +6229,21 @@ public struct Pack8 public static implicit operator SteamInventoryStartPurchaseResult_t ( SteamInventoryStartPurchaseResult_t.Pack8 d ) => new SteamInventoryStartPurchaseResult_t{ Result = d.Result,OrderID = d.OrderID,TransID = d.TransID, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamInventoryRequestPricesResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientInventory + 5; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_result enum EResult [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)] internal string Currency; // m_rgchCurrency char [4] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamInventoryRequestPricesResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamInventoryRequestPricesResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamInventoryRequestPricesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientInventory + 5; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamInventoryRequestPricesResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamInventoryRequestPricesResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -28533,164 +6263,19 @@ public struct Pack8 public static implicit operator SteamInventoryRequestPricesResult_t ( SteamInventoryRequestPricesResult_t.Pack8 d ) => new SteamInventoryRequestPricesResult_t{ Result = d.Result,Currency = d.Currency, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct BroadcastUploadStop_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientVideo + 5; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal BroadcastUploadResult Result; // m_eResult enum EBroadcastUploadResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static BroadcastUploadStop_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((BroadcastUploadStop_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((BroadcastUploadStop_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientVideo + 5; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((BroadcastUploadStop_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((BroadcastUploadStop_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -28706,162 +6291,22 @@ public struct Pack8 public static implicit operator BroadcastUploadStop_t ( BroadcastUploadStop_t.Pack8 d ) => new BroadcastUploadStop_t{ Result = d.Result, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GetVideoURLResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientVideo + 11; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal uint VideoAppID; // m_unVideoAppID AppId_t [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] internal string URL; // m_rgchURL char [256] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GetVideoURLResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GetVideoURLResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GetVideoURLResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientVideo + 11; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GetVideoURLResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GetVideoURLResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -28883,160 +6328,20 @@ public struct Pack8 public static implicit operator GetVideoURLResult_t ( GetVideoURLResult_t.Pack8 d ) => new GetVideoURLResult_t{ Result = d.Result,VideoAppID = d.VideoAppID,URL = d.URL, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GetOPFSettingsResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientVideo + 24; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal uint VideoAppID; // m_unVideoAppID AppId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GetOPFSettingsResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GetOPFSettingsResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GetOPFSettingsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientVideo + 24; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GetOPFSettingsResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GetOPFSettingsResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -29054,160 +6359,20 @@ public struct Pack8 public static implicit operator GetOPFSettingsResult_t ( GetOPFSettingsResult_t.Pack8 d ) => new GetOPFSettingsResult_t{ Result = d.Result,VideoAppID = d.VideoAppID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GSClientApprove_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameServer + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamID; // m_SteamID class CSteamID internal ulong OwnerSteamID; // m_OwnerSteamID class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GSClientApprove_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GSClientApprove_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSClientApprove_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GSClientApprove_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSClientApprove_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -29225,162 +6390,22 @@ public struct Pack8 public static implicit operator GSClientApprove_t ( GSClientApprove_t.Pack8 d ) => new GSClientApprove_t{ SteamID = d.SteamID,OwnerSteamID = d.OwnerSteamID, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GSClientDeny_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameServer + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamID; // m_SteamID class CSteamID internal DenyReason DenyReason; // m_eDenyReason enum EDenyReason [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] internal string OptionalText; // m_rgchOptionalText char [128] - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GSClientDeny_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GSClientDeny_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSClientDeny_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GSClientDeny_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSClientDeny_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -29402,160 +6427,20 @@ public struct Pack8 public static implicit operator GSClientDeny_t ( GSClientDeny_t.Pack8 d ) => new GSClientDeny_t{ SteamID = d.SteamID,DenyReason = d.DenyReason,OptionalText = d.OptionalText, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GSClientKick_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameServer + 3; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamID; // m_SteamID class CSteamID internal DenyReason DenyReason; // m_eDenyReason enum EDenyReason - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GSClientKick_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GSClientKick_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSClientKick_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 3; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GSClientKick_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSClientKick_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -29573,163 +6458,23 @@ public struct Pack8 public static implicit operator GSClientKick_t ( GSClientKick_t.Pack8 d ) => new GSClientKick_t{ SteamID = d.SteamID,DenyReason = d.DenyReason, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GSClientAchievementStatus_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameServer + 6; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamID; // m_SteamID uint64 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] internal string PchAchievement; // m_pchAchievement char [128] [MarshalAs(UnmanagedType.I1)] internal bool Unlocked; // m_bUnlocked _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GSClientAchievementStatus_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GSClientAchievementStatus_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSClientAchievementStatus_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 6; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GSClientAchievementStatus_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSClientAchievementStatus_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -29753,159 +6498,19 @@ public struct Pack8 public static implicit operator GSClientAchievementStatus_t ( GSClientAchievementStatus_t.Pack8 d ) => new GSClientAchievementStatus_t{ SteamID = d.SteamID,PchAchievement = d.PchAchievement,Unlocked = d.Unlocked, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GSPolicyResponse_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 15; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal byte Secure; // m_bSecure uint8 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GSPolicyResponse_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GSPolicyResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSPolicyResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 15; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GSPolicyResponse_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSPolicyResponse_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -29921,162 +6526,22 @@ public struct Pack8 public static implicit operator GSPolicyResponse_t ( GSPolicyResponse_t.Pack8 d ) => new GSPolicyResponse_t{ Secure = d.Secure, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GSGameplayStats_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameServer + 7; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal int Rank; // m_nRank int32 internal uint TotalConnects; // m_unTotalConnects uint32 internal uint TotalMinutesPlayed; // m_unTotalMinutesPlayed uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GSGameplayStats_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GSGameplayStats_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSGameplayStats_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 7; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GSGameplayStats_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSGameplayStats_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -30098,143 +6563,11 @@ public struct Pack8 public static implicit operator GSGameplayStats_t ( GSGameplayStats_t.Pack8 d ) => new GSGameplayStats_t{ Result = d.Result,Rank = d.Rank,TotalConnects = d.TotalConnects,TotalMinutesPlayed = d.TotalMinutesPlayed, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GSClientGroupStatus_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameServer + 8; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDUser; // m_SteamIDUser class CSteamID internal ulong SteamIDGroup; // m_SteamIDGroup class CSteamID [MarshalAs(UnmanagedType.I1)] @@ -30242,20 +6575,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) [MarshalAs(UnmanagedType.I1)] internal bool Officer; // m_bOfficer _Bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GSClientGroupStatus_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GSClientGroupStatus_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSClientGroupStatus_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 8; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GSClientGroupStatus_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSClientGroupStatus_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -30281,143 +6606,11 @@ public struct Pack8 public static implicit operator GSClientGroupStatus_t ( GSClientGroupStatus_t.Pack8 d ) => new GSClientGroupStatus_t{ SteamIDUser = d.SteamIDUser,SteamIDGroup = d.SteamIDGroup,Member = d.Member,Officer = d.Officer, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GSReputation_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameServer + 9; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal uint ReputationScore; // m_unReputationScore uint32 [MarshalAs(UnmanagedType.I1)] @@ -30427,20 +6620,12 @@ public Steamworks.ISteamCallback Fill( IntPtr p, int size) internal ulong BannedGameID; // m_ulBannedGameID uint64 internal uint BanExpires; // m_unBanExpires uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GSReputation_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GSReputation_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSReputation_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 9; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GSReputation_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSReputation_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -30470,164 +6655,19 @@ public struct Pack8 public static implicit operator GSReputation_t ( GSReputation_t.Pack8 d ) => new GSReputation_t{ Result = d.Result,ReputationScore = d.ReputationScore,Banned = d.Banned,BannedIP = d.BannedIP,BannedPort = d.BannedPort,BannedGameID = d.BannedGameID,BanExpires = d.BanExpires, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct AssociateWithClanResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameServer + 10; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static AssociateWithClanResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((AssociateWithClanResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((AssociateWithClanResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 10; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((AssociateWithClanResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((AssociateWithClanResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -30643,168 +6683,23 @@ public struct Pack8 public static implicit operator AssociateWithClanResult_t ( AssociateWithClanResult_t.Pack8 d ) => new AssociateWithClanResult_t{ Result = d.Result, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct ComputeNewPlayerCompatibilityResult_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameServer + 11; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal int CPlayersThatDontLikeCandidate; // m_cPlayersThatDontLikeCandidate int internal int CPlayersThatCandidateDoesntLike; // m_cPlayersThatCandidateDoesntLike int internal int CClanPlayersThatDontLikeCandidate; // m_cClanPlayersThatDontLikeCandidate int internal ulong SteamIDCandidate; // m_SteamIDCandidate class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static ComputeNewPlayerCompatibilityResult_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((ComputeNewPlayerCompatibilityResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ComputeNewPlayerCompatibilityResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameServer + 11; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((ComputeNewPlayerCompatibilityResult_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ComputeNewPlayerCompatibilityResult_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -30828,165 +6723,20 @@ public struct Pack8 public static implicit operator ComputeNewPlayerCompatibilityResult_t ( ComputeNewPlayerCompatibilityResult_t.Pack8 d ) => new ComputeNewPlayerCompatibilityResult_t{ Result = d.Result,CPlayersThatDontLikeCandidate = d.CPlayersThatDontLikeCandidate,CPlayersThatCandidateDoesntLike = d.CPlayersThatCandidateDoesntLike,CClanPlayersThatDontLikeCandidate = d.CClanPlayersThatDontLikeCandidate,SteamIDCandidate = d.SteamIDCandidate, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GSStatsReceived_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameServerStats + 0; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong SteamIDUser; // m_steamIDUser class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GSStatsReceived_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GSStatsReceived_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSStatsReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameServerStats + 0; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GSStatsReceived_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSStatsReceived_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -31004,165 +6754,20 @@ public struct Pack8 public static implicit operator GSStatsReceived_t ( GSStatsReceived_t.Pack8 d ) => new GSStatsReceived_t{ Result = d.Result,SteamIDUser = d.SteamIDUser, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GSStatsStored_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameServerStats + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal Result Result; // m_eResult enum EResult internal ulong SteamIDUser; // m_steamIDUser class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GSStatsStored_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GSStatsStored_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSStatsStored_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameServerStats + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GSStatsStored_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSStatsStored_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -31180,164 +6785,19 @@ public struct Pack8 public static implicit operator GSStatsStored_t ( GSStatsStored_t.Pack8 d ) => new GSStatsStored_t{ Result = d.Result,SteamIDUser = d.SteamIDUser, }; } - - internal static CallResult CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action CallbackFunction ) - { - return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); - } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GSStatsUnloaded_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUserStats + 8; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal ulong SteamIDUser; // m_steamIDUser class CSteamID - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GSStatsUnloaded_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GSStatsUnloaded_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSStatsUnloaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUserStats + 8; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GSStatsUnloaded_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GSStatsUnloaded_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -31353,158 +6813,18 @@ public struct Pack8 public static implicit operator GSStatsUnloaded_t ( GSStatsUnloaded_t.Pack8 d ) => new GSStatsUnloaded_t{ SteamIDUser = d.SteamIDUser, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct NewUrlLaunchParameters_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamApps + 14; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } - - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static NewUrlLaunchParameters_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((NewUrlLaunchParameters_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((NewUrlLaunchParameters_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamApps + 14; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((NewUrlLaunchParameters_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((NewUrlLaunchParameters_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -31518,160 +6838,20 @@ public struct Pack8 public static implicit operator NewUrlLaunchParameters_t ( NewUrlLaunchParameters_t.Pack8 d ) => new NewUrlLaunchParameters_t{ }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct ItemInstalled_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientUGC + 5; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint AppID; // m_unAppID AppId_t internal ulong PublishedFileId; // m_nPublishedFileId PublishedFileId_t - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static ItemInstalled_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((ItemInstalled_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ItemInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientUGC + 5; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((ItemInstalled_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ItemInstalled_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -31689,132 +6869,7 @@ public struct Pack8 public static implicit operator ItemInstalled_t ( ItemInstalled_t.Pack8 d ) => new ItemInstalled_t{ AppID = d.AppID,PublishedFileId = d.PublishedFileId, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct InputAnalogActionData_t @@ -31825,20 +6880,11 @@ public struct InputAnalogActionData_t [MarshalAs(UnmanagedType.I1)] internal bool BActive; // bActive bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static InputAnalogActionData_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((InputAnalogActionData_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((InputAnalogActionData_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public InputAnalogActionData_t Fill( IntPtr p ) => Platform.PackSmall ? ((InputAnalogActionData_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((InputAnalogActionData_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -31862,6 +6908,7 @@ public struct Pack8 public static implicit operator InputAnalogActionData_t ( InputAnalogActionData_t.Pack8 d ) => new InputAnalogActionData_t{ EMode = d.EMode,X = d.X,Y = d.Y,BActive = d.BActive, }; } + #endregion } public struct InputMotionData_t @@ -31877,20 +6924,11 @@ public struct InputMotionData_t internal float RotVelY; // rotVelY float internal float RotVelZ; // rotVelZ float - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static InputMotionData_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((InputMotionData_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((InputMotionData_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public InputMotionData_t Fill( IntPtr p ) => Platform.PackSmall ? ((InputMotionData_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((InputMotionData_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -31924,6 +6962,7 @@ public struct Pack8 public static implicit operator InputMotionData_t ( InputMotionData_t.Pack8 d ) => new InputMotionData_t{ RotQuatX = d.RotQuatX,RotQuatY = d.RotQuatY,RotQuatZ = d.RotQuatZ,RotQuatW = d.RotQuatW,PosAccelX = d.PosAccelX,PosAccelY = d.PosAccelY,PosAccelZ = d.PosAccelZ,RotVelX = d.RotVelX,RotVelY = d.RotVelY,RotVelZ = d.RotVelZ, }; } + #endregion } public struct InputDigitalActionData_t @@ -31933,20 +6972,11 @@ public struct InputDigitalActionData_t [MarshalAs(UnmanagedType.I1)] internal bool BActive; // bActive bool - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static InputDigitalActionData_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((InputDigitalActionData_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((InputDigitalActionData_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public InputDigitalActionData_t Fill( IntPtr p ) => Platform.PackSmall ? ((InputDigitalActionData_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((InputDigitalActionData_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -31968,32 +6998,18 @@ public struct Pack8 public static implicit operator InputDigitalActionData_t ( InputDigitalActionData_t.Pack8 d ) => new InputDigitalActionData_t{ BState = d.BState,BActive = d.BActive, }; } + #endregion } public struct SteamInventoryDefinitionUpdate_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.ClientInventory + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } - - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamInventoryDefinitionUpdate_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamInventoryDefinitionUpdate_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamInventoryDefinitionUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.ClientInventory + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamInventoryDefinitionUpdate_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamInventoryDefinitionUpdate_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -32007,158 +7023,18 @@ public struct Pack8 public static implicit operator SteamInventoryDefinitionUpdate_t ( SteamInventoryDefinitionUpdate_t.Pack8 d ) => new SteamInventoryDefinitionUpdate_t{ }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamParentalSettingsChanged_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamParentalSettings + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } - - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamParentalSettingsChanged_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamParentalSettingsChanged_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamParentalSettingsChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamParentalSettings + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamParentalSettingsChanged_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamParentalSettingsChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -32172,158 +7048,18 @@ public struct Pack8 public static implicit operator SteamParentalSettingsChanged_t ( SteamParentalSettingsChanged_t.Pack8 d ) => new SteamParentalSettingsChanged_t{ }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamServersConnected_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } - - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamServersConnected_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamServersConnected_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamServersConnected_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamServersConnected_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamServersConnected_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -32337,151 +7073,17 @@ public struct Pack8 public static implicit operator SteamServersConnected_t ( SteamServersConnected_t.Pack8 d ) => new SteamServersConnected_t{ }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct NewLaunchQueryParameters_t { - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static NewLaunchQueryParameters_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((NewLaunchQueryParameters_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((NewLaunchQueryParameters_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region Marshalling + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public NewLaunchQueryParameters_t Fill( IntPtr p ) => Platform.PackSmall ? ((NewLaunchQueryParameters_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((NewLaunchQueryParameters_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -32495,33 +7097,19 @@ public struct Pack8 public static implicit operator NewLaunchQueryParameters_t ( NewLaunchQueryParameters_t.Pack8 d ) => new NewLaunchQueryParameters_t{ }; } + #endregion } public struct GCMessageAvailable_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameCoordinator + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal uint MessageSize; // m_nMessageSize uint32 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GCMessageAvailable_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GCMessageAvailable_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GCMessageAvailable_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameCoordinator + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GCMessageAvailable_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GCMessageAvailable_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -32537,158 +7125,18 @@ public struct Pack8 public static implicit operator GCMessageAvailable_t ( GCMessageAvailable_t.Pack8 d ) => new GCMessageAvailable_t{ MessageSize = d.MessageSize, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct GCMessageFailed_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamGameCoordinator + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } - - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static GCMessageFailed_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((GCMessageFailed_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GCMessageFailed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamGameCoordinator + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((GCMessageFailed_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((GCMessageFailed_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -32702,158 +7150,18 @@ public struct Pack8 public static implicit operator GCMessageFailed_t ( GCMessageFailed_t.Pack8 d ) => new GCMessageFailed_t{ }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct ScreenshotRequested_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamScreenshots + 2; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } - - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static ScreenshotRequested_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((ScreenshotRequested_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ScreenshotRequested_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamScreenshots + 2; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((ScreenshotRequested_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((ScreenshotRequested_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -32867,158 +7175,18 @@ public struct Pack8 public static implicit operator ScreenshotRequested_t ( ScreenshotRequested_t.Pack8 d ) => new ScreenshotRequested_t{ }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct LicensesUpdated_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 25; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } - - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static LicensesUpdated_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((LicensesUpdated_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LicensesUpdated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 25; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((LicensesUpdated_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((LicensesUpdated_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -33032,158 +7200,18 @@ public struct Pack8 public static implicit operator LicensesUpdated_t ( LicensesUpdated_t.Pack8 d ) => new LicensesUpdated_t{ }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct SteamShutdown_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUtils + 4; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } - - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static SteamShutdown_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((SteamShutdown_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamShutdown_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUtils + 4; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((SteamShutdown_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((SteamShutdown_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -33197,158 +7225,18 @@ public struct Pack8 public static implicit operator SteamShutdown_t ( SteamShutdown_t.Pack8 d ) => new SteamShutdown_t{ }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct IPCountry_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUtils + 1; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } - - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static IPCountry_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((IPCountry_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((IPCountry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUtils + 1; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((IPCountry_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((IPCountry_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -33362,159 +7250,19 @@ public struct Pack8 public static implicit operator IPCountry_t ( IPCountry_t.Pack8 d ) => new IPCountry_t{ }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } public struct IPCFailure_t : Steamworks.ISteamCallback { - internal const int CallbackId = CallbackIdentifiers.SteamUser + 17; - public int GetCallbackId() => CallbackId; - public int GetStructSize() => StructSize(); - public Steamworks.ISteamCallback Fill( IntPtr p, int size) - { - return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW - } internal byte FailureType; // m_eFailureType uint8 - // - // Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff. - // - internal static IPCFailure_t FromPointer( IntPtr p ) => - Platform.PackSmall ? ((IPCFailure_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((IPCFailure_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); - - // - // Get the size of the structure we're going to be using. - // - internal static int StructSize() - { - return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); - } - + #region ISteamCallback + public int GetCallbackId() => CallbackIdentifiers.SteamUser + 17; + public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) ); + public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((IPCFailure_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((IPCFailure_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) )); + #endregion + #region Packed Versions [StructLayout( LayoutKind.Sequential, Pack = 4 )] public struct Pack4 { @@ -33530,323 +7278,198 @@ public struct Pack8 public static implicit operator IPCFailure_t ( IPCFailure_t.Pack8 d ) => new IPCFailure_t{ FailureType = d.FailureType, }; } - - internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) - { - var handle = new CallbackHandle( steamworks ); - - // - // Create the functions we need for the vtable - // - if ( Facepunch.Steamworks.Config.UseThisCall ) - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWinThis ) ) ); - var vTable = new Callback.VTableWinThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableThis ) ) ); - var vTable = new Callback.VTableThis - { - ResultA = OnResultThis, - ResultB = OnResultWithInfoThis, - GetSize = OnGetSizeThis, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - else - { - // - // Create the VTable by manually allocating the memory and copying across - // - if ( Platform.IsWindows ) - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin ) ) ); - var vTable = new Callback.VTableWin - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - else - { - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable - { - ResultA = OnResult, - ResultB = OnResultWithInfo, - GetSize = OnGetSize, - }; - handle.FuncA = GCHandle.Alloc( vTable.ResultA ); - handle.FuncB = GCHandle.Alloc( vTable.ResultB ); - handle.FuncC = GCHandle.Alloc( vTable.GetSize ); - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); - } - } - - // - // Create the callback object - // - var cb = new Callback(); - cb.vTablePtr = handle.vTablePtr; - cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0; - cb.CallbackId = CallbackId; - - // - // Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native - // - handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned ); - - // - // Register the callback with Steam - // - steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId ); - - steamworks.RegisterCallbackHandle( handle ); - } - - [MonoPInvokeCallback] - internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } - [MonoPInvokeCallback] - internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } - [MonoPInvokeCallback] - internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } - [MonoPInvokeCallback] - internal static int OnGetSize(){ return StructSize(); } - - [MonoPInvokeCallback] - internal static void OnResult( IntPtr param ) - { - OnResultWithInfo( param, false, 0 ); - } - - [MonoPInvokeCallback] - internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call ) - { - if ( failure ) return; - - var value = FromPointer( param ); - - if ( Facepunch.Steamworks.Client.Instance != null ) - Facepunch.Steamworks.Client.Instance.OnCallback( value ); - - if ( Facepunch.Steamworks.Server.Instance != null ) - Facepunch.Steamworks.Server.Instance.OnCallback( value ); - } + #endregion } internal static class Callbacks { internal static void RegisterCallbacks( Facepunch.Steamworks.BaseSteamworks steamworks ) { - SteamServerConnectFailure_t.Register( steamworks ); - SteamServersDisconnected_t.Register( steamworks ); - ClientGameServerDeny_t.Register( steamworks ); - ValidateAuthTicketResponse_t.Register( steamworks ); - MicroTxnAuthorizationResponse_t.Register( steamworks ); - EncryptedAppTicketResponse_t.Register( steamworks ); - GetAuthSessionTicketResponse_t.Register( steamworks ); - GameWebCallback_t.Register( steamworks ); - StoreAuthURLResponse_t.Register( steamworks ); - MarketEligibilityResponse_t.Register( steamworks ); - PersonaStateChange_t.Register( steamworks ); - GameOverlayActivated_t.Register( steamworks ); - GameServerChangeRequested_t.Register( steamworks ); - GameLobbyJoinRequested_t.Register( steamworks ); - AvatarImageLoaded_t.Register( steamworks ); - ClanOfficerListResponse_t.Register( steamworks ); - FriendRichPresenceUpdate_t.Register( steamworks ); - GameRichPresenceJoinRequested_t.Register( steamworks ); - GameConnectedClanChatMsg_t.Register( steamworks ); - GameConnectedChatJoin_t.Register( steamworks ); - GameConnectedChatLeave_t.Register( steamworks ); - DownloadClanActivityCountsResult_t.Register( steamworks ); - JoinClanChatRoomCompletionResult_t.Register( steamworks ); - GameConnectedFriendChatMsg_t.Register( steamworks ); - FriendsGetFollowerCount_t.Register( steamworks ); - FriendsIsFollowing_t.Register( steamworks ); - FriendsEnumerateFollowingList_t.Register( steamworks ); - SetPersonaNameResponse_t.Register( steamworks ); - LowBatteryPower_t.Register( steamworks ); - SteamAPICallCompleted_t.Register( steamworks ); - CheckFileSignature_t.Register( steamworks ); - GamepadTextInputDismissed_t.Register( steamworks ); - FavoritesListChanged_t.Register( steamworks ); - LobbyInvite_t.Register( steamworks ); - LobbyEnter_t.Register( steamworks ); - LobbyDataUpdate_t.Register( steamworks ); - LobbyChatUpdate_t.Register( steamworks ); - LobbyChatMsg_t.Register( steamworks ); - LobbyGameCreated_t.Register( steamworks ); - LobbyMatchList_t.Register( steamworks ); - LobbyKicked_t.Register( steamworks ); - LobbyCreated_t.Register( steamworks ); - PSNGameBootInviteResult_t.Register( steamworks ); - FavoritesListAccountsUpdated_t.Register( steamworks ); - SearchForGameProgressCallback_t.Register( steamworks ); - SearchForGameResultCallback_t.Register( steamworks ); - RequestPlayersForGameProgressCallback_t.Register( steamworks ); - RequestPlayersForGameResultCallback_t.Register( steamworks ); - RequestPlayersForGameFinalResultCallback_t.Register( steamworks ); - SubmitPlayerResultResultCallback_t.Register( steamworks ); - EndGameResultCallback_t.Register( steamworks ); - JoinPartyCallback_t.Register( steamworks ); - CreateBeaconCallback_t.Register( steamworks ); - ReservationNotificationCallback_t.Register( steamworks ); - ChangeNumOpenSlotsCallback_t.Register( steamworks ); - RemoteStorageAppSyncedClient_t.Register( steamworks ); - RemoteStorageAppSyncedServer_t.Register( steamworks ); - RemoteStorageAppSyncProgress_t.Register( steamworks ); - RemoteStorageAppSyncStatusCheck_t.Register( steamworks ); - RemoteStorageFileShareResult_t.Register( steamworks ); - RemoteStoragePublishFileResult_t.Register( steamworks ); - RemoteStorageDeletePublishedFileResult_t.Register( steamworks ); - RemoteStorageEnumerateUserPublishedFilesResult_t.Register( steamworks ); - RemoteStorageSubscribePublishedFileResult_t.Register( steamworks ); - RemoteStorageEnumerateUserSubscribedFilesResult_t.Register( steamworks ); - RemoteStorageUnsubscribePublishedFileResult_t.Register( steamworks ); - RemoteStorageUpdatePublishedFileResult_t.Register( steamworks ); - RemoteStorageDownloadUGCResult_t.Register( steamworks ); - RemoteStorageGetPublishedFileDetailsResult_t.Register( steamworks ); - RemoteStorageEnumerateWorkshopFilesResult_t.Register( steamworks ); - RemoteStorageGetPublishedItemVoteDetailsResult_t.Register( steamworks ); - RemoteStoragePublishedFileSubscribed_t.Register( steamworks ); - RemoteStoragePublishedFileUnsubscribed_t.Register( steamworks ); - RemoteStoragePublishedFileDeleted_t.Register( steamworks ); - RemoteStorageUpdateUserPublishedItemVoteResult_t.Register( steamworks ); - RemoteStorageUserVoteDetails_t.Register( steamworks ); - RemoteStorageEnumerateUserSharedWorkshopFilesResult_t.Register( steamworks ); - RemoteStorageSetUserPublishedFileActionResult_t.Register( steamworks ); - RemoteStorageEnumeratePublishedFilesByUserActionResult_t.Register( steamworks ); - RemoteStoragePublishFileProgress_t.Register( steamworks ); - RemoteStoragePublishedFileUpdated_t.Register( steamworks ); - RemoteStorageFileWriteAsyncComplete_t.Register( steamworks ); - RemoteStorageFileReadAsyncComplete_t.Register( steamworks ); - UserStatsReceived_t.Register( steamworks ); - UserStatsStored_t.Register( steamworks ); - UserAchievementStored_t.Register( steamworks ); - LeaderboardFindResult_t.Register( steamworks ); - LeaderboardScoresDownloaded_t.Register( steamworks ); - LeaderboardScoreUploaded_t.Register( steamworks ); - NumberOfCurrentPlayers_t.Register( steamworks ); - UserStatsUnloaded_t.Register( steamworks ); - UserAchievementIconFetched_t.Register( steamworks ); - GlobalAchievementPercentagesReady_t.Register( steamworks ); - LeaderboardUGCSet_t.Register( steamworks ); - PS3TrophiesInstalled_t.Register( steamworks ); - GlobalStatsReceived_t.Register( steamworks ); - DlcInstalled_t.Register( steamworks ); - RegisterActivationCodeResponse_t.Register( steamworks ); - AppProofOfPurchaseKeyResponse_t.Register( steamworks ); - FileDetailsResult_t.Register( steamworks ); - P2PSessionRequest_t.Register( steamworks ); - P2PSessionConnectFail_t.Register( steamworks ); - SocketStatusCallback_t.Register( steamworks ); - ScreenshotReady_t.Register( steamworks ); - VolumeHasChanged_t.Register( steamworks ); - MusicPlayerWantsShuffled_t.Register( steamworks ); - MusicPlayerWantsLooped_t.Register( steamworks ); - MusicPlayerWantsVolume_t.Register( steamworks ); - MusicPlayerSelectsQueueEntry_t.Register( steamworks ); - MusicPlayerSelectsPlaylistEntry_t.Register( steamworks ); - MusicPlayerWantsPlayingRepeatStatus_t.Register( steamworks ); - HTTPRequestCompleted_t.Register( steamworks ); - HTTPRequestHeadersReceived_t.Register( steamworks ); - HTTPRequestDataReceived_t.Register( steamworks ); - SteamUGCQueryCompleted_t.Register( steamworks ); - SteamUGCRequestUGCDetailsResult_t.Register( steamworks ); - CreateItemResult_t.Register( steamworks ); - SubmitItemUpdateResult_t.Register( steamworks ); - DownloadItemResult_t.Register( steamworks ); - UserFavoriteItemsListChanged_t.Register( steamworks ); - SetUserItemVoteResult_t.Register( steamworks ); - GetUserItemVoteResult_t.Register( steamworks ); - StartPlaytimeTrackingResult_t.Register( steamworks ); - StopPlaytimeTrackingResult_t.Register( steamworks ); - AddUGCDependencyResult_t.Register( steamworks ); - RemoveUGCDependencyResult_t.Register( steamworks ); - AddAppDependencyResult_t.Register( steamworks ); - RemoveAppDependencyResult_t.Register( steamworks ); - GetAppDependenciesResult_t.Register( steamworks ); - DeleteItemResult_t.Register( steamworks ); - SteamAppInstalled_t.Register( steamworks ); - SteamAppUninstalled_t.Register( steamworks ); - HTML_BrowserReady_t.Register( steamworks ); - HTML_URLChanged_t.Register( steamworks ); - HTML_FinishedRequest_t.Register( steamworks ); - HTML_OpenLinkInNewTab_t.Register( steamworks ); - HTML_ChangedTitle_t.Register( steamworks ); - HTML_SearchResults_t.Register( steamworks ); - HTML_CanGoBackAndForward_t.Register( steamworks ); - HTML_HorizontalScroll_t.Register( steamworks ); - HTML_VerticalScroll_t.Register( steamworks ); - HTML_LinkAtPosition_t.Register( steamworks ); - HTML_JSAlert_t.Register( steamworks ); - HTML_JSConfirm_t.Register( steamworks ); - HTML_FileOpenDialog_t.Register( steamworks ); - HTML_NewWindow_t.Register( steamworks ); - HTML_SetCursor_t.Register( steamworks ); - HTML_StatusText_t.Register( steamworks ); - HTML_ShowToolTip_t.Register( steamworks ); - HTML_UpdateToolTip_t.Register( steamworks ); - HTML_HideToolTip_t.Register( steamworks ); - HTML_BrowserRestarted_t.Register( steamworks ); - SteamInventoryResultReady_t.Register( steamworks ); - SteamInventoryFullUpdate_t.Register( steamworks ); - SteamInventoryEligiblePromoItemDefIDs_t.Register( steamworks ); - SteamInventoryStartPurchaseResult_t.Register( steamworks ); - SteamInventoryRequestPricesResult_t.Register( steamworks ); - BroadcastUploadStop_t.Register( steamworks ); - GetVideoURLResult_t.Register( steamworks ); - GetOPFSettingsResult_t.Register( steamworks ); - GSClientApprove_t.Register( steamworks ); - GSClientDeny_t.Register( steamworks ); - GSClientKick_t.Register( steamworks ); - GSClientAchievementStatus_t.Register( steamworks ); - GSPolicyResponse_t.Register( steamworks ); - GSGameplayStats_t.Register( steamworks ); - GSClientGroupStatus_t.Register( steamworks ); - GSReputation_t.Register( steamworks ); - AssociateWithClanResult_t.Register( steamworks ); - ComputeNewPlayerCompatibilityResult_t.Register( steamworks ); - GSStatsReceived_t.Register( steamworks ); - GSStatsStored_t.Register( steamworks ); - GSStatsUnloaded_t.Register( steamworks ); - NewUrlLaunchParameters_t.Register( steamworks ); - ItemInstalled_t.Register( steamworks ); - SteamInventoryDefinitionUpdate_t.Register( steamworks ); - SteamParentalSettingsChanged_t.Register( steamworks ); - SteamServersConnected_t.Register( steamworks ); - GCMessageAvailable_t.Register( steamworks ); - GCMessageFailed_t.Register( steamworks ); - ScreenshotRequested_t.Register( steamworks ); - LicensesUpdated_t.Register( steamworks ); - SteamShutdown_t.Register( steamworks ); - IPCountry_t.Register( steamworks ); - IPCFailure_t.Register( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); + new CallbackHandle( steamworks ); } } } diff --git a/Generator/CodeWriter/Class.cs b/Generator/CodeWriter/Class.cs index ce9908f..3c35483 100644 --- a/Generator/CodeWriter/Class.cs +++ b/Generator/CodeWriter/Class.cs @@ -175,14 +175,14 @@ private void Detect_CallResult( List argList, List callargs BeforeLines.Insert( 0, "SteamAPICall_t callback = 0;" ); ReturnVar = "callback"; - ReturnType = $"CallbackHandle"; + ReturnType = $"CallResult<{MethodDef.CallResult}>"; AfterLines.Add( "" ); AfterLines.Add( "if ( CallbackFunction == null ) return null;" ); AfterLines.Add("if ( callback == 0 ) return null;"); AfterLines.Add( "" ); - AfterLines.Add( $"return {MethodDef.CallResult}.CallResult( steamworks, callback, CallbackFunction );" ); + AfterLines.Add( $"return new CallResult<{MethodDef.CallResult}>( steamworks, callback, CallbackFunction );" ); } private void Detect_StringArray( List argList, List callargs ) @@ -303,7 +303,7 @@ private void Detect_ReturningStruct() BeforeLines.Add( "IntPtr struct_pointer;" ); AfterLines.Add( $"if ( struct_pointer == IntPtr.Zero ) return default({ReturnType});" ); - AfterLines.Add( $"return {ReturnType}.FromPointer( struct_pointer );" ); + AfterLines.Add( $"return new {ReturnType}().Fill( struct_pointer );" ); } diff --git a/Generator/CodeWriter/Struct.cs b/Generator/CodeWriter/Struct.cs index fdc61a5..6f50add 100644 --- a/Generator/CodeWriter/Struct.cs +++ b/Generator/CodeWriter/Struct.cs @@ -60,110 +60,95 @@ void Structs() // StartBlock( $"public struct {c.Name}{(isCallback?" : Steamworks.ISteamCallback":"")}" ); { - if ( isCallback ) - { - WriteLine( "internal const int CallbackId = " + c.CallbackId + ";" ); - WriteLine( "public int GetCallbackId() => CallbackId;" ); - WriteLine( "public int GetStructSize() => StructSize();" ); + // + // The fields + // + StructFields( c.Fields ); + WriteLine(); - StartBlock( "public Steamworks.ISteamCallback Fill( IntPtr p, int size)" ); + if ( isCallback ) + { + WriteLine( "#region ISteamCallback" ); { - WriteLine( "return FromPointer( p ); // TODO - USE SIZE HERE SOMEHOW" ); + WriteLine( $"public int GetCallbackId() => {c.CallbackId};" ); + WriteLine( $"public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) );" ); + WriteLine( $"public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? (({c.Name})(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : (({c.Name})(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) ));" ); + } + WriteLine( "#endregion" ); + } + else + { + WriteLine( "#region Marshalling" ); + { + WriteLine( $"public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) );" ); + WriteLine( $"public {c.Name} Fill( IntPtr p ) => Platform.PackSmall ? (({c.Name})(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : (({c.Name})(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) ));" ); + } + WriteLine( "#endregion" ); + } + + WriteLine( "#region Packed Versions" ); + { + // + // Small packed struct (for osx, linux) + // + + WriteLine( $"[StructLayout( LayoutKind.Sequential, Pack = 4 )]" ); + StartBlock( $"public struct Pack4" ); + { + StructFields( c.Fields ); + + // + // Implicit convert from PackSmall to regular + // + WriteLine(); + Write( $"public static implicit operator {c.Name} ( {c.Name}.Pack4 d ) => " ); + { + Write( $"new {c.Name}{{ " ); + { + foreach ( var f in c.Fields ) + { + Write( $"{CleanMemberName( f.Name )} = d.{CleanMemberName( f.Name )}," ); + } + } + WriteLine( " };" ); + } + } EndBlock(); - } - - // - // The fields - // - StructFields( c.Fields ); - - WriteLine(); - WriteLine( "//" ); - WriteLine( "// Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff." ); - WriteLine( "//" ); - WriteLine( $"internal static {c.Name} FromPointer( IntPtr p ) => " ); - { - WriteLine( $" Platform.PackSmall ? (({c.Name})(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : (({c.Name})(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) ));" ); - } - - WriteLine(); - WriteLine( "//" ); - WriteLine( "// Get the size of the structure we're going to be using." ); - WriteLine( "//" ); - StartBlock( $"internal static int StructSize()" ); - { - WriteLine( $"return System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) );" ); - } - EndBlock(); - - // if ( defaultPack == 8 ) - // defaultPack = 4; - - // - // Small packed struct (for osx, linux) - // - WriteLine(); - WriteLine( $"[StructLayout( LayoutKind.Sequential, Pack = 4 )]" ); - StartBlock( $"public struct Pack4" ); - { - StructFields( c.Fields ); - - // - // Implicit convert from PackSmall to regular - // - WriteLine(); - Write( $"public static implicit operator {c.Name} ( {c.Name}.Pack4 d ) => " ); - { - Write( $"new {c.Name}{{ " ); - { - foreach ( var f in c.Fields ) - { - Write( $"{CleanMemberName( f.Name )} = d.{CleanMemberName( f.Name )}," ); - } - } - WriteLine( " };" ); - } - - } - EndBlock(); - - // - // Small packed struct (for osx, linux) - // - WriteLine(); - WriteLine( $"[StructLayout( LayoutKind.Sequential, Pack = {defaultPack} )]" ); - StartBlock( $"public struct Pack8" ); - { - StructFields( c.Fields ); // - // Implicit convert from PackSmall to regular + // Small packed struct (for osx, linux) // WriteLine(); - Write( $"public static implicit operator {c.Name} ( {c.Name}.Pack8 d ) => " ); + WriteLine( $"[StructLayout( LayoutKind.Sequential, Pack = {defaultPack} )]" ); + StartBlock( $"public struct Pack8" ); { - Write( $"new {c.Name}{{ " ); + StructFields( c.Fields ); + + // + // Implicit convert from PackSmall to regular + // + WriteLine(); + Write( $"public static implicit operator {c.Name} ( {c.Name}.Pack8 d ) => " ); { - foreach ( var f in c.Fields ) + Write( $"new {c.Name}{{ " ); { - Write( $"{CleanMemberName( f.Name )} = d.{CleanMemberName( f.Name )}," ); + foreach ( var f in c.Fields ) + { + Write( $"{CleanMemberName( f.Name )} = d.{CleanMemberName( f.Name )}," ); + } } + WriteLine( " };" ); } - WriteLine( " };" ); + } + EndBlock(); } - EndBlock(); - - if ( c.IsCallResult ) - { - CallResult( c ); - } + WriteLine( "#endregion" ); if ( !string.IsNullOrEmpty( c.CallbackId ) ) { - Callback( c ); callbackList.Add( c ); } @@ -177,7 +162,7 @@ void Structs() { foreach ( var c in callbackList ) { - WriteLine( $"{c.Name}.Register( steamworks );" ); + WriteLine( $"new CallbackHandle<{c.Name}>( steamworks );" ); } } EndBlock(); @@ -257,154 +242,5 @@ private void StructFields( SteamApiDefinition.StructDef.StructFields[] fields ) WriteLine( $"internal {t} {CleanMemberName( m.Name )}; // {m.Name} {m.Type}" ); } } - - private void Callback( SteamApiDefinition.StructDef c ) - { - WriteLine(); - StartBlock( $"internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks )" ); - { - WriteLine( $"var handle = new CallbackHandle( steamworks );" ); - WriteLine( $"" ); - - CallbackCall( c ); - - WriteLine( "" ); - WriteLine( "//" ); - WriteLine( "// Register the callback with Steam" ); - WriteLine( "//" ); - WriteLine( $"steamworks.native.api.SteamAPI_RegisterCallback( handle.PinnedCallback.AddrOfPinnedObject(), CallbackId );" ); - - WriteLine(); - WriteLine( "steamworks.RegisterCallbackHandle( handle );" ); - } - EndBlock(); - - WriteLine(); - WriteLine( "[MonoPInvokeCallback]" ); - WriteLine( "internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); }" ); - WriteLine( "[MonoPInvokeCallback]" ); - WriteLine( "internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); }" ); - WriteLine( "[MonoPInvokeCallback]" ); - WriteLine( "internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); }" ); - WriteLine( "[MonoPInvokeCallback]" ); - WriteLine( "internal static int OnGetSize(){ return StructSize(); }" ); - - WriteLine(); - WriteLine( "[MonoPInvokeCallback]" ); - StartBlock( "internal static void OnResult( IntPtr param )" ); - { - WriteLine( $"OnResultWithInfo( param, false, 0 );" ); - } - EndBlock(); - - WriteLine(); - WriteLine( "[MonoPInvokeCallback]" ); - StartBlock( "internal static void OnResultWithInfo( IntPtr param, bool failure, SteamNative.SteamAPICall_t call )" ); - { - WriteLine( $"if ( failure ) return;" ); - WriteLine(); - WriteLine( "var value = FromPointer( param );" ); - - WriteLine(); - WriteLine( "if ( Facepunch.Steamworks.Client.Instance != null )" ); - WriteLine( $" Facepunch.Steamworks.Client.Instance.OnCallback<{c.Name}>( value );" ); - - WriteLine(); - WriteLine( "if ( Facepunch.Steamworks.Server.Instance != null )" ); - WriteLine( $" Facepunch.Steamworks.Server.Instance.OnCallback<{c.Name}>( value );" ); - } - EndBlock(); - } - - - private void CallResult( SteamApiDefinition.StructDef c ) - { - WriteLine(); - StartBlock( $"internal static CallResult<{c.Name}> CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action<{c.Name}, bool> CallbackFunction )" ); - { - WriteLine( $"return new CallResult<{c.Name}>( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId );" ); - } - EndBlock(); - } - - - private void CallbackCall( SteamApiDefinition.StructDef c ) - { - WriteLine( "//" ); - WriteLine( "// Create the functions we need for the vtable" ); - WriteLine( "//" ); - - StartBlock( "if ( Facepunch.Steamworks.Config.UseThisCall )" ); - { - CallFunctions( c, "ThisCall", "_" ); - } - Else(); - { - CallFunctions( c, "StdCall", "" ); - } - EndBlock(); - - WriteLine( "" ); - WriteLine( "//" ); - WriteLine( "// Create the callback object" ); - WriteLine( "//" ); - WriteLine( $"var cb = new Callback();" ); - WriteLine( $"cb.vTablePtr = handle.vTablePtr;" ); - WriteLine( $"cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0;" ); - WriteLine( $"cb.CallbackId = CallbackId;" ); - - WriteLine( "" ); - WriteLine( "//" ); - WriteLine( "// Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native" ); - WriteLine( "//" ); - WriteLine( $"handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned );" ); - } - - private void CallFunctions( SteamApiDefinition.StructDef c, string ThisCall, string ThisArg ) - { - var ThisArgC = ThisArg.Length > 0 ? $"{ThisArg}, " : ""; - var This = ThisArg.Length > 0 ? "This" : ""; - - WriteLine( "//" ); - WriteLine( "// Create the VTable by manually allocating the memory and copying across" ); - WriteLine( "//" ); - StartBlock( "if ( Platform.IsWindows )" ); - { - WriteLine( $"handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTableWin{This} ) ) );" ); - StartBlock( $"var vTable = new Callback.VTableWin{This}" ); - { - WriteLine( $"ResultA = OnResult{This}," ); - WriteLine( $"ResultB = OnResultWithInfo{This}," ); - WriteLine( $"GetSize = OnGetSize{This}," ); - } - EndBlock( ";" ); - - WriteLine( "handle.FuncA = GCHandle.Alloc( vTable.ResultA );" ); - WriteLine( "handle.FuncB = GCHandle.Alloc( vTable.ResultB );" ); - WriteLine( "handle.FuncC = GCHandle.Alloc( vTable.GetSize );" ); - - WriteLine( "Marshal.StructureToPtr( vTable, handle.vTablePtr, false );" ); - } - Else(); - { - WriteLine( $"handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable{This} ) ) );" ); - StartBlock( $"var vTable = new Callback.VTable{This}" ); - { - WriteLine( $"ResultA = OnResult{This}," ); - WriteLine( $"ResultB = OnResultWithInfo{This}," ); - WriteLine( $"GetSize = OnGetSize{This}," ); - } - EndBlock( ";" ); - - WriteLine( "handle.FuncA = GCHandle.Alloc( vTable.ResultA );" ); - WriteLine( "handle.FuncB = GCHandle.Alloc( vTable.ResultB );" ); - WriteLine( "handle.FuncC = GCHandle.Alloc( vTable.GetSize );" ); - - WriteLine( "Marshal.StructureToPtr( vTable, handle.vTablePtr, false );" ); - } - EndBlock(); - - - } } }