diff --git a/Plugins/Steamworks.NET/CallbackDispatcher.cs b/Plugins/Steamworks.NET/CallbackDispatcher.cs index 815d1800..4d9959a8 100644 --- a/Plugins/Steamworks.NET/CallbackDispatcher.cs +++ b/Plugins/Steamworks.NET/CallbackDispatcher.cs @@ -295,6 +295,7 @@ private void OnRunCallback( #endif IntPtr pvParam) { m_hAPICall = SteamAPICall_t.Invalid; // Caller unregisters for us + try { m_Func((T)Marshal.PtrToStructure(pvParam, typeof(T)), false); } @@ -308,21 +309,17 @@ private void OnRunCallResult( #if !STDCALL IntPtr thisptr, #endif - IntPtr pvParam, bool bFailed, ulong hSteamAPICall) { - SteamAPICall_t hAPICall = (SteamAPICall_t)hSteamAPICall; - if (hAPICall == m_hAPICall) { + IntPtr pvParam, bool bFailed, ulong hSteamAPICall_) { + SteamAPICall_t hSteamAPICall = (SteamAPICall_t)hSteamAPICall_; + if (hSteamAPICall == m_hAPICall) { + m_hAPICall = SteamAPICall_t.Invalid; // Caller unregisters for us + try { m_Func((T)Marshal.PtrToStructure(pvParam, typeof(T)), bFailed); } catch (Exception e) { CallbackDispatcher.ExceptionHandler(e); } - - // The official SDK sets m_hAPICall to invalid before calling the callresult function, - // this doesn't let us access .Handle from within the function though. - if (hAPICall == m_hAPICall) { // Ensure that m_hAPICall has not been changed in m_Func - m_hAPICall = SteamAPICall_t.Invalid; // Caller unregisters for us - } } }