diff --git a/Facepunch.Steamworks/BaseSteamworks.cs b/Facepunch.Steamworks/BaseSteamworks.cs
index fbdf91f..8e95faf 100644
--- a/Facepunch.Steamworks/BaseSteamworks.cs
+++ b/Facepunch.Steamworks/BaseSteamworks.cs
@@ -81,13 +81,13 @@ namespace Facepunch.Steamworks
///
/// Global callback type
///
- internal void AddCallback( Action Callback, int id )
+ internal void AddCallback( Action Callback, int id ) where T : new()
{
var callback = new Callback( native.api, IsGameServer, id, Callback );
Disposables.Add( callback );
}
- internal void AddCallback( Action Callback, int id )
+ internal void AddCallback( Action Callback, int id ) where T : new()
{
AddCallback( Callback, id );
}
diff --git a/Facepunch.Steamworks/Interfaces/Networking.cs b/Facepunch.Steamworks/Interfaces/Networking.cs
index 94d64d9..3a58293 100644
--- a/Facepunch.Steamworks/Interfaces/Networking.cs
+++ b/Facepunch.Steamworks/Interfaces/Networking.cs
@@ -47,7 +47,7 @@ namespace Facepunch.Steamworks
}
}
- private void onP2PConnectionRequest( P2PSessionRequest o )
+ private void onP2PConnectionRequest( P2PSessionRequest o, bool b )
{
if ( OnIncomingConnection != null )
{
@@ -83,7 +83,7 @@ namespace Facepunch.Steamworks
Max = 5
};
- private void onP2PConnectionFailed( P2PSessionConnectFail o )
+ private void onP2PConnectionFailed( P2PSessionConnectFail o, bool b )
{
if ( OnConnectionFailed != null )
{
diff --git a/Facepunch.Steamworks/Interfaces/Workshop.cs b/Facepunch.Steamworks/Interfaces/Workshop.cs
index ba0ee58..520238e 100644
--- a/Facepunch.Steamworks/Interfaces/Workshop.cs
+++ b/Facepunch.Steamworks/Interfaces/Workshop.cs
@@ -37,13 +37,13 @@ namespace Facepunch.Steamworks
OnItemInstalled = null;
}
- private void onItemInstalled( ItemInstalled obj )
+ private void onItemInstalled( ItemInstalled obj, bool failed )
{
if ( OnItemInstalled != null )
OnItemInstalled( obj.FileId );
}
- private void onDownloadResult( DownloadResult obj )
+ private void onDownloadResult( DownloadResult obj, bool failed )
{
if ( OnFileDownloaded != null )
OnFileDownloaded( obj.FileId, obj.Result );
diff --git a/Facepunch.Steamworks/Interop/Callback.This.cs b/Facepunch.Steamworks/Interop/Callback.This.cs
index 39b8464..88f6543 100644
--- a/Facepunch.Steamworks/Interop/Callback.This.cs
+++ b/Facepunch.Steamworks/Interop/Callback.This.cs
@@ -10,26 +10,29 @@ namespace Facepunch.Steamworks.Interop.VTable.This
internal struct Callback
{
[UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate void Result( IntPtr thisptr, IntPtr pvParam );
+ [UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate void ResultBool( IntPtr thisptr, IntPtr pvParam, bool bIOFailure, SteamNative.SteamAPICall_t hSteamAPICall );
[UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate int GetSize( IntPtr thisptr );
- [MarshalAs(UnmanagedType.FunctionPtr)] public Result RunCallResult;
+ [MarshalAs(UnmanagedType.FunctionPtr)] public ResultBool RunCallResult;
[MarshalAs(UnmanagedType.FunctionPtr)] public Result RunCallback;
[MarshalAs(UnmanagedType.FunctionPtr)] public GetSize GetCallbackSizeBytes;
- internal static IntPtr Get( Action onRunCallback, int size, Interop.Callback cb )
+ internal static IntPtr Get( Action onRunCallback, int size, Interop.Callback cb )
{
var ptr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback ) ) );
- Callback.Result da = ( _, p ) => { onRunCallback( _, p ); };
+ Callback.Result da = ( _, p ) => { onRunCallback( _, p, false ); };
+ Callback.ResultBool db = ( _, p, iofailure, call ) => { onRunCallback( _, p, iofailure ); };
Callback.GetSize dc = ( _ ) => { return size; };
cb.AddHandle( GCHandle.Alloc( da ) );
+ cb.AddHandle( GCHandle.Alloc( db ) );
cb.AddHandle( GCHandle.Alloc( dc ) );
var table = new Callback()
{
RunCallback = da,
- RunCallResult = da,
+ RunCallResult = db,
GetCallbackSizeBytes = dc
};
diff --git a/Facepunch.Steamworks/Interop/Callback.cs b/Facepunch.Steamworks/Interop/Callback.cs
index 4f22b41..7896681 100644
--- a/Facepunch.Steamworks/Interop/Callback.cs
+++ b/Facepunch.Steamworks/Interop/Callback.cs
@@ -48,20 +48,20 @@ namespace Facepunch.Steamworks.Interop
}
}
- internal partial class Callback : Callback
+ internal partial class Callback : Callback where T : new()
{
private SteamNative.SteamApi api;
public int CallbackId = 0;
public bool GameServer = false;
- public Action Function;
+ public Action Function;
private IntPtr vTablePtr = IntPtr.Zero;
private GCHandle callbackPin;
private readonly int m_size = Marshal.SizeOf(typeof(T));
- public Callback( SteamNative.SteamApi api, bool gameserver, int callbackid, Action func )
+ public Callback( SteamNative.SteamApi api, bool gameserver, int callbackid, Action func )
{
this.api = api;
GameServer = gameserver;
@@ -90,16 +90,22 @@ namespace Facepunch.Steamworks.Interop
base.Dispose();
}
- private void OnRunCallback( IntPtr thisObject, IntPtr ptr )
+ private void OnRunCallback( IntPtr thisObject, IntPtr ptr, bool failure )
{
if ( callbackPin == null ) throw new System.Exception( "Callback wasn't pinned!" );
if ( vTablePtr == IntPtr.Zero ) throw new System.Exception( "vTablePtr wasn't pinned!" );
- if ( thisObject != IntPtr.Zero && thisObject != callbackPin.AddrOfPinnedObject() ) throw new System.Exception( "This wasn't valid!" );
+ if ( thisObject != IntPtr.Zero && thisObject != callbackPin.AddrOfPinnedObject() ) throw new System.Exception( "This wasn't valid! ("+ thisObject.ToInt64() + ") ( "+ callbackPin.AddrOfPinnedObject().ToInt64() + " )" );
if ( SteamNative.Platform.PackSmall && typeof(T) != typeof( TSmall ) ) throw new System.Exception( "Callback should use PackSmall" );
+ if ( failure )
+ {
+ Function( new T(), failure );
+ return;
+ }
+
T data = (T) Marshal.PtrToStructure( ptr, typeof(T) );
- Function( data );
+ Function( data, failure );
}
diff --git a/Facepunch.Steamworks/Server/Auth.cs b/Facepunch.Steamworks/Server/Auth.cs
index a5c8317..3448950 100644
--- a/Facepunch.Steamworks/Server/Auth.cs
+++ b/Facepunch.Steamworks/Server/Auth.cs
@@ -58,7 +58,7 @@ namespace Facepunch.Steamworks
server.AddCallback( OnAuthTicketValidate, ValidateAuthTicketResponse.CallbackId );
}
- void OnAuthTicketValidate( ValidateAuthTicketResponse data )
+ void OnAuthTicketValidate( ValidateAuthTicketResponse data, bool b )
{
if ( OnAuthChange != null )
OnAuthChange( data.SteamID, data.OwnerSteamID, (Status) data.AuthResponse );