mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-27 07:05:50 +03:00
ISteamNetworkingUtils
This commit is contained in:
parent
068beddc04
commit
239273a715
@ -0,0 +1,232 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Steamworks.Data;
|
||||
|
||||
|
||||
namespace Steamworks
|
||||
{
|
||||
internal class ISteamNetworkingUtils : SteamInterface
|
||||
{
|
||||
public ISteamNetworkingUtils( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "SteamNetworkingUtils001";
|
||||
|
||||
public override void InitInternals()
|
||||
{
|
||||
_GetLocalPingLocation = Marshal.GetDelegateForFunctionPointer<FGetLocalPingLocation>( Marshal.ReadIntPtr( VTable, 0) );
|
||||
_EstimatePingTimeBetweenTwoLocations = Marshal.GetDelegateForFunctionPointer<FEstimatePingTimeBetweenTwoLocations>( Marshal.ReadIntPtr( VTable, 8) );
|
||||
_EstimatePingTimeFromLocalHost = Marshal.GetDelegateForFunctionPointer<FEstimatePingTimeFromLocalHost>( Marshal.ReadIntPtr( VTable, 16) );
|
||||
_ConvertPingLocationToString = Marshal.GetDelegateForFunctionPointer<FConvertPingLocationToString>( Marshal.ReadIntPtr( VTable, 24) );
|
||||
_ParsePingLocationString = Marshal.GetDelegateForFunctionPointer<FParsePingLocationString>( Marshal.ReadIntPtr( VTable, 32) );
|
||||
_CheckPingDataUpToDate = Marshal.GetDelegateForFunctionPointer<FCheckPingDataUpToDate>( Marshal.ReadIntPtr( VTable, 40) );
|
||||
_IsPingMeasurementInProgress = Marshal.GetDelegateForFunctionPointer<FIsPingMeasurementInProgress>( Marshal.ReadIntPtr( VTable, 48) );
|
||||
_GetPingToDataCenter = Marshal.GetDelegateForFunctionPointer<FGetPingToDataCenter>( Marshal.ReadIntPtr( VTable, 56) );
|
||||
_GetDirectPingToPOP = Marshal.GetDelegateForFunctionPointer<FGetDirectPingToPOP>( Marshal.ReadIntPtr( VTable, 64) );
|
||||
_GetPOPCount = Marshal.GetDelegateForFunctionPointer<FGetPOPCount>( Marshal.ReadIntPtr( VTable, 72) );
|
||||
_GetPOPList = Marshal.GetDelegateForFunctionPointer<FGetPOPList>( Marshal.ReadIntPtr( VTable, 80) );
|
||||
_GetLocalTimestamp = Marshal.GetDelegateForFunctionPointer<FGetLocalTimestamp>( Marshal.ReadIntPtr( VTable, 88) );
|
||||
_SetDebugOutputFunction = Marshal.GetDelegateForFunctionPointer<FSetDebugOutputFunction>( Marshal.ReadIntPtr( VTable, 96) );
|
||||
_SetConfigValue = Marshal.GetDelegateForFunctionPointer<FSetConfigValue>( Marshal.ReadIntPtr( VTable, 104) );
|
||||
_GetConfigValue = Marshal.GetDelegateForFunctionPointer<FGetConfigValue>( Marshal.ReadIntPtr( VTable, 112) );
|
||||
_GetConfigValueInfo = Marshal.GetDelegateForFunctionPointer<FGetConfigValueInfo>( Marshal.ReadIntPtr( VTable, 120) );
|
||||
_GetFirstConfigValue = Marshal.GetDelegateForFunctionPointer<FGetFirstConfigValue>( Marshal.ReadIntPtr( VTable, 128) );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate float FGetLocalPingLocation( IntPtr self, SteamNetworkPingLocation_t result );
|
||||
private FGetLocalPingLocation _GetLocalPingLocation;
|
||||
|
||||
#endregion
|
||||
internal float GetLocalPingLocation( SteamNetworkPingLocation_t result )
|
||||
{
|
||||
return _GetLocalPingLocation( Self, result );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate int FEstimatePingTimeBetweenTwoLocations( IntPtr self, SteamNetworkPingLocation_t location1, SteamNetworkPingLocation_t location2 );
|
||||
private FEstimatePingTimeBetweenTwoLocations _EstimatePingTimeBetweenTwoLocations;
|
||||
|
||||
#endregion
|
||||
internal int EstimatePingTimeBetweenTwoLocations( SteamNetworkPingLocation_t location1, SteamNetworkPingLocation_t location2 )
|
||||
{
|
||||
return _EstimatePingTimeBetweenTwoLocations( Self, location1, location2 );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate int FEstimatePingTimeFromLocalHost( IntPtr self, SteamNetworkPingLocation_t remoteLocation );
|
||||
private FEstimatePingTimeFromLocalHost _EstimatePingTimeFromLocalHost;
|
||||
|
||||
#endregion
|
||||
internal int EstimatePingTimeFromLocalHost( SteamNetworkPingLocation_t remoteLocation )
|
||||
{
|
||||
return _EstimatePingTimeFromLocalHost( Self, remoteLocation );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FConvertPingLocationToString( IntPtr self, SteamNetworkPingLocation_t location, StringBuilder pszBuf, int cchBufSize );
|
||||
private FConvertPingLocationToString _ConvertPingLocationToString;
|
||||
|
||||
#endregion
|
||||
internal void ConvertPingLocationToString( SteamNetworkPingLocation_t location, StringBuilder pszBuf, int cchBufSize )
|
||||
{
|
||||
_ConvertPingLocationToString( Self, location, pszBuf, cchBufSize );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FParsePingLocationString( IntPtr self, string pszString, SteamNetworkPingLocation_t result );
|
||||
private FParsePingLocationString _ParsePingLocationString;
|
||||
|
||||
#endregion
|
||||
internal bool ParsePingLocationString( string pszString, SteamNetworkPingLocation_t result )
|
||||
{
|
||||
return _ParsePingLocationString( Self, pszString, result );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FCheckPingDataUpToDate( IntPtr self, float flMaxAgeSeconds );
|
||||
private FCheckPingDataUpToDate _CheckPingDataUpToDate;
|
||||
|
||||
#endregion
|
||||
internal bool CheckPingDataUpToDate( float flMaxAgeSeconds )
|
||||
{
|
||||
return _CheckPingDataUpToDate( Self, flMaxAgeSeconds );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FIsPingMeasurementInProgress( IntPtr self );
|
||||
private FIsPingMeasurementInProgress _IsPingMeasurementInProgress;
|
||||
|
||||
#endregion
|
||||
internal bool IsPingMeasurementInProgress()
|
||||
{
|
||||
return _IsPingMeasurementInProgress( Self );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate int FGetPingToDataCenter( IntPtr self, SteamNetworkingPOPID popID, ref SteamNetworkingPOPID pViaRelayPoP );
|
||||
private FGetPingToDataCenter _GetPingToDataCenter;
|
||||
|
||||
#endregion
|
||||
internal int GetPingToDataCenter( SteamNetworkingPOPID popID, ref SteamNetworkingPOPID pViaRelayPoP )
|
||||
{
|
||||
return _GetPingToDataCenter( Self, popID, ref pViaRelayPoP );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate int FGetDirectPingToPOP( IntPtr self, SteamNetworkingPOPID popID );
|
||||
private FGetDirectPingToPOP _GetDirectPingToPOP;
|
||||
|
||||
#endregion
|
||||
internal int GetDirectPingToPOP( SteamNetworkingPOPID popID )
|
||||
{
|
||||
return _GetDirectPingToPOP( Self, popID );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate int FGetPOPCount( IntPtr self );
|
||||
private FGetPOPCount _GetPOPCount;
|
||||
|
||||
#endregion
|
||||
internal int GetPOPCount()
|
||||
{
|
||||
return _GetPOPCount( Self );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate int FGetPOPList( IntPtr self, ref SteamNetworkingPOPID list, int nListSz );
|
||||
private FGetPOPList _GetPOPList;
|
||||
|
||||
#endregion
|
||||
internal int GetPOPList( ref SteamNetworkingPOPID list, int nListSz )
|
||||
{
|
||||
return _GetPOPList( Self, ref list, nListSz );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamNetworkingMicroseconds FGetLocalTimestamp( IntPtr self );
|
||||
private FGetLocalTimestamp _GetLocalTimestamp;
|
||||
|
||||
#endregion
|
||||
internal SteamNetworkingMicroseconds GetLocalTimestamp()
|
||||
{
|
||||
return _GetLocalTimestamp( Self );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FSetDebugOutputFunction( IntPtr self, SteamNetworkingSocketsDebugOutputType eDetailLevel, FSteamNetworkingSocketsDebugOutput pfnFunc );
|
||||
private FSetDebugOutputFunction _SetDebugOutputFunction;
|
||||
|
||||
#endregion
|
||||
internal void SetDebugOutputFunction( SteamNetworkingSocketsDebugOutputType eDetailLevel, FSteamNetworkingSocketsDebugOutput pfnFunc )
|
||||
{
|
||||
_SetDebugOutputFunction( Self, eDetailLevel, pfnFunc );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FSetConfigValue( IntPtr self, SteamNetworkingConfigValue eValue, SteamNetworkingConfigScope eScopeType, IntPtr scopeObj, SteamNetworkingConfigDataType eDataType, IntPtr pArg );
|
||||
private FSetConfigValue _SetConfigValue;
|
||||
|
||||
#endregion
|
||||
internal bool SetConfigValue( SteamNetworkingConfigValue eValue, SteamNetworkingConfigScope eScopeType, IntPtr scopeObj, SteamNetworkingConfigDataType eDataType, IntPtr pArg )
|
||||
{
|
||||
return _SetConfigValue( Self, eValue, eScopeType, scopeObj, eDataType, pArg );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamNetworkingGetConfigValueResult FGetConfigValue( IntPtr self, SteamNetworkingConfigValue eValue, SteamNetworkingConfigScope eScopeType, IntPtr scopeObj, [In,Out] SteamNetworkingConfigDataType[] pOutDataType, IntPtr pResult, ref ulong cbResult );
|
||||
private FGetConfigValue _GetConfigValue;
|
||||
|
||||
#endregion
|
||||
internal SteamNetworkingGetConfigValueResult GetConfigValue( SteamNetworkingConfigValue eValue, SteamNetworkingConfigScope eScopeType, IntPtr scopeObj, [In,Out] SteamNetworkingConfigDataType[] pOutDataType, IntPtr pResult, ref ulong cbResult )
|
||||
{
|
||||
return _GetConfigValue( Self, eValue, eScopeType, scopeObj, pOutDataType, pResult, ref cbResult );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FGetConfigValueInfo( IntPtr self, SteamNetworkingConfigValue eValue, [In,Out] string[] pOutName, [In,Out] SteamNetworkingConfigDataType[] pOutDataType, [In,Out] SteamNetworkingConfigScope[] pOutScope, [In,Out] SteamNetworkingConfigValue[] pOutNextValue );
|
||||
private FGetConfigValueInfo _GetConfigValueInfo;
|
||||
|
||||
#endregion
|
||||
internal bool GetConfigValueInfo( SteamNetworkingConfigValue eValue, [In,Out] string[] pOutName, [In,Out] SteamNetworkingConfigDataType[] pOutDataType, [In,Out] SteamNetworkingConfigScope[] pOutScope, [In,Out] SteamNetworkingConfigValue[] pOutNextValue )
|
||||
{
|
||||
return _GetConfigValueInfo( Self, eValue, pOutName, pOutDataType, pOutScope, pOutNextValue );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamNetworkingConfigValue FGetFirstConfigValue( IntPtr self );
|
||||
private FGetFirstConfigValue _GetFirstConfigValue;
|
||||
|
||||
#endregion
|
||||
internal SteamNetworkingConfigValue GetFirstConfigValue()
|
||||
{
|
||||
return _GetFirstConfigValue( Self );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ internal Function AddFunction( string funcName, string returnType, string args )
|
||||
|
||||
foreach ( var arg in args.Split( new[] { ',' }, StringSplitOptions.RemoveEmptyEntries ) )
|
||||
{
|
||||
var m = Regex.Match( arg.Trim(), @"(.+?[ |\*])?([a-zA-Z0-9_]+?)( = (.+?))?$" );
|
||||
var m = Regex.Match( arg.Trim(), @"(.+?[ |\*|\&])?([a-zA-Z0-9_]+?)( = (.+?))?$" );
|
||||
|
||||
var t = m.Groups[1].Value.Trim();
|
||||
var n = m.Groups[2].Value.Trim();
|
||||
|
@ -80,6 +80,7 @@ public void ToFolder( string folder )
|
||||
GenerateVTableClass( "ISteamNetworking", $"{folder}../Generated/Interfaces/ISteamNetworking.cs" );
|
||||
GenerateVTableClass( "ISteamMatchmaking", $"{folder}../Generated/Interfaces/ISteamMatchmaking.cs" );
|
||||
GenerateVTableClass( "ISteamParties", $"{folder}../Generated/Interfaces/ISteamParties.cs" );
|
||||
GenerateVTableClass( "ISteamNetworkingUtils", $"{folder}../Generated/Interfaces/ISteamNetworkingUtils.cs" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,12 +17,15 @@ public static BaseType Parse( string type, string varname = null )
|
||||
{
|
||||
type = Cleanup.ConvertType( type );
|
||||
|
||||
type = type.Trim( '&' );
|
||||
|
||||
if ( type == "SteamAPIWarningMessageHook_t" ) return new PointerType { NativeType = type, VarName = varname };
|
||||
if ( type == "intptr_t" ) return new PointerType { NativeType = type, VarName = varname };
|
||||
|
||||
if ( type == "SteamAPICall_t" ) return new SteamApiCallType { NativeType = type, VarName = varname };
|
||||
|
||||
if ( type == "void" ) return new VoidType { NativeType = type, VarName = varname };
|
||||
if ( type.Replace( " ", "" ) == "constchar*" ) return new ConstCharType { NativeType = type, VarName = varname };
|
||||
if ( type.Replace( " ", "" ).StartsWith( "constchar*" ) ) return new ConstCharType { NativeType = type, VarName = varname };
|
||||
if ( type == "char *" ) return new StringBuilderType { NativeType = type, VarName = varname };
|
||||
|
||||
var basicType = type.Replace( "const ", "" ).Trim( ' ', '*' );
|
||||
@ -35,6 +38,10 @@ public static BaseType Parse( string type, string varname = null )
|
||||
if ( basicType == "uint8" ) return new UInt8Type { NativeType = type, VarName = varname };
|
||||
if ( basicType == "uint16" ) return new UInt16Type { NativeType = type, VarName = varname };
|
||||
if ( basicType == "SteamId" ) return new CSteamIdType { NativeType = type, VarName = varname };
|
||||
|
||||
// DANGER DANGER Danger
|
||||
if ( basicType == "size_t" ) return new ULongType { NativeType = type, VarName = varname };
|
||||
|
||||
if ( basicType == "uint64" ) return new ULongType { NativeType = type, VarName = varname };
|
||||
if ( basicType == "int64" ) return new LongType { NativeType = type, VarName = varname };
|
||||
if ( basicType == "bool" ) return new BoolType { NativeType = type, VarName = varname };
|
||||
|
Loading…
Reference in New Issue
Block a user