diff --git a/Facepunch.Steamworks/BaseSteamworks.cs b/Facepunch.Steamworks/BaseSteamworks.cs index 774417f..55dd17e 100644 --- a/Facepunch.Steamworks/BaseSteamworks.cs +++ b/Facepunch.Steamworks/BaseSteamworks.cs @@ -21,7 +21,7 @@ public virtual void Dispose() { foreach ( var h in CallbackHandles ) { - h.UnregisterCallback(); + h.Dispose(); } CallbackHandles.Clear(); diff --git a/Facepunch.Steamworks/Interfaces/Workshop.Editor.cs b/Facepunch.Steamworks/Interfaces/Workshop.Editor.cs index 4c30779..32e2f8b 100644 --- a/Facepunch.Steamworks/Interfaces/Workshop.Editor.cs +++ b/Facepunch.Steamworks/Interfaces/Workshop.Editor.cs @@ -114,20 +114,17 @@ private void StartCreatingItem() private void OnItemCreated( SteamNative.CreateItemResult_t obj, bool Failed ) { - if ( Failed ) - throw new System.Exception( "CreateItemResult_t Failed" ); - NeedToAgreeToWorkshopLegal = obj.UserNeedsToAcceptWorkshopLegalAgreement; - CreateItem = null; + CreateItem.Dispose(); - if ( obj.Result == SteamNative.Result.OK ) + if ( obj.Result == SteamNative.Result.OK && !Failed ) { Id = obj.PublishedFileId; PublishChanges(); return; } - Error = "Error creating new file: " + obj.Result.ToString(); + Error = "Error creating new file: " + obj.Result.ToString() + "("+ obj.PublishedFileId+ ")"; Publishing = false; } diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.Callback.cs b/Facepunch.Steamworks/SteamNative/SteamNative.Callback.cs index df8fe48..29d7684 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.Callback.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.Callback.cs @@ -40,19 +40,21 @@ public class VTable public class CallbackHandle : IDisposable { internal BaseSteamworks steamworks; - - internal SteamAPICall_t callHandle; - - public GCHandle FuncA; - public GCHandle FuncB; - public GCHandle FuncC; - - public IntPtr vTablePtr; - - public GCHandle PinnedCallback; + internal SteamAPICall_t CallResultHandle; + internal bool CallResult; + internal GCHandle FuncA; + internal GCHandle FuncB; + internal GCHandle FuncC; + internal IntPtr vTablePtr; + internal GCHandle PinnedCallback; public void Dispose() { + if ( CallResult ) + UnregisterCallResult(); + else + UnregisterCallback(); + if ( FuncA.IsAllocated ) FuncA.Free(); @@ -72,50 +74,24 @@ public void Dispose() } } - internal void UnregisterCallback() + private void UnregisterCallback() { - if ( PinnedCallback.IsAllocated ) - { - steamworks.native.api.SteamAPI_UnregisterCallback( PinnedCallback.AddrOfPinnedObject() ); - } + if ( !PinnedCallback.IsAllocated ) + return; - Dispose(); + steamworks.native.api.SteamAPI_UnregisterCallback( PinnedCallback.AddrOfPinnedObject() ); } - internal void UnregisterCallResult() + private void UnregisterCallResult() { - if ( PinnedCallback.IsAllocated ) - { - steamworks.native.api.SteamAPI_UnregisterCallResult( PinnedCallback.AddrOfPinnedObject(), callHandle ); - } + if ( CallResultHandle == 0 ) + return; - Dispose(); + if ( !PinnedCallback.IsAllocated ) + return; + + steamworks.native.api.SteamAPI_UnregisterCallResult( PinnedCallback.AddrOfPinnedObject(), CallResultHandle ); } } - /* - public class CallResult : IDisposable - { - public SteamAPICall_t Handle { get; private set; } - private Callback.Handle CallbackHandle; - - - internal CallResult( BaseSteamworks steamworks, SteamAPICall_t Handle, Callback.Handle CallbackHandle ) - { - this.Handle = Handle; - this.CallbackHandle = CallbackHandle; - this.steamworks = steamworks; - } - - public void Dispose() - { - if ( !steamworks.IsValid ) return; - if ( this.Handle == 0 ) return; - - steamworks.native.api.SteamAPI_UnregisterCallResult( CallbackHandle.PinnedCallback.AddrOfPinnedObject(), Handle ); - CallbackHandle.Dispose(); - Handle = 0; - } - } - */ } diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.Structs.cs b/Facepunch.Steamworks/SteamNative/SteamNative.Structs.cs index 22a19d0..e973b26 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.Structs.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.Structs.cs @@ -574,13 +574,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( EncryptedAppTicketResponse_t ) ); }; // @@ -861,13 +870,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( StoreAuthURLResponse_t ) ); }; // @@ -1527,13 +1545,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( ClanOfficerListResponse_t ) ); }; // @@ -2214,13 +2241,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( JoinClanChatRoomCompletionResult_t ) ); }; // @@ -2410,13 +2446,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( FriendsGetFollowerCount_t ) ); }; // @@ -2512,13 +2557,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( FriendsIsFollowing_t ) ); }; // @@ -2617,13 +2671,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( FriendsEnumerateFollowingList_t ) ); }; // @@ -2721,13 +2784,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( SetPersonaNameResponse_t ) ); }; // @@ -3007,13 +3079,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( CheckFileSignature_t ) ); }; // @@ -3600,13 +3681,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( LobbyEnter_t ) ); }; // @@ -4099,13 +4189,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( LobbyMatchList_t ) ); }; // @@ -4295,13 +4394,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( LobbyCreated_t ) ); }; // @@ -5026,13 +5134,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageFileShareResult_t ) ); }; // @@ -5224,13 +5341,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageDeletePublishedFileResult_t ) ); }; // @@ -5329,13 +5455,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageEnumerateUserPublishedFilesResult_t ) ); }; // @@ -5426,13 +5561,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageSubscribePublishedFileResult_t ) ); }; // @@ -5536,13 +5680,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageEnumerateUserSubscribedFilesResult_t ) ); }; // @@ -5633,13 +5786,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageUnsubscribePublishedFileResult_t ) ); }; // @@ -5735,13 +5897,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageUpdatePublishedFileResult_t ) ); }; // @@ -5846,13 +6017,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageDownloadUGCResult_t ) ); }; // @@ -6016,13 +6196,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageGetPublishedFileDetailsResult_t ) ); }; // @@ -6132,13 +6321,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageEnumerateWorkshopFilesResult_t ) ); }; // @@ -6241,13 +6439,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageGetPublishedItemVoteDetailsResult_t ) ); }; // @@ -6626,13 +6833,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageUpdateUserPublishedItemVoteResult_t ) ); }; // @@ -6929,13 +7145,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageSetUserPublishedFileActionResult_t ) ); }; // @@ -7042,13 +7267,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageEnumeratePublishedFilesByUserActionResult_t ) ); }; // @@ -7141,13 +7375,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStoragePublishFileProgress_t ) ); }; // @@ -7334,13 +7577,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageFileWriteAsyncComplete_t ) ); }; // @@ -7437,13 +7689,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( RemoteStorageFileReadAsyncComplete_t ) ); }; // @@ -7581,13 +7842,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( UserStatsReceived_t ) ); }; // @@ -7883,13 +8153,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( LeaderboardFindResult_t ) ); }; // @@ -7983,13 +8262,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( LeaderboardScoresDownloaded_t ) ); }; // @@ -8092,13 +8380,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( LeaderboardScoreUploaded_t ) ); }; // @@ -8189,13 +8486,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( NumberOfCurrentPlayers_t ) ); }; // @@ -8485,13 +8791,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( GlobalAchievementPercentagesReady_t ) ); }; // @@ -8582,13 +8897,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( LeaderboardUGCSet_t ) ); }; // @@ -8778,13 +9102,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( GlobalStatsReceived_t ) ); }; // @@ -9176,13 +9509,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( FileDetailsResult_t ) ); }; // @@ -11050,13 +11392,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( SteamUGCQueryCompleted_t ) ); }; // @@ -11250,13 +11601,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall.Value != call.Value ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( CreateItemResult_t ) ); }; // @@ -11349,13 +11709,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( SubmitItemUpdateResult_t ) ); }; // @@ -11550,13 +11919,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( UserFavoriteItemsListChanged_t ) ); }; // @@ -11652,13 +12030,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( SetUserItemVoteResult_t ) ); }; // @@ -11764,13 +12151,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( GetUserItemVoteResult_t ) ); }; // @@ -11858,13 +12254,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( StartPlaytimeTrackingResult_t ) ); }; // @@ -11952,13 +12357,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( StopPlaytimeTrackingResult_t ) ); }; // @@ -12232,13 +12646,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( HTML_BrowserReady_t ) ); }; // @@ -15426,13 +15849,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( GSReputation_t ) ); }; // @@ -15520,13 +15952,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( AssociateWithClanResult_t ) ); }; // @@ -15626,13 +16067,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( ComputeNewPlayerCompatibilityResult_t ) ); }; // @@ -15723,13 +16173,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( GSStatsReceived_t ) ); }; // @@ -15820,13 +16279,22 @@ public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks ste { var handle = new CallbackHandle(); handle.steamworks = steamworks; - handle.callHandle = call; + handle.CallResultHandle = call; + handle.CallResult = true; // // Create the functions we need for the vtable // - Callback.Result funcA = ( _, p ) => { CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }; - Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => { CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }; + Callback.Result funcA = ( _, p ) => { handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }; + Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => + { + if ( hSteamAPICall != call ) return; + + handle.CallResultHandle = 0; + handle.Dispose(); + + CallbackFunction( FromPointer( p ), bIOFailure ); + }; Callback.GetSize funcC = ( _ ) => { return Marshal.SizeOf( typeof( GSStatsStored_t ) ); }; // diff --git a/Generator/CodeWriter/Struct.cs b/Generator/CodeWriter/Struct.cs index b51e067..eb9902d 100644 --- a/Generator/CodeWriter/Struct.cs +++ b/Generator/CodeWriter/Struct.cs @@ -272,14 +272,24 @@ private void CallResult( SteamApiDefinition.StructDef c ) { WriteLine( $"var handle = new CallbackHandle();" ); WriteLine( $"handle.steamworks = steamworks;" ); - WriteLine( $"handle.callHandle = call;" ); + WriteLine( $"handle.CallResultHandle = call;" ); + WriteLine( $"handle.CallResult = true;" ); WriteLine( $"" ); WriteLine( "//" ); WriteLine( "// Create the functions we need for the vtable" ); WriteLine( "//" ); - WriteLine( $"Callback.Result funcA = ( _, p ) => {{ CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }};" ); - WriteLine( $"Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => {{ CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }};" ); + WriteLine( $"Callback.Result funcA = ( _, p ) => {{ handle.Dispose(); CallbackFunction( FromPointer( p ), false ); }};" ); + StartBlock( $"Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => " ); + { + WriteLine( "if ( hSteamAPICall != call ) return;" ); + WriteLine(); + WriteLine( "handle.CallResultHandle = 0;" ); + WriteLine( "handle.Dispose();" ); + WriteLine(); + WriteLine( "CallbackFunction( FromPointer( p ), bIOFailure );" ); + } + EndBlock( ";" ); WriteLine( $"Callback.GetSize funcC = ( _ ) => {{ return Marshal.SizeOf( typeof( {c.Name} ) ); }};" ); WriteLine(); WriteLine( "//" );