mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 14:15:47 +03:00
Fixes
This commit is contained in:
parent
bae105dbc9
commit
c9443b75f2
@ -21,7 +21,7 @@ public virtual void Dispose()
|
||||
{
|
||||
foreach ( var h in CallbackHandles )
|
||||
{
|
||||
h.UnregisterCallback();
|
||||
h.Dispose();
|
||||
}
|
||||
CallbackHandles.Clear();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<T> : 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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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( "//" );
|
||||
|
Loading…
Reference in New Issue
Block a user