Fixed NetworkUtils.DebugOut on 32bit

This commit is contained in:
Garry Newman 2020-02-24 14:46:29 +00:00
parent d990b537a3
commit 403488dfcb
3 changed files with 13 additions and 5 deletions

View File

@ -96,7 +96,7 @@ namespace Steamworks
await Task.Delay( 1000 ); await Task.Delay( 1000 );
Close(); //Close();
} }
public override unsafe void OnMessage( Connection connection, NetIdentity identity, IntPtr data, int size, long messageNum, long recvTime, int channel ) public override unsafe void OnMessage( Connection connection, NetIdentity identity, IntPtr data, int size, long messageNum, long recvTime, int channel )

View File

@ -4,5 +4,6 @@ using System.Runtime.InteropServices;
namespace Steamworks.Data namespace Steamworks.Data
{ {
delegate void NetDebugFunc( NetDebugOutput nType, string pszMsg ); [UnmanagedFunctionPointer( Platform.CC )]
delegate void NetDebugFunc( [In] NetDebugOutput nType, [In] IntPtr pszMsg );
} }

View File

@ -178,7 +178,9 @@ namespace Steamworks
set set
{ {
_debugLevel = value; _debugLevel = value;
Internal.SetDebugOutputFunction( value, OnDebugMessage ); _debugFunc = new NetDebugFunc( OnDebugMessage );
Internal.SetDebugOutputFunction( value, _debugFunc );
} }
} }
@ -187,6 +189,11 @@ namespace Steamworks
/// </summary> /// </summary>
private static NetDebugOutput _debugLevel; private static NetDebugOutput _debugLevel;
/// <summary>
/// We need to keep the delegate around until it's not used anymore
/// </summary>
static NetDebugFunc _debugFunc;
struct DebugMessage struct DebugMessage
{ {
public NetDebugOutput Type; public NetDebugOutput Type;
@ -198,9 +205,9 @@ namespace Steamworks
/// <summary> /// <summary>
/// This can be called from other threads - so we're going to queue these up and process them in a safe place. /// This can be called from other threads - so we're going to queue these up and process them in a safe place.
/// </summary> /// </summary>
private static void OnDebugMessage( NetDebugOutput nType, string pszMsg ) private static void OnDebugMessage( NetDebugOutput nType, IntPtr str )
{ {
debugMessages.Enqueue( new DebugMessage { Type = nType, Msg = pszMsg } ); debugMessages.Enqueue( new DebugMessage { Type = nType, Msg = Helpers.MemoryToString( str ) } );
} }
/// <summary> /// <summary>