diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs new file mode 100644 index 0000000..da8cb4a --- /dev/null +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs @@ -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( Marshal.ReadIntPtr( VTable, 0) ); + _EstimatePingTimeBetweenTwoLocations = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 8) ); + _EstimatePingTimeFromLocalHost = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 16) ); + _ConvertPingLocationToString = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 24) ); + _ParsePingLocationString = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 32) ); + _CheckPingDataUpToDate = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 40) ); + _IsPingMeasurementInProgress = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 48) ); + _GetPingToDataCenter = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 56) ); + _GetDirectPingToPOP = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 64) ); + _GetPOPCount = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 72) ); + _GetPOPList = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 80) ); + _GetLocalTimestamp = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 88) ); + _SetDebugOutputFunction = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 96) ); + _SetConfigValue = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 104) ); + _GetConfigValue = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 112) ); + _GetConfigValueInfo = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 120) ); + _GetFirstConfigValue = Marshal.GetDelegateForFunctionPointer( 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 ); + } + + } +} diff --git a/Generator/CodeParser/CodeParser.Class.cs b/Generator/CodeParser/CodeParser.Class.cs index b132066..43672ae 100644 --- a/Generator/CodeParser/CodeParser.Class.cs +++ b/Generator/CodeParser/CodeParser.Class.cs @@ -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(); diff --git a/Generator/CodeWriter/CodeWriter.cs b/Generator/CodeWriter/CodeWriter.cs index a78199f..0642384 100644 --- a/Generator/CodeWriter/CodeWriter.cs +++ b/Generator/CodeWriter/CodeWriter.cs @@ -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" ); } } diff --git a/Generator/CodeWriter/Types/BaseType.cs b/Generator/CodeWriter/Types/BaseType.cs index 8d3ebac..8ee3ff5 100644 --- a/Generator/CodeWriter/Types/BaseType.cs +++ b/Generator/CodeWriter/Types/BaseType.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 };