diff --git a/Facepunch.Steamworks/BaseSteamworks.cs b/Facepunch.Steamworks/BaseSteamworks.cs index 49652ab..036432d 100644 --- a/Facepunch.Steamworks/BaseSteamworks.cs +++ b/Facepunch.Steamworks/BaseSteamworks.cs @@ -41,6 +41,8 @@ protected BaseSteamworks( uint appId ) public virtual void Dispose() { + Callbacks.Clear(); + foreach ( var h in CallbackHandles ) { h.Dispose(); @@ -157,5 +159,37 @@ public void UpdateWhile( Func func ) #endif } } + + Dictionary>> Callbacks = new Dictionary>>(); + + internal List> CallbackList( Type T ) + { + List> list = null; + + if ( !Callbacks.TryGetValue( T, out list ) ) + { + list = new List>(); + Callbacks[T] = list; + } + + return list; + } + + internal void OnCallback( T data ) + { + var list = CallbackList( typeof( T ) ); + + foreach ( var i in list ) + { + i( data ); + } + } + + internal void RegisterCallback( Action func ) + { + var list = CallbackList( typeof( T ) ); + list.Add( ( o ) => func( (T) o ) ); + } + } } \ No newline at end of file diff --git a/Facepunch.Steamworks/Client.cs b/Facepunch.Steamworks/Client.cs index af65c20..d4c7ee0 100644 --- a/Facepunch.Steamworks/Client.cs +++ b/Facepunch.Steamworks/Client.cs @@ -89,6 +89,12 @@ public Client( uint appId ) : base( appId ) // SetupCommonInterfaces(); + // + // Register Callbacks + // + + SteamNative.Callbacks.RegisterCallbacks( this ); + // // Client only interfaces // @@ -121,8 +127,6 @@ public Client( uint appId ) : base( appId ) CurrentLanguage = native.apps.GetCurrentGameLanguage(); AvailableLanguages = native.apps.GetAvailableGameLanguages().Split( new[] {';'}, StringSplitOptions.RemoveEmptyEntries ); // TODO: Assumed colon separated - - // // Run update, first call does some initialization // diff --git a/Facepunch.Steamworks/Client/Achievements.cs b/Facepunch.Steamworks/Client/Achievements.cs index ba152cf..40abfc5 100644 --- a/Facepunch.Steamworks/Client/Achievements.cs +++ b/Facepunch.Steamworks/Client/Achievements.cs @@ -22,8 +22,8 @@ internal Achievements( Client c ) client = c; All = new Achievement[0]; - SteamNative.UserStatsReceived_t.RegisterCallback( c, UserStatsReceived ); - SteamNative.UserStatsStored_t.RegisterCallback( c, UserStatsStored ); + c.RegisterCallback( UserStatsReceived ); + c.RegisterCallback( UserStatsStored ); Refresh(); } @@ -100,9 +100,8 @@ public bool Reset( string identifier ) return client.native.userstats.ClearAchievement( identifier ); } - private void UserStatsReceived( UserStatsReceived_t stats, bool isError ) + private void UserStatsReceived( UserStatsReceived_t stats ) { - if ( isError ) return; if ( stats.GameID != client.AppId ) return; Refresh(); @@ -110,9 +109,8 @@ private void UserStatsReceived( UserStatsReceived_t stats, bool isError ) OnUpdated?.Invoke(); } - private void UserStatsStored( UserStatsStored_t stats, bool isError ) + private void UserStatsStored( UserStatsStored_t stats ) { - if ( isError ) return; if ( stats.GameID != client.AppId ) return; Refresh(); diff --git a/Facepunch.Steamworks/Client/Friends.cs b/Facepunch.Steamworks/Client/Friends.cs index 36cd95d..0aea558 100644 --- a/Facepunch.Steamworks/Client/Friends.cs +++ b/Facepunch.Steamworks/Client/Friends.cs @@ -163,7 +163,7 @@ internal Friends( Client c ) { client = c; - SteamNative.PersonaStateChange_t.RegisterCallback( client, OnPersonaStateChange ); + client.RegisterCallback( OnPersonaStateChange ); } /// @@ -357,9 +357,9 @@ public SteamFriend Get( ulong steamid ) return f; } - private void OnPersonaStateChange( PersonaStateChange_t data, bool error ) + private void OnPersonaStateChange( PersonaStateChange_t data ) { - + // HUH } } diff --git a/Facepunch.Steamworks/Client/Lobby.cs b/Facepunch.Steamworks/Client/Lobby.cs index 510b4df..1d013a4 100644 --- a/Facepunch.Steamworks/Client/Lobby.cs +++ b/Facepunch.Steamworks/Client/Lobby.cs @@ -36,12 +36,13 @@ public enum Type : int public Lobby( Client c ) { client = c; - SteamNative.LobbyDataUpdate_t.RegisterCallback( client, OnLobbyDataUpdatedAPI ); - SteamNative.LobbyChatMsg_t.RegisterCallback( client, OnLobbyChatMessageRecievedAPI ); - SteamNative.LobbyChatUpdate_t.RegisterCallback( client, OnLobbyStateUpdatedAPI ); - SteamNative.GameLobbyJoinRequested_t.RegisterCallback( client, OnLobbyJoinRequestedAPI ); - SteamNative.LobbyInvite_t.RegisterCallback( client, OnUserInvitedToLobbyAPI ); - SteamNative.PersonaStateChange_t.RegisterCallback( client, OnLobbyMemberPersonaChangeAPI ); + + client.RegisterCallback( OnLobbyDataUpdatedAPI ); + client.RegisterCallback( OnLobbyChatMessageRecievedAPI ); + client.RegisterCallback( OnLobbyStateUpdatedAPI ); + client.RegisterCallback( OnLobbyJoinRequestedAPI ); + client.RegisterCallback( OnUserInvitedToLobbyAPI ); + client.RegisterCallback( OnLobbyMemberPersonaChangeAPI ); } /// @@ -242,9 +243,10 @@ public string GetMemberData( ulong steamID, string key ) return client.native.matchmaking.GetLobbyMemberData( CurrentLobby, steamID, key ); } - internal void OnLobbyDataUpdatedAPI( LobbyDataUpdate_t callback, bool error ) + internal void OnLobbyDataUpdatedAPI( LobbyDataUpdate_t callback ) { - if ( error || (callback.SteamIDLobby != CurrentLobby) ) { return; } + if ( callback.SteamIDLobby != CurrentLobby ) return; + if ( callback.SteamIDLobby == CurrentLobby ) //actual lobby data was updated by owner { UpdateLobbyData(); @@ -320,10 +322,10 @@ public Type LobbyType private static byte[] chatMessageData = new byte[1024 * 4]; - private unsafe void OnLobbyChatMessageRecievedAPI( LobbyChatMsg_t callback, bool error ) + private unsafe void OnLobbyChatMessageRecievedAPI( LobbyChatMsg_t callback ) { //from Client.Networking - if ( error || callback.SteamIDLobby != CurrentLobby ) + if ( callback.SteamIDLobby != CurrentLobby ) return; SteamNative.CSteamID steamid = 1; @@ -380,9 +382,9 @@ public enum MemberStateChange Banned = ChatMemberStateChange.Banned, } - internal void OnLobbyStateUpdatedAPI( LobbyChatUpdate_t callback, bool error ) + internal void OnLobbyStateUpdatedAPI( LobbyChatUpdate_t callback ) { - if ( error || callback.SteamIDLobby != CurrentLobby ) + if ( callback.SteamIDLobby != CurrentLobby ) return; MemberStateChange change = (MemberStateChange)callback.GfChatMemberStateChange; @@ -555,9 +557,9 @@ public bool InviteUserToLobby( ulong friendID ) return client.native.matchmaking.InviteUserToLobby( CurrentLobby, friendID ); } - internal void OnUserInvitedToLobbyAPI( LobbyInvite_t callback, bool error ) + internal void OnUserInvitedToLobbyAPI( LobbyInvite_t callback ) { - if ( error || (callback.GameID != client.AppId) ) { return; } + if ( callback.GameID != client.AppId ) return; if ( OnUserInvitedToLobby != null ) { OnUserInvitedToLobby( callback.SteamIDLobby, callback.SteamIDUser ); } } @@ -570,18 +572,17 @@ internal void OnUserInvitedToLobbyAPI( LobbyInvite_t callback, bool error ) /// /// Joins a lobby if a request was made to join the lobby through the friends list or an invite /// - internal void OnLobbyJoinRequestedAPI( GameLobbyJoinRequested_t callback, bool error ) + internal void OnLobbyJoinRequestedAPI( GameLobbyJoinRequested_t callback ) { - if ( error ) { return; } Join( callback.SteamIDLobby ); } /// /// Makes sure we send an update callback if a Lobby user updates their information /// - internal void OnLobbyMemberPersonaChangeAPI( PersonaStateChange_t callback, bool error ) + internal void OnLobbyMemberPersonaChangeAPI( PersonaStateChange_t callback ) { - if ( error || !UserIsInCurrentLobby( callback.SteamID ) ) { return; } + if ( !UserIsInCurrentLobby( callback.SteamID ) ) return; if ( OnLobbyMemberDataUpdated != null ) { OnLobbyMemberDataUpdated( callback.SteamID ); } } diff --git a/Facepunch.Steamworks/Client/LobbyList.cs b/Facepunch.Steamworks/Client/LobbyList.cs index 905695d..a8ed9a2 100644 --- a/Facepunch.Steamworks/Client/LobbyList.cs +++ b/Facepunch.Steamworks/Client/LobbyList.cs @@ -101,7 +101,7 @@ void OnLobbyList(LobbyMatchList_t callback, bool error) { //else we need to get the info for the missing lobby client.native.matchmaking.RequestLobbyData(lobby); - SteamNative.LobbyDataUpdate_t.RegisterCallback(client, OnLobbyDataUpdated); + client.RegisterCallback( OnLobbyDataUpdated ); } } @@ -121,7 +121,7 @@ void checkFinished() Finished = false; } - void OnLobbyDataUpdated(LobbyDataUpdate_t callback, bool error) + void OnLobbyDataUpdated(LobbyDataUpdate_t callback) { if (callback.Success == 1) //1 if success, 0 if failure { diff --git a/Facepunch.Steamworks/Client/MicroTransactions.cs b/Facepunch.Steamworks/Client/MicroTransactions.cs index 6c7af88..240b35b 100644 --- a/Facepunch.Steamworks/Client/MicroTransactions.cs +++ b/Facepunch.Steamworks/Client/MicroTransactions.cs @@ -23,10 +23,10 @@ internal MicroTransactions( Client c ) { client = c; - SteamNative.MicroTxnAuthorizationResponse_t.RegisterCallback( client, onMicroTxnAuthorizationResponse ); + client.RegisterCallback( onMicroTxnAuthorizationResponse ); } - private void onMicroTxnAuthorizationResponse( MicroTxnAuthorizationResponse_t arg1, bool arg2 ) + private void onMicroTxnAuthorizationResponse( MicroTxnAuthorizationResponse_t arg1 ) { if ( OnAuthorizationResponse != null ) { diff --git a/Facepunch.Steamworks/Config.cs b/Facepunch.Steamworks/Config.cs index 6ac0dee..3d79a4e 100644 --- a/Facepunch.Steamworks/Config.cs +++ b/Facepunch.Steamworks/Config.cs @@ -18,11 +18,6 @@ public static void ForUnity( string platform ) // if ( platform == "WindowsEditor" || platform == "WindowsPlayer" ) { - // - // 32bit windows unity uses a stdcall - // - if ( IntPtr.Size == 4 ) UseThisCall = false; - ForcePlatform( OperatingSystem.Windows, IntPtr.Size == 4 ? Architecture.x86 : Architecture.x64 ); } @@ -36,6 +31,8 @@ public static void ForUnity( string platform ) ForcePlatform( OperatingSystem.Linux, IntPtr.Size == 4 ? Architecture.x86 : Architecture.x64 ); } + IsUnity = true; + Console.WriteLine( "Facepunch.Steamworks Unity: " + platform ); Console.WriteLine( "Facepunch.Steamworks Os: " + SteamNative.Platform.Os ); Console.WriteLine( "Facepunch.Steamworks Arch: " + SteamNative.Platform.Arch ); @@ -50,7 +47,13 @@ public static void ForUnity( string platform ) /// for releasing his shit open source under the MIT license so we can all learn and iterate. /// /// - public static bool UseThisCall { get; set; } = true; + internal static bool UseThisCall { get { return SteamNative.Platform.Os == OperatingSystem.Windows && !IsUnity; } } + + + /// + /// Should be true if we're using Unity + /// + internal static bool IsUnity { get; set; } /// diff --git a/Facepunch.Steamworks/Facepunch.Steamworks.csproj b/Facepunch.Steamworks/Facepunch.Steamworks.csproj index a910c47..2750edb 100644 --- a/Facepunch.Steamworks/Facepunch.Steamworks.csproj +++ b/Facepunch.Steamworks/Facepunch.Steamworks.csproj @@ -26,7 +26,7 @@ - + @@ -36,5 +36,10 @@ C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client + + + full + true + diff --git a/Facepunch.Steamworks/Interfaces/Inventory.Result.cs b/Facepunch.Steamworks/Interfaces/Inventory.Result.cs index 1c80b94..b09befd 100644 --- a/Facepunch.Steamworks/Interfaces/Inventory.Result.cs +++ b/Facepunch.Steamworks/Interfaces/Inventory.Result.cs @@ -139,9 +139,9 @@ internal void Fill() } } - internal void OnSteamResult( SteamInventoryResultReady_t data, bool error ) + internal void OnSteamResult( SteamInventoryResultReady_t data ) { - var success = data.Result == SteamNative.Result.OK && !error; + var success = data.Result == SteamNative.Result.OK; if ( success ) { diff --git a/Facepunch.Steamworks/Interfaces/Inventory.cs b/Facepunch.Steamworks/Interfaces/Inventory.cs index 97b6837..1f1dbe3 100644 --- a/Facepunch.Steamworks/Interfaces/Inventory.cs +++ b/Facepunch.Steamworks/Interfaces/Inventory.cs @@ -54,8 +54,8 @@ internal Inventory( BaseSteamworks steamworks, SteamNative.SteamInventory c, boo if ( !server ) { - SteamNative.SteamInventoryResultReady_t.RegisterCallback( steamworks, onResultReady ); - SteamNative.SteamInventoryFullUpdate_t.RegisterCallback( steamworks, onFullUpdate ); + steamworks.RegisterCallback( onResultReady ); + steamworks.RegisterCallback( onFullUpdate ); // // Get a list of our items immediately @@ -67,10 +67,8 @@ internal Inventory( BaseSteamworks steamworks, SteamNative.SteamInventory c, boo /// /// We've received a FULL update /// - private void onFullUpdate( SteamInventoryFullUpdate_t data, bool error ) + private void onFullUpdate( SteamInventoryFullUpdate_t data ) { - if ( error ) return; - var result = new Result( this, data.Handle, false ); result.Fill(); @@ -80,15 +78,15 @@ private void onFullUpdate( SteamInventoryFullUpdate_t data, bool error ) /// /// A generic result has returned. /// - private void onResultReady( SteamInventoryResultReady_t data, bool error ) + private void onResultReady( SteamInventoryResultReady_t data ) { if ( Result.Pending.ContainsKey( data.Handle ) ) { var result = Result.Pending[data.Handle]; - result.OnSteamResult( data, error ); + result.OnSteamResult( data ); - if ( !error && data.Result == SteamNative.Result.OK ) + if ( data.Result == SteamNative.Result.OK ) { onResult( result, false ); } diff --git a/Facepunch.Steamworks/Interfaces/Networking.cs b/Facepunch.Steamworks/Interfaces/Networking.cs index 8d3b0c4..f48fefd 100644 --- a/Facepunch.Steamworks/Interfaces/Networking.cs +++ b/Facepunch.Steamworks/Interfaces/Networking.cs @@ -26,8 +26,8 @@ internal Networking( BaseSteamworks steamworks, SteamNative.SteamNetworking netw { this.networking = networking; - SteamNative.P2PSessionRequest_t.RegisterCallback( steamworks, onP2PConnectionRequest ); - SteamNative.P2PSessionConnectFail_t.RegisterCallback( steamworks, onP2PConnectionFailed ); + steamworks.RegisterCallback( onP2PConnectionRequest ); + steamworks.RegisterCallback( onP2PConnectionFailed ); } public void Dispose() @@ -80,7 +80,7 @@ public void SetListenChannel( int ChannelId, bool Listen ) } } - private void onP2PConnectionRequest( SteamNative.P2PSessionRequest_t o, bool b ) + private void onP2PConnectionRequest( SteamNative.P2PSessionRequest_t o ) { if ( OnIncomingConnection != null ) { @@ -116,7 +116,7 @@ public enum SessionError : byte Max = 5 }; - private void onP2PConnectionFailed( SteamNative.P2PSessionConnectFail_t o, bool b ) + private void onP2PConnectionFailed( SteamNative.P2PSessionConnectFail_t o ) { if ( OnConnectionFailed != null ) { diff --git a/Facepunch.Steamworks/Interfaces/Workshop.cs b/Facepunch.Steamworks/Interfaces/Workshop.cs index c32713a..64ae67e 100644 --- a/Facepunch.Steamworks/Interfaces/Workshop.cs +++ b/Facepunch.Steamworks/Interfaces/Workshop.cs @@ -46,8 +46,8 @@ internal Workshop( BaseSteamworks steamworks, SteamNative.SteamUGC ugc, SteamNat this.steamworks = steamworks; this.remoteStorage = remoteStorage; - SteamNative.DownloadItemResult_t.RegisterCallback( steamworks, onDownloadResult ); - SteamNative.ItemInstalled_t.RegisterCallback( steamworks, onItemInstalled ); + steamworks.RegisterCallback( onDownloadResult ); + steamworks.RegisterCallback( onItemInstalled ); } /// @@ -64,13 +64,13 @@ public void Dispose() OnItemInstalled = null; } - private void onItemInstalled( SteamNative.ItemInstalled_t obj, bool failed ) + private void onItemInstalled( SteamNative.ItemInstalled_t obj ) { if ( OnItemInstalled != null && obj.AppID == Client.Instance.AppId ) OnItemInstalled( obj.PublishedFileId ); } - private void onDownloadResult( SteamNative.DownloadItemResult_t obj, bool failed ) + private void onDownloadResult( SteamNative.DownloadItemResult_t obj ) { if ( OnFileDownloaded != null && obj.AppID == Client.Instance.AppId ) OnFileDownloaded( obj.PublishedFileId, (Callbacks.Result) obj.Result ); diff --git a/Facepunch.Steamworks/Server.cs b/Facepunch.Steamworks/Server.cs index 900a983..f4947ee 100644 --- a/Facepunch.Steamworks/Server.cs +++ b/Facepunch.Steamworks/Server.cs @@ -53,9 +53,10 @@ public Server( uint appId, ServerInit init) : base( appId ) SetupCommonInterfaces(); // - // Cache common, unchanging info + // Register Callbacks // - AppId = appId; + + SteamNative.Callbacks.RegisterCallbacks( this ); // // Initial settings diff --git a/Facepunch.Steamworks/Server/Auth.cs b/Facepunch.Steamworks/Server/Auth.cs index 24ded75..f94cddc 100644 --- a/Facepunch.Steamworks/Server/Auth.cs +++ b/Facepunch.Steamworks/Server/Auth.cs @@ -35,10 +35,10 @@ internal ServerAuth( Server s ) { server = s; - SteamNative.ValidateAuthTicketResponse_t.RegisterCallback( server, OnAuthTicketValidate ); + server.RegisterCallback( OnAuthTicketValidate ); } - void OnAuthTicketValidate( SteamNative.ValidateAuthTicketResponse_t data, bool b ) + void OnAuthTicketValidate( SteamNative.ValidateAuthTicketResponse_t data ) { if ( OnAuthChange != null ) OnAuthChange( data.SteamID, data.OwnerSteamID, (Status) data.AuthSessionResponse ); diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.Callback.cs b/Facepunch.Steamworks/SteamNative/SteamNative.Callback.cs index ede1d4f..fd0f384 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.Callback.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.Callback.cs @@ -20,29 +20,50 @@ internal enum Flags : byte [StructLayout( LayoutKind.Sequential, Pack = 1 )] public class VTable { - public IntPtr ResultA; - public IntPtr ResultB; - public IntPtr GetSize; + [UnmanagedFunctionPointer( CallingConvention.StdCall )] public delegate void ResultD( IntPtr pvParam ); + [UnmanagedFunctionPointer( CallingConvention.StdCall )] public delegate void ResultWithInfoD( IntPtr pvParam, bool bIOFailure, SteamNative.SteamAPICall_t hSteamAPICall ); + [UnmanagedFunctionPointer( CallingConvention.StdCall )] public delegate int GetSizeD(); + + public ResultD ResultA; + public ResultWithInfoD ResultB; + public GetSizeD GetSize; } - // - // All possible functions - // - internal class ThisCall + [StructLayout( LayoutKind.Sequential, Pack = 1 )] + public class VTableWin { - [UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate void Result( IntPtr thisptr, IntPtr pvParam ); - [UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate void ResultWithInfo( IntPtr thisptr, IntPtr pvParam, bool bIOFailure, SteamNative.SteamAPICall_t hSteamAPICall ); - [UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate int GetSize( IntPtr thisptr ); + [UnmanagedFunctionPointer( CallingConvention.StdCall )] public delegate void ResultD( IntPtr pvParam ); + [UnmanagedFunctionPointer( CallingConvention.StdCall )] public delegate void ResultWithInfoD( IntPtr pvParam, bool bIOFailure, SteamNative.SteamAPICall_t hSteamAPICall ); + [UnmanagedFunctionPointer( CallingConvention.StdCall )] public delegate int GetSizeD(); + + public ResultWithInfoD ResultB; + public ResultD ResultA; + public GetSizeD GetSize; } - internal class StdCall + [StructLayout( LayoutKind.Sequential, Pack = 1 )] + public class VTableThis { - [UnmanagedFunctionPointer( CallingConvention.StdCall )] public delegate void Result( IntPtr pvParam ); - [UnmanagedFunctionPointer( CallingConvention.StdCall )] public delegate void ResultWithInfo( IntPtr pvParam, bool bIOFailure, SteamNative.SteamAPICall_t hSteamAPICall ); - [UnmanagedFunctionPointer( CallingConvention.StdCall )] public delegate int GetSize(); + [UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate void ResultD( IntPtr thisptr, IntPtr pvParam ); + [UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate void ResultWithInfoD( IntPtr thisptr, IntPtr pvParam, bool bIOFailure, SteamNative.SteamAPICall_t hSteamAPICall ); + [UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate int GetSizeD( IntPtr thisptr ); + + public ResultD ResultA; + public ResultWithInfoD ResultB; + public GetSizeD GetSize; } + [StructLayout( LayoutKind.Sequential, Pack = 1 )] + public class VTableWinThis + { + [UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate void ResultD( IntPtr thisptr, IntPtr pvParam ); + [UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate void ResultWithInfoD( IntPtr thisptr, IntPtr pvParam, bool bIOFailure, SteamNative.SteamAPICall_t hSteamAPICall ); + [UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate int GetSizeD( IntPtr thisptr ); + public ResultWithInfoD ResultB; + public ResultD ResultA; + public GetSizeD GetSize; + } }; // @@ -169,4 +190,9 @@ unsafe internal override void RunCallback() } } } + + internal class MonoPInvokeCallbackAttribute : Attribute + { + public MonoPInvokeCallbackAttribute( Type t ) { } + } } diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.Structs.cs b/Facepunch.Steamworks/SteamNative/SteamNative.Structs.cs index be5603c..a118b90 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.Structs.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.Structs.cs @@ -100,7 +100,7 @@ public static implicit operator SteamServerConnectFailure_t ( SteamServerConnec } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -109,85 +109,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SteamServerConnectFailure_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SteamServerConnectFailure_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -210,6 +196,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -253,7 +268,7 @@ public static implicit operator SteamServersDisconnected_t ( SteamServersDiscon } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -262,85 +277,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SteamServersDisconnected_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SteamServersDisconnected_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -363,6 +364,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -418,7 +448,7 @@ public static implicit operator ClientGameServerDeny_t ( ClientGameServerDeny_t } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -427,85 +457,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( ClientGameServerDeny_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( ClientGameServerDeny_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -528,6 +544,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -577,7 +622,7 @@ public static implicit operator ValidateAuthTicketResponse_t ( ValidateAuthTick } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -586,85 +631,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( ValidateAuthTicketResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( ValidateAuthTicketResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -687,6 +718,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -736,7 +796,7 @@ public static implicit operator MicroTxnAuthorizationResponse_t ( MicroTxnAutho } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -745,85 +805,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( MicroTxnAuthorizationResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( MicroTxnAuthorizationResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -846,6 +892,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -894,7 +969,7 @@ internal static CallResult CallResult( Facepunch.S return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -903,85 +978,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( EncryptedAppTicketResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( EncryptedAppTicketResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -1004,6 +1065,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -1050,7 +1140,7 @@ public static implicit operator GetAuthSessionTicketResponse_t ( GetAuthSession } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -1059,85 +1149,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GetAuthSessionTicketResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GetAuthSessionTicketResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -1160,6 +1236,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -1205,7 +1310,7 @@ public static implicit operator GameWebCallback_t ( GameWebCallback_t.PackSmall } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -1214,85 +1319,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GameWebCallback_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GameWebCallback_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -1315,6 +1406,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -1365,7 +1485,7 @@ internal static CallResult CallResult( Facepunch.Steamwo return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -1374,85 +1494,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( StoreAuthURLResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( StoreAuthURLResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -1475,6 +1581,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -1618,7 +1753,7 @@ public static implicit operator PersonaStateChange_t ( PersonaStateChange_t.Pac } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -1627,85 +1762,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( PersonaStateChange_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( PersonaStateChange_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -1728,6 +1849,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -1771,7 +1921,7 @@ public static implicit operator GameOverlayActivated_t ( GameOverlayActivated_t } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -1780,85 +1930,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GameOverlayActivated_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GameOverlayActivated_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -1881,6 +2017,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -1931,7 +2096,7 @@ public static implicit operator GameServerChangeRequested_t ( GameServerChangeR } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -1940,85 +2105,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GameServerChangeRequested_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GameServerChangeRequested_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -2041,6 +2192,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -2087,7 +2267,7 @@ public static implicit operator GameLobbyJoinRequested_t ( GameLobbyJoinRequest } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -2096,85 +2276,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GameLobbyJoinRequested_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GameLobbyJoinRequested_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -2197,6 +2363,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -2249,7 +2444,7 @@ public static implicit operator AvatarImageLoaded_t ( AvatarImageLoaded_t.PackS } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -2258,85 +2453,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( AvatarImageLoaded_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( AvatarImageLoaded_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -2359,6 +2540,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -2413,7 +2623,7 @@ internal static CallResult CallResult( Facepunch.Stea return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -2422,85 +2632,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( ClanOfficerListResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( ClanOfficerListResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -2523,6 +2719,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -2569,7 +2794,7 @@ public static implicit operator FriendRichPresenceUpdate_t ( FriendRichPresence } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -2578,85 +2803,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( FriendRichPresenceUpdate_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( FriendRichPresenceUpdate_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -2679,6 +2890,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -2727,7 +2967,7 @@ public static implicit operator GameRichPresenceJoinRequested_t ( GameRichPrese } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -2736,85 +2976,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GameRichPresenceJoinRequested_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GameRichPresenceJoinRequested_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -2837,6 +3063,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -2886,7 +3141,7 @@ public static implicit operator GameConnectedClanChatMsg_t ( GameConnectedClanC } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -2895,85 +3150,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GameConnectedClanChatMsg_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GameConnectedClanChatMsg_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -2996,6 +3237,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -3042,7 +3312,7 @@ public static implicit operator GameConnectedChatJoin_t ( GameConnectedChatJoin } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -3051,85 +3321,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GameConnectedChatJoin_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GameConnectedChatJoin_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -3152,6 +3408,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -3208,7 +3493,7 @@ public static implicit operator GameConnectedChatLeave_t ( GameConnectedChatLea } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -3217,85 +3502,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GameConnectedChatLeave_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GameConnectedChatLeave_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -3318,6 +3589,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -3363,7 +3663,7 @@ public static implicit operator DownloadClanActivityCountsResult_t ( DownloadCl } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -3372,85 +3672,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( DownloadClanActivityCountsResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( DownloadClanActivityCountsResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -3473,6 +3759,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -3524,7 +3839,7 @@ internal static CallResult CallResult( Facep return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -3533,85 +3848,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( JoinClanChatRoomCompletionResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( JoinClanChatRoomCompletionResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -3634,6 +3935,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -3680,7 +4010,7 @@ public static implicit operator GameConnectedFriendChatMsg_t ( GameConnectedFri } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -3689,85 +4019,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GameConnectedFriendChatMsg_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GameConnectedFriendChatMsg_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -3790,6 +4106,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -3844,7 +4189,7 @@ internal static CallResult CallResult( Facepunch.Stea return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -3853,85 +4198,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( FriendsGetFollowerCount_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( FriendsGetFollowerCount_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -3954,6 +4285,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -4010,7 +4370,7 @@ internal static CallResult CallResult( Facepunch.Steamwork return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -4019,85 +4379,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( FriendsIsFollowing_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( FriendsIsFollowing_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -4120,6 +4466,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -4179,7 +4554,7 @@ internal static CallResult CallResult( Facepunc return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -4188,85 +4563,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( FriendsEnumerateFollowingList_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( FriendsEnumerateFollowingList_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -4289,6 +4650,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -4347,7 +4737,7 @@ internal static CallResult CallResult( Facepunch.Steam return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -4356,85 +4746,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SetPersonaNameResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SetPersonaNameResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -4457,6 +4833,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -4500,7 +4905,7 @@ public static implicit operator LowBatteryPower_t ( LowBatteryPower_t.PackSmall } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -4509,85 +4914,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LowBatteryPower_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LowBatteryPower_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -4610,6 +5001,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -4659,7 +5079,7 @@ public static implicit operator SteamAPICallCompleted_t ( SteamAPICallCompleted } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -4668,85 +5088,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SteamAPICallCompleted_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SteamAPICallCompleted_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -4769,6 +5175,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -4817,7 +5252,7 @@ internal static CallResult CallResult( Facepunch.Steamwork return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -4826,85 +5261,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( CheckFileSignature_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( CheckFileSignature_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -4927,6 +5348,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -4975,7 +5425,7 @@ public static implicit operator GamepadTextInputDismissed_t ( GamepadTextInputD } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -4984,85 +5434,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GamepadTextInputDismissed_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GamepadTextInputDismissed_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -5085,6 +5521,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -5353,7 +5818,7 @@ public static implicit operator FavoritesListChanged_t ( FavoritesListChanged_t } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -5362,85 +5827,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( FavoritesListChanged_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( FavoritesListChanged_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -5463,6 +5914,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -5512,7 +5992,7 @@ public static implicit operator LobbyInvite_t ( LobbyInvite_t.PackSmall d ) } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -5521,85 +6001,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LobbyInvite_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LobbyInvite_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -5622,6 +6088,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -5681,7 +6176,7 @@ internal static CallResult CallResult( Facepunch.Steamworks.BaseSt return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -5690,85 +6185,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LobbyEnter_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LobbyEnter_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -5791,6 +6272,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -5840,7 +6350,7 @@ public static implicit operator LobbyDataUpdate_t ( LobbyDataUpdate_t.PackSmall } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -5849,85 +6359,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LobbyDataUpdate_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LobbyDataUpdate_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -5950,6 +6446,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -6002,7 +6527,7 @@ public static implicit operator LobbyChatUpdate_t ( LobbyChatUpdate_t.PackSmall } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -6011,85 +6536,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LobbyChatUpdate_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LobbyChatUpdate_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -6112,6 +6623,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -6164,7 +6704,7 @@ public static implicit operator LobbyChatMsg_t ( LobbyChatMsg_t.PackSmall d ) } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -6173,85 +6713,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LobbyChatMsg_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LobbyChatMsg_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -6274,6 +6800,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -6326,7 +6881,7 @@ public static implicit operator LobbyGameCreated_t ( LobbyGameCreated_t.PackSma } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -6335,85 +6890,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LobbyGameCreated_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LobbyGameCreated_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -6436,6 +6977,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -6484,7 +7054,7 @@ internal static CallResult CallResult( Facepunch.Steamworks.Ba return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -6493,85 +7063,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LobbyMatchList_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LobbyMatchList_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -6594,6 +7150,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -6643,7 +7228,7 @@ public static implicit operator LobbyKicked_t ( LobbyKicked_t.PackSmall d ) } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -6652,85 +7237,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LobbyKicked_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LobbyKicked_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -6753,6 +7324,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -6804,7 +7404,7 @@ internal static CallResult CallResult( Facepunch.Steamworks.Base return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -6813,85 +7413,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LobbyCreated_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LobbyCreated_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -6914,6 +7500,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -6962,7 +7577,7 @@ public static implicit operator PSNGameBootInviteResult_t ( PSNGameBootInviteRe } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -6971,85 +7586,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( PSNGameBootInviteResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( PSNGameBootInviteResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -7072,6 +7673,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -7115,7 +7745,7 @@ public static implicit operator FavoritesListAccountsUpdated_t ( FavoritesListA } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -7124,85 +7754,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( FavoritesListAccountsUpdated_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( FavoritesListAccountsUpdated_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -7225,6 +7841,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -7318,7 +7963,7 @@ public static implicit operator RemoteStorageAppSyncedClient_t ( RemoteStorageA } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -7327,85 +7972,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageAppSyncedClient_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageAppSyncedClient_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -7428,6 +8059,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -7477,7 +8137,7 @@ public static implicit operator RemoteStorageAppSyncedServer_t ( RemoteStorageA } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -7486,85 +8146,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageAppSyncedServer_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageAppSyncedServer_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -7587,6 +8233,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -7646,7 +8321,7 @@ public static implicit operator RemoteStorageAppSyncProgress_t ( RemoteStorageA } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -7655,85 +8330,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageAppSyncProgress_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageAppSyncProgress_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -7756,6 +8417,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -7802,7 +8492,7 @@ public static implicit operator RemoteStorageAppSyncStatusCheck_t ( RemoteStora } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -7811,85 +8501,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageAppSyncStatusCheck_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageAppSyncStatusCheck_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -7912,6 +8588,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -7968,7 +8673,7 @@ internal static CallResult CallResult( Facepunch return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -7977,85 +8682,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageFileShareResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageFileShareResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -8078,6 +8769,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -8129,7 +8849,7 @@ public static implicit operator RemoteStoragePublishFileResult_t ( RemoteStorag } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -8138,85 +8858,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStoragePublishFileResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStoragePublishFileResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -8239,6 +8945,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -8290,7 +9025,7 @@ internal static CallResult CallResult( return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -8299,85 +9034,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageDeletePublishedFileResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageDeletePublishedFileResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -8400,6 +9121,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -8459,7 +9209,7 @@ internal static CallResult Cal return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -8468,85 +9218,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageEnumerateUserPublishedFilesResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageEnumerateUserPublishedFilesResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -8569,6 +9305,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -8620,7 +9385,7 @@ internal static CallResult CallResu return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -8629,85 +9394,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageSubscribePublishedFileResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageSubscribePublishedFileResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -8730,6 +9481,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -8794,7 +9574,7 @@ internal static CallResult Ca return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -8803,85 +9583,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageEnumerateUserSubscribedFilesResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageEnumerateUserSubscribedFilesResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -8904,6 +9670,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -8955,7 +9750,7 @@ internal static CallResult CallRe return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -8964,85 +9759,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageUnsubscribePublishedFileResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageUnsubscribePublishedFileResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -9065,6 +9846,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -9121,7 +9931,7 @@ internal static CallResult CallResult( return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -9130,85 +9940,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageUpdatePublishedFileResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageUpdatePublishedFileResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -9231,6 +10027,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -9296,7 +10121,7 @@ internal static CallResult CallResult( Facepun return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -9305,85 +10130,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageDownloadUGCResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageDownloadUGCResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -9406,6 +10217,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -9530,7 +10370,7 @@ internal static CallResult CallRes return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -9539,85 +10379,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageGetPublishedFileDetailsResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageGetPublishedFileDetailsResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -9640,6 +10466,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -9710,7 +10565,7 @@ internal static CallResult CallResu return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -9719,85 +10574,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageEnumerateWorkshopFilesResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageEnumerateWorkshopFilesResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -9820,6 +10661,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -9883,7 +10753,7 @@ internal static CallResult Cal return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -9892,85 +10762,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageGetPublishedItemVoteDetailsResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageGetPublishedItemVoteDetailsResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -9993,6 +10849,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -10039,7 +10924,7 @@ public static implicit operator RemoteStoragePublishedFileSubscribed_t ( Remote } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -10048,85 +10933,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStoragePublishedFileSubscribed_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStoragePublishedFileSubscribed_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -10149,6 +11020,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -10195,7 +11095,7 @@ public static implicit operator RemoteStoragePublishedFileUnsubscribed_t ( Remo } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -10204,85 +11104,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStoragePublishedFileUnsubscribed_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStoragePublishedFileUnsubscribed_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -10305,6 +11191,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -10351,7 +11266,7 @@ public static implicit operator RemoteStoragePublishedFileDeleted_t ( RemoteSto } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -10360,85 +11275,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStoragePublishedFileDeleted_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStoragePublishedFileDeleted_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -10461,6 +11362,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -10512,7 +11442,7 @@ internal static CallResult Cal return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -10521,85 +11451,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageUpdateUserPublishedItemVoteResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageUpdateUserPublishedItemVoteResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -10622,6 +11538,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -10671,7 +11616,7 @@ public static implicit operator RemoteStorageUserVoteDetails_t ( RemoteStorageU } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -10680,85 +11625,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageUserVoteDetails_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageUserVoteDetails_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -10781,6 +11712,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -10835,7 +11795,7 @@ public static implicit operator RemoteStorageEnumerateUserSharedWorkshopFilesRes } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -10844,85 +11804,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageEnumerateUserSharedWorkshopFilesResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageEnumerateUserSharedWorkshopFilesResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -10945,6 +11891,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -10999,7 +11974,7 @@ internal static CallResult Call return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -11008,85 +11983,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageSetUserPublishedFileActionResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageSetUserPublishedFileActionResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -11109,6 +12070,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -11176,7 +12166,7 @@ internal static CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -11185,85 +12175,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageEnumeratePublishedFilesByUserActionResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageEnumeratePublishedFilesByUserActionResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -11286,6 +12262,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -11339,7 +12344,7 @@ internal static CallResult CallResult( Facep return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -11348,85 +12353,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStoragePublishFileProgress_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStoragePublishFileProgress_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -11449,6 +12440,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -11498,7 +12518,7 @@ public static implicit operator RemoteStoragePublishedFileUpdated_t ( RemoteSto } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -11507,85 +12527,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStoragePublishedFileUpdated_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStoragePublishedFileUpdated_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -11608,6 +12614,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -11656,7 +12691,7 @@ internal static CallResult CallResult( Fa return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -11665,85 +12700,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageFileWriteAsyncComplete_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageFileWriteAsyncComplete_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -11766,6 +12787,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -11823,7 +12873,7 @@ internal static CallResult CallResult( Fac return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -11832,85 +12882,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoteStorageFileReadAsyncComplete_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoteStorageFileReadAsyncComplete_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -11933,6 +12969,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -12040,7 +13105,7 @@ internal static CallResult CallResult( Facepunch.Steamworks return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -12049,85 +13114,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( UserStatsReceived_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( UserStatsReceived_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -12150,6 +13201,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -12196,7 +13276,7 @@ public static implicit operator UserStatsStored_t ( UserStatsStored_t.PackSmall } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -12205,85 +13285,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( UserStatsStored_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( UserStatsStored_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -12306,6 +13372,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -12365,7 +13460,7 @@ public static implicit operator UserAchievementStored_t ( UserAchievementStored } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -12374,85 +13469,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( UserAchievementStored_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( UserAchievementStored_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -12475,6 +13556,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -12526,7 +13636,7 @@ internal static CallResult CallResult( Facepunch.Steamw return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -12535,85 +13645,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LeaderboardFindResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LeaderboardFindResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -12636,6 +13732,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -12690,7 +13815,7 @@ internal static CallResult CallResult( Facepunch. return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -12699,85 +13824,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LeaderboardScoresDownloaded_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LeaderboardScoresDownloaded_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -12800,6 +13911,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -12863,7 +14003,7 @@ internal static CallResult CallResult( Facepunch.Ste return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -12872,85 +14012,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LeaderboardScoreUploaded_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LeaderboardScoreUploaded_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -12973,6 +14099,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -13024,7 +14179,7 @@ internal static CallResult CallResult( Facepunch.Steam return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -13033,85 +14188,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( NumberOfCurrentPlayers_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( NumberOfCurrentPlayers_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -13134,6 +14275,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -13177,7 +14347,7 @@ public static implicit operator UserStatsUnloaded_t ( UserStatsUnloaded_t.PackS } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -13186,85 +14356,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( UserStatsUnloaded_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( UserStatsUnloaded_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -13287,6 +14443,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -13343,7 +14528,7 @@ public static implicit operator UserAchievementIconFetched_t ( UserAchievementI } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -13352,85 +14537,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( UserAchievementIconFetched_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( UserAchievementIconFetched_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -13453,6 +14624,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -13504,7 +14704,7 @@ internal static CallResult CallResult( Face return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -13513,85 +14713,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GlobalAchievementPercentagesReady_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GlobalAchievementPercentagesReady_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -13614,6 +14800,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -13665,7 +14880,7 @@ internal static CallResult CallResult( Facepunch.Steamworks return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -13674,85 +14889,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( LeaderboardUGCSet_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( LeaderboardUGCSet_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -13775,6 +14976,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -13824,7 +15054,7 @@ public static implicit operator PS3TrophiesInstalled_t ( PS3TrophiesInstalled_t } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -13833,85 +15063,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( PS3TrophiesInstalled_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( PS3TrophiesInstalled_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -13934,6 +15150,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -13985,7 +15230,7 @@ internal static CallResult CallResult( Facepunch.Steamwor return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -13994,85 +15239,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GlobalStatsReceived_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GlobalStatsReceived_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -14095,6 +15326,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -14138,7 +15398,7 @@ public static implicit operator DlcInstalled_t ( DlcInstalled_t.PackSmall d ) } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -14147,85 +15407,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( DlcInstalled_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( DlcInstalled_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -14248,6 +15494,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -14294,7 +15569,7 @@ public static implicit operator RegisterActivationCodeResponse_t ( RegisterActi } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -14303,85 +15578,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RegisterActivationCodeResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RegisterActivationCodeResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -14404,6 +15665,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -14458,7 +15748,7 @@ public static implicit operator AppProofOfPurchaseKeyResponse_t ( AppProofOfPur } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -14467,85 +15757,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( AppProofOfPurchaseKeyResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( AppProofOfPurchaseKeyResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -14568,6 +15844,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -14627,7 +15932,7 @@ internal static CallResult CallResult( Facepunch.Steamworks return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -14636,85 +15941,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( FileDetailsResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( FileDetailsResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -14737,6 +16028,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -14842,7 +16162,7 @@ public static implicit operator P2PSessionRequest_t ( P2PSessionRequest_t.PackS } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -14851,85 +16171,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( P2PSessionRequest_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( P2PSessionRequest_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -14952,6 +16258,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -14998,7 +16333,7 @@ public static implicit operator P2PSessionConnectFail_t ( P2PSessionConnectFail } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -15007,85 +16342,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( P2PSessionConnectFail_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( P2PSessionConnectFail_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -15108,6 +16429,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -15160,7 +16510,7 @@ public static implicit operator SocketStatusCallback_t ( SocketStatusCallback_t } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -15169,85 +16519,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SocketStatusCallback_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SocketStatusCallback_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -15270,6 +16606,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -15316,7 +16681,7 @@ public static implicit operator ScreenshotReady_t ( ScreenshotReady_t.PackSmall } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -15325,85 +16690,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( ScreenshotReady_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( ScreenshotReady_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -15426,6 +16777,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -15469,7 +16849,7 @@ public static implicit operator VolumeHasChanged_t ( VolumeHasChanged_t.PackSma } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -15478,85 +16858,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( VolumeHasChanged_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( VolumeHasChanged_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -15579,6 +16945,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -15624,7 +17019,7 @@ public static implicit operator MusicPlayerWantsShuffled_t ( MusicPlayerWantsSh } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -15633,85 +17028,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( MusicPlayerWantsShuffled_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( MusicPlayerWantsShuffled_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -15734,6 +17115,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -15779,7 +17189,7 @@ public static implicit operator MusicPlayerWantsLooped_t ( MusicPlayerWantsLoop } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -15788,85 +17198,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( MusicPlayerWantsLooped_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( MusicPlayerWantsLooped_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -15889,6 +17285,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -15932,7 +17357,7 @@ public static implicit operator MusicPlayerWantsVolume_t ( MusicPlayerWantsVolu } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -15941,85 +17366,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( MusicPlayerWantsVolume_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( MusicPlayerWantsVolume_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -16042,6 +17453,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -16085,7 +17525,7 @@ public static implicit operator MusicPlayerSelectsQueueEntry_t ( MusicPlayerSel } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -16094,85 +17534,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( MusicPlayerSelectsQueueEntry_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( MusicPlayerSelectsQueueEntry_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -16195,6 +17621,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -16238,7 +17693,7 @@ public static implicit operator MusicPlayerSelectsPlaylistEntry_t ( MusicPlayer } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -16247,85 +17702,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( MusicPlayerSelectsPlaylistEntry_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( MusicPlayerSelectsPlaylistEntry_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -16348,6 +17789,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -16391,7 +17861,7 @@ public static implicit operator MusicPlayerWantsPlayingRepeatStatus_t ( MusicPl } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -16400,85 +17870,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( MusicPlayerWantsPlayingRepeatStatus_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( MusicPlayerWantsPlayingRepeatStatus_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -16501,6 +17957,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -16558,7 +18043,7 @@ public static implicit operator HTTPRequestCompleted_t ( HTTPRequestCompleted_t } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -16567,85 +18052,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTTPRequestCompleted_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTTPRequestCompleted_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -16668,6 +18139,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -16714,7 +18214,7 @@ public static implicit operator HTTPRequestHeadersReceived_t ( HTTPRequestHeade } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -16723,85 +18223,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTTPRequestHeadersReceived_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTTPRequestHeadersReceived_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -16824,6 +18310,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -16876,7 +18391,7 @@ public static implicit operator HTTPRequestDataReceived_t ( HTTPRequestDataRece } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -16885,85 +18400,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTTPRequestDataReceived_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTTPRequestDataReceived_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -16986,6 +18487,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -17348,7 +18878,7 @@ internal static CallResult CallResult( Facepunch.Steam return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -17357,85 +18887,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SteamUGCQueryCompleted_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SteamUGCQueryCompleted_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -17458,6 +18974,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -17506,7 +19051,7 @@ public static implicit operator SteamUGCRequestUGCDetailsResult_t ( SteamUGCReq } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -17515,85 +19060,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SteamUGCRequestUGCDetailsResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SteamUGCRequestUGCDetailsResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -17616,6 +19147,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -17672,7 +19232,7 @@ internal static CallResult CallResult( Facepunch.Steamworks. return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -17681,85 +19241,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( CreateItemResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( CreateItemResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -17782,6 +19328,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -17838,7 +19413,7 @@ internal static CallResult CallResult( Facepunch.Steam return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -17847,85 +19422,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SubmitItemUpdateResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SubmitItemUpdateResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -17948,6 +19509,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -17997,7 +19587,7 @@ public static implicit operator DownloadItemResult_t ( DownloadItemResult_t.Pac } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -18006,85 +19596,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( DownloadItemResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( DownloadItemResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -18107,6 +19683,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -18163,7 +19768,7 @@ internal static CallResult CallResult( Facepunch return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -18172,85 +19777,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( UserFavoriteItemsListChanged_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( UserFavoriteItemsListChanged_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -18273,6 +19864,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -18329,7 +19949,7 @@ internal static CallResult CallResult( Facepunch.Steamw return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -18338,85 +19958,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SetUserItemVoteResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SetUserItemVoteResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -18439,6 +20045,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -18505,7 +20140,7 @@ internal static CallResult CallResult( Facepunch.Steamw return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -18514,85 +20149,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GetUserItemVoteResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GetUserItemVoteResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -18615,6 +20236,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -18663,7 +20313,7 @@ internal static CallResult CallResult( Facepunch. return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -18672,85 +20322,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( StartPlaytimeTrackingResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( StartPlaytimeTrackingResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -18773,6 +20409,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -18821,7 +20486,7 @@ internal static CallResult CallResult( Facepunch.S return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -18830,85 +20495,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( StopPlaytimeTrackingResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( StopPlaytimeTrackingResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -18931,6 +20582,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -18985,7 +20665,7 @@ internal static CallResult CallResult( Facepunch.Steam return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -18994,85 +20674,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( AddUGCDependencyResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( AddUGCDependencyResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -19095,6 +20761,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -19149,7 +20844,7 @@ internal static CallResult CallResult( Facepunch.St return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -19158,85 +20853,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoveUGCDependencyResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoveUGCDependencyResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -19259,6 +20940,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -19313,7 +21023,7 @@ internal static CallResult CallResult( Facepunch.Steam return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -19322,85 +21032,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( AddAppDependencyResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( AddAppDependencyResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -19423,6 +21119,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -19477,7 +21202,7 @@ internal static CallResult CallResult( Facepunch.St return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -19486,85 +21211,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( RemoveAppDependencyResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( RemoveAppDependencyResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -19587,6 +21298,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -19649,7 +21389,7 @@ internal static CallResult CallResult( Facepunch.Ste return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -19658,85 +21398,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GetAppDependenciesResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GetAppDependenciesResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -19759,6 +21485,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -19810,7 +21565,7 @@ internal static CallResult CallResult( Facepunch.Steamworks. return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -19819,85 +21574,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( DeleteItemResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( DeleteItemResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -19920,6 +21661,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -19963,7 +21733,7 @@ public static implicit operator SteamAppInstalled_t ( SteamAppInstalled_t.PackS } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -19972,85 +21742,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SteamAppInstalled_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SteamAppInstalled_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -20073,6 +21829,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -20116,7 +21901,7 @@ public static implicit operator SteamAppUninstalled_t ( SteamAppUninstalled_t.P } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -20125,85 +21910,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SteamAppUninstalled_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SteamAppUninstalled_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -20226,6 +21997,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -20274,7 +22074,7 @@ internal static CallResult CallResult( Facepunch.Steamworks return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -20283,85 +22083,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_BrowserReady_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_BrowserReady_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -20384,6 +22170,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -20616,7 +22431,7 @@ public static implicit operator HTML_URLChanged_t ( HTML_URLChanged_t.PackSmall } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -20625,85 +22440,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_URLChanged_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_URLChanged_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -20726,6 +22527,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -20775,7 +22605,7 @@ public static implicit operator HTML_FinishedRequest_t ( HTML_FinishedRequest_t } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -20784,85 +22614,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_FinishedRequest_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_FinishedRequest_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -20885,6 +22701,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -20931,7 +22776,7 @@ public static implicit operator HTML_OpenLinkInNewTab_t ( HTML_OpenLinkInNewTab } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -20940,85 +22785,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_OpenLinkInNewTab_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_OpenLinkInNewTab_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -21041,6 +22872,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -21087,7 +22947,7 @@ public static implicit operator HTML_ChangedTitle_t ( HTML_ChangedTitle_t.PackS } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -21096,85 +22956,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_ChangedTitle_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_ChangedTitle_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -21197,6 +23043,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -21246,7 +23121,7 @@ public static implicit operator HTML_SearchResults_t ( HTML_SearchResults_t.Pac } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -21255,85 +23130,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_SearchResults_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_SearchResults_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -21356,6 +23217,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -21409,7 +23299,7 @@ public static implicit operator HTML_CanGoBackAndForward_t ( HTML_CanGoBackAndF } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -21418,85 +23308,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_CanGoBackAndForward_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_CanGoBackAndForward_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -21519,6 +23395,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -21579,7 +23484,7 @@ public static implicit operator HTML_HorizontalScroll_t ( HTML_HorizontalScroll } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -21588,85 +23493,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_HorizontalScroll_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_HorizontalScroll_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -21689,6 +23580,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -21749,7 +23669,7 @@ public static implicit operator HTML_VerticalScroll_t ( HTML_VerticalScroll_t.P } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -21758,85 +23678,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_VerticalScroll_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_VerticalScroll_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -21859,6 +23765,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -21921,7 +23856,7 @@ public static implicit operator HTML_LinkAtPosition_t ( HTML_LinkAtPosition_t.P } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -21930,85 +23865,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_LinkAtPosition_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_LinkAtPosition_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -22031,6 +23952,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -22077,7 +24027,7 @@ public static implicit operator HTML_JSAlert_t ( HTML_JSAlert_t.PackSmall d ) } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -22086,85 +24036,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_JSAlert_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_JSAlert_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -22187,6 +24123,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -22233,7 +24198,7 @@ public static implicit operator HTML_JSConfirm_t ( HTML_JSConfirm_t.PackSmall d } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -22242,85 +24207,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_JSConfirm_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_JSConfirm_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -22343,6 +24294,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -22392,7 +24372,7 @@ public static implicit operator HTML_FileOpenDialog_t ( HTML_FileOpenDialog_t.P } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -22401,85 +24381,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_FileOpenDialog_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_FileOpenDialog_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -22502,6 +24468,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -22563,7 +24558,7 @@ public static implicit operator HTML_NewWindow_t ( HTML_NewWindow_t.PackSmall d } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -22572,85 +24567,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_NewWindow_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_NewWindow_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -22673,6 +24654,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -22719,7 +24729,7 @@ public static implicit operator HTML_SetCursor_t ( HTML_SetCursor_t.PackSmall d } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -22728,85 +24738,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_SetCursor_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_SetCursor_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -22829,6 +24825,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -22875,7 +24900,7 @@ public static implicit operator HTML_StatusText_t ( HTML_StatusText_t.PackSmall } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -22884,85 +24909,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_StatusText_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_StatusText_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -22985,6 +24996,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -23031,7 +25071,7 @@ public static implicit operator HTML_ShowToolTip_t ( HTML_ShowToolTip_t.PackSma } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -23040,85 +25080,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_ShowToolTip_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_ShowToolTip_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -23141,6 +25167,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -23187,7 +25242,7 @@ public static implicit operator HTML_UpdateToolTip_t ( HTML_UpdateToolTip_t.Pac } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -23196,85 +25251,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_UpdateToolTip_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_UpdateToolTip_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -23297,6 +25338,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -23340,7 +25410,7 @@ public static implicit operator HTML_HideToolTip_t ( HTML_HideToolTip_t.PackSma } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -23349,85 +25419,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_HideToolTip_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_HideToolTip_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -23450,6 +25506,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -23496,7 +25581,7 @@ public static implicit operator HTML_BrowserRestarted_t ( HTML_BrowserRestarted } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -23505,85 +25590,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( HTML_BrowserRestarted_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( HTML_BrowserRestarted_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -23606,6 +25677,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -23702,7 +25802,7 @@ public static implicit operator SteamInventoryResultReady_t ( SteamInventoryRes } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -23711,85 +25811,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SteamInventoryResultReady_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SteamInventoryResultReady_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -23812,6 +25898,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -23855,7 +25970,7 @@ public static implicit operator SteamInventoryFullUpdate_t ( SteamInventoryFull } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -23864,85 +25979,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SteamInventoryFullUpdate_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SteamInventoryFullUpdate_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -23965,6 +26066,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -24024,7 +26154,7 @@ internal static CallResult CallResult( return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -24033,85 +26163,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SteamInventoryEligiblePromoItemDefIDs_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SteamInventoryEligiblePromoItemDefIDs_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -24134,6 +26250,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -24188,7 +26333,7 @@ internal static CallResult CallResult( Face return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -24197,85 +26342,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SteamInventoryStartPurchaseResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SteamInventoryStartPurchaseResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -24298,6 +26429,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -24351,7 +26511,7 @@ internal static CallResult CallResult( Face return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -24360,85 +26520,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( SteamInventoryRequestPricesResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( SteamInventoryRequestPricesResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -24461,6 +26607,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -24504,7 +26679,7 @@ public static implicit operator BroadcastUploadStop_t ( BroadcastUploadStop_t.P } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -24513,85 +26688,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( BroadcastUploadStop_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( BroadcastUploadStop_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -24614,6 +26775,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -24665,7 +26855,7 @@ public static implicit operator GetVideoURLResult_t ( GetVideoURLResult_t.PackS } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -24674,85 +26864,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GetVideoURLResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GetVideoURLResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -24775,6 +26951,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -24821,7 +27026,7 @@ public static implicit operator GetOPFSettingsResult_t ( GetOPFSettingsResult_t } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -24830,85 +27035,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GetOPFSettingsResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GetOPFSettingsResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -24931,6 +27122,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -24977,7 +27197,7 @@ public static implicit operator GSClientApprove_t ( GSClientApprove_t.PackSmall } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -24986,85 +27206,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GSClientApprove_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GSClientApprove_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -25087,6 +27293,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -25138,7 +27373,7 @@ public static implicit operator GSClientDeny_t ( GSClientDeny_t.PackSmall d ) } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -25147,85 +27382,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GSClientDeny_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GSClientDeny_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -25248,6 +27469,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -25294,7 +27544,7 @@ public static implicit operator GSClientKick_t ( GSClientKick_t.PackSmall d ) } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -25303,85 +27553,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GSClientKick_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GSClientKick_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -25404,6 +27640,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -25457,7 +27722,7 @@ public static implicit operator GSClientAchievementStatus_t ( GSClientAchieveme } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -25466,85 +27731,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GSClientAchievementStatus_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GSClientAchievementStatus_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -25567,6 +27818,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -25610,7 +27890,7 @@ public static implicit operator GSPolicyResponse_t ( GSPolicyResponse_t.PackSma } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -25619,85 +27899,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GSPolicyResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GSPolicyResponse_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -25720,6 +27986,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -25772,7 +28067,7 @@ public static implicit operator GSGameplayStats_t ( GSGameplayStats_t.PackSmall } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -25781,85 +28076,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GSGameplayStats_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GSGameplayStats_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -25882,6 +28163,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -25938,7 +28248,7 @@ public static implicit operator GSClientGroupStatus_t ( GSClientGroupStatus_t.P } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -25947,85 +28257,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GSClientGroupStatus_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GSClientGroupStatus_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -26048,6 +28344,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -26116,7 +28441,7 @@ internal static CallResult CallResult( Facepunch.Steamworks.Base return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -26125,85 +28450,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GSReputation_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GSReputation_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -26226,6 +28537,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -26274,7 +28614,7 @@ internal static CallResult CallResult( Facepunch.Stea return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -26283,85 +28623,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( AssociateWithClanResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( AssociateWithClanResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -26384,6 +28710,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -26444,7 +28799,7 @@ internal static CallResult CallResult( Fa return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -26453,85 +28808,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( ComputeNewPlayerCompatibilityResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( ComputeNewPlayerCompatibilityResult_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -26554,6 +28895,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -26605,7 +28975,7 @@ internal static CallResult CallResult( Facepunch.Steamworks.B return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -26614,85 +28984,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GSStatsReceived_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GSStatsReceived_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -26715,6 +29071,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -26766,7 +29151,7 @@ internal static CallResult CallResult( Facepunch.Steamworks.Bas return new CallResult( steamworks, call, CallbackFunction, FromPointer, StructSize(), CallbackId ); } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -26775,85 +29160,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GSStatsStored_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GSStatsStored_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -26876,6 +29247,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 4 )] @@ -26919,7 +29319,7 @@ public static implicit operator GSStatsUnloaded_t ( GSStatsUnloaded_t.PackSmall } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -26928,85 +29328,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( GSStatsUnloaded_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( GSStatsUnloaded_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -27029,6 +29415,35 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } [StructLayout( LayoutKind.Sequential, Pack = 8 )] @@ -27075,7 +29490,7 @@ public static implicit operator ItemInstalled_t ( ItemInstalled_t.PackSmall d ) } } - internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action CallbackFunction ) + internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks ) { var handle = new CallbackHandle( steamworks ); @@ -27084,85 +29499,71 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam // if ( Facepunch.Steamworks.Config.UseThisCall ) { - Callback.ThisCall.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.ThisCall.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.ThisCall.GetSize funcC = ( _ ) => Marshal.SizeOf( typeof( ItemInstalled_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( _ ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } else { - Callback.StdCall.Result funcA = ( p ) => { CallbackFunction( FromPointer( p ), false ); }; - Callback.StdCall.ResultWithInfo funcB = ( p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); }; - Callback.StdCall.GetSize funcC = ( ) => Marshal.SizeOf( typeof( ItemInstalled_t ) ); - - // - // If this platform is PackSmall, use PackSmall versions of everything instead - // - if ( Platform.PackSmall ) - { - funcC = ( ) => Marshal.SizeOf( typeof( PackSmall ) ); - } - - // - // Allocate a handle to each function, so they don't get disposed - // - handle.FuncA = GCHandle.Alloc( funcA ); - handle.FuncB = GCHandle.Alloc( funcB ); - handle.FuncC = GCHandle.Alloc( funcC ); - // // Create the VTable by manually allocating the memory and copying across // - handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) ); - var vTable = new Callback.VTable() - { - ResultA = Marshal.GetFunctionPointerForDelegate( funcA ), - ResultB = Marshal.GetFunctionPointerForDelegate( funcB ), - GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), - }; - // - // The order of these functions are swapped on Windows - // if ( Platform.IsWindows ) { - vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB ); - vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA ); + 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 ); } - Marshal.StructureToPtr( vTable, handle.vTablePtr, false ); } // @@ -27185,6 +29586,203 @@ internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steam steamworks.RegisterCallbackHandle( handle ); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); } + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static int OnGetSize(){ return StructSize(); } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + internal static void OnResult( IntPtr param ) + { + OnResultWithInfo( param, false, 0 ); + } + + [MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )] + 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 ); + } } + 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 ); + 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 ); + 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 ); + ItemInstalled_t.Register( steamworks ); + } + } } diff --git a/Generator/CodeWriter/Struct.cs b/Generator/CodeWriter/Struct.cs index f1fc1ef..74ad06d 100644 --- a/Generator/CodeWriter/Struct.cs +++ b/Generator/CodeWriter/Struct.cs @@ -37,6 +37,8 @@ public class TypeDef void Structs() { + var callbackList = new List(); + foreach ( var c in def.structs ) { if ( SkipStructs.Contains( c.Name ) ) @@ -133,12 +135,24 @@ void Structs() if ( !string.IsNullOrEmpty( c.CallbackId ) ) { Callback( c ); + callbackList.Add( c ); } } EndBlock(); WriteLine(); } + + StartBlock( $"internal static class Callbacks" ); + StartBlock( $"internal static void RegisterCallbacks( Facepunch.Steamworks.BaseSteamworks steamworks )" ); + { + foreach ( var c in callbackList ) + { + WriteLine( $"{c.Name}.Register( steamworks );" ); + } + } + EndBlock(); + EndBlock(); } private void StructFields( SteamApiDefinition.StructDef.StructFields[] fields ) @@ -216,14 +230,14 @@ private void StructFields( SteamApiDefinition.StructDef.StructFields[] fields ) } private void Callback( SteamApiDefinition.StructDef c ) - { + { WriteLine(); - StartBlock( $"internal static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action<{c.Name}, bool> CallbackFunction )" ); + StartBlock( $"internal static void Register( Facepunch.Steamworks.BaseSteamworks steamworks )" ); { WriteLine( $"var handle = new CallbackHandle( steamworks );" ); WriteLine( $"" ); - CallbackCallresultShared( c, false ); + CallbackCall( c ); WriteLine( "" ); WriteLine( "//" ); @@ -235,6 +249,42 @@ private void Callback( SteamApiDefinition.StructDef c ) WriteLine( "steamworks.RegisterCallbackHandle( handle );" ); } EndBlock(); + + WriteLine(); + WriteLine( "[MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )]" ); + WriteLine( "internal static void OnResultThis( IntPtr self, IntPtr param ){ OnResult( param ); }" ); + WriteLine( "[MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )]" ); + WriteLine( "internal static void OnResultWithInfoThis( IntPtr self, IntPtr param, bool failure, SteamNative.SteamAPICall_t call ){ OnResultWithInfo( param, failure, call ); }" ); + WriteLine( "[MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )]" ); + WriteLine( "internal static int OnGetSizeThis( IntPtr self ){ return OnGetSize(); }" ); + WriteLine( "[MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )]" ); + WriteLine( "internal static int OnGetSize(){ return StructSize(); }" ); + + WriteLine(); + WriteLine( "[MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )]" ); + StartBlock( "internal static void OnResult( IntPtr param )" ); + { + WriteLine( $"OnResultWithInfo( param, false, 0 );" ); + } + EndBlock(); + + WriteLine(); + WriteLine( "[MonoPInvokeCallback( typeof( SteamNative.Callback.VTableThis.ResultD ) )]" ); + 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(); } @@ -244,24 +294,12 @@ private void CallResult( SteamApiDefinition.StructDef c ) 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 );" ); - // WriteLine( $"" ); - - // CallbackCallresultShared( c, true ); - - // WriteLine( "" ); - // WriteLine( "//" ); - // WriteLine( "// Register the callback with Steam" ); - // WriteLine( "//" ); - // WriteLine( $"steamworks.native.api.SteamAPI_RegisterCallResult( handle.PinnedCallback.AddrOfPinnedObject(), call );" ); - - // WriteLine(); - //WriteLine( "return handle;" ); } EndBlock(); } - private void CallbackCallresultShared( SteamApiDefinition.StructDef c, bool Result ) + private void CallbackCall( SteamApiDefinition.StructDef c ) { WriteLine( "//" ); WriteLine( "// Create the functions we need for the vtable" ); @@ -269,11 +307,11 @@ private void CallbackCallresultShared( SteamApiDefinition.StructDef c, bool Resu StartBlock( "if ( Facepunch.Steamworks.Config.UseThisCall )" ); { - CallresultFunctions( c, Result, "ThisCall", "_" ); + CallFunctions( c, "ThisCall", "_" ); } Else(); { - CallresultFunctions( c, Result, "StdCall", "" ); + CallFunctions( c, "StdCall", "" ); } EndBlock(); @@ -293,73 +331,51 @@ private void CallbackCallresultShared( SteamApiDefinition.StructDef c, bool Resu WriteLine( $"handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned );" ); } - private void CallresultFunctions( SteamApiDefinition.StructDef c, bool Result, string ThisCall, string ThisArg ) + private void CallFunctions( SteamApiDefinition.StructDef c, string ThisCall, string ThisArg ) { var ThisArgC = ThisArg.Length > 0 ? $"{ThisArg}, " : ""; - - if ( Result ) - { - WriteLine( $"Callback.{ThisCall}.Result funcA = ( {ThisArgC}p ) => {{ handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }};" ); - StartBlock( $"Callback.{ThisCall}.ResultWithInfo funcB = ( {ThisArgC}p, bIOFailure, hSteamAPICall ) => " ); - { - WriteLine( "if ( hSteamAPICall != call ) return;" ); - WriteLine(); - WriteLine( "handle.CallResultHandle = 0;" ); - WriteLine( "handle.Dispose();" ); - WriteLine(); - WriteLine( "CallbackFunction( FromPointer( p ), bIOFailure );" ); - } - EndBlock( ";" ); - } - else - { - WriteLine( $"Callback.{ThisCall}.Result funcA = ( {ThisArgC}p ) => {{ CallbackFunction( FromPointer( p ), false ); }};" ); - WriteLine( $"Callback.{ThisCall}.ResultWithInfo funcB = ( {ThisArgC}p, bIOFailure, hSteamAPICall ) => {{ CallbackFunction( FromPointer( p ), bIOFailure ); }};" ); - } - - WriteLine( $"Callback.{ThisCall}.GetSize funcC = ( {ThisArg} ) => Marshal.SizeOf( typeof( {c.Name} ) );" ); - WriteLine(); - WriteLine( "//" ); - WriteLine( "// If this platform is PackSmall, use PackSmall versions of everything instead" ); - WriteLine( "//" ); - StartBlock( "if ( Platform.PackSmall )" ); - { - WriteLine( $"funcC = ( {ThisArg} ) => Marshal.SizeOf( typeof( PackSmall ) );" ); - } - EndBlock(); - - WriteLine( "" ); - WriteLine( "//" ); - WriteLine( "// Allocate a handle to each function, so they don't get disposed" ); - WriteLine( "//" ); - WriteLine( "handle.FuncA = GCHandle.Alloc( funcA );" ); - WriteLine( "handle.FuncB = GCHandle.Alloc( funcB );" ); - WriteLine( "handle.FuncC = GCHandle.Alloc( funcC );" ); - WriteLine(); + var This = ThisArg.Length > 0 ? "This" : ""; WriteLine( "//" ); WriteLine( "// Create the VTable by manually allocating the memory and copying across" ); WriteLine( "//" ); - WriteLine( "handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) );" ); - StartBlock( "var vTable = new Callback.VTable()" ); - { - WriteLine( "ResultA = Marshal.GetFunctionPointerForDelegate( funcA )," ); - WriteLine( "ResultB = Marshal.GetFunctionPointerForDelegate( funcB )," ); - WriteLine( "GetSize = Marshal.GetFunctionPointerForDelegate( funcC )," ); - } - EndBlock( ";" ); - - WriteLine( "//" ); - WriteLine( "// The order of these functions are swapped on Windows" ); - WriteLine( "//" ); StartBlock( "if ( Platform.IsWindows )" ); { - WriteLine( "vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB );" ); - WriteLine( "vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA );" ); + 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(); - WriteLine( "Marshal.StructureToPtr( vTable, handle.vTablePtr, false );" ); + } } }