From 798bfa991eeed0b59cf2b97d80d5fee0e8cc152d Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Wed, 19 Feb 2020 10:27:04 +0000 Subject: [PATCH] SteamNetworkingConfigValue_t => NetKeyValue --- .../Interfaces/ISteamNetworkingSockets.cs | 42 +++++++++---------- .../Interfaces/ISteamNetworkingUtils.cs | 4 +- Facepunch.Steamworks/Generated/SteamEnums.cs | 2 +- .../Generated/SteamStructs.cs | 14 ------- Facepunch.Steamworks/Structs/NetKeyValue.cs | 31 ++++++++++++++ Generator/Cleanup.cs | 2 + Generator/CodeWriter/Types/BaseType.cs | 2 + 7 files changed, 59 insertions(+), 38 deletions(-) create mode 100644 Facepunch.Steamworks/Structs/NetKeyValue.cs diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs index 7e92b81..a4b7b98 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs @@ -19,45 +19,45 @@ namespace Steamworks #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_CreateListenSocketIP")] - private static extern Socket _CreateListenSocketIP( IntPtr self, ref NetAddress localAddress, int nOptions, ref NetConfig_t pOptions ); + private static extern Socket _CreateListenSocketIP( IntPtr self, ref NetAddress localAddress, int nOptions, [In,Out] NetKeyValue[] pOptions ); #endregion - internal Socket CreateListenSocketIP( ref NetAddress localAddress, int nOptions, ref NetConfig_t pOptions ) + internal Socket CreateListenSocketIP( ref NetAddress localAddress, int nOptions, [In,Out] NetKeyValue[] pOptions ) { - var returnValue = _CreateListenSocketIP( Self, ref localAddress, nOptions, ref pOptions ); + var returnValue = _CreateListenSocketIP( Self, ref localAddress, nOptions, pOptions ); return returnValue; } #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_ConnectByIPAddress")] - private static extern Connection _ConnectByIPAddress( IntPtr self, ref NetAddress address, int nOptions, ref NetConfig_t pOptions ); + private static extern Connection _ConnectByIPAddress( IntPtr self, ref NetAddress address, int nOptions, [In,Out] NetKeyValue[] pOptions ); #endregion - internal Connection ConnectByIPAddress( ref NetAddress address, int nOptions, ref NetConfig_t pOptions ) + internal Connection ConnectByIPAddress( ref NetAddress address, int nOptions, [In,Out] NetKeyValue[] pOptions ) { - var returnValue = _ConnectByIPAddress( Self, ref address, nOptions, ref pOptions ); + var returnValue = _ConnectByIPAddress( Self, ref address, nOptions, pOptions ); return returnValue; } #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_CreateListenSocketP2P")] - private static extern Socket _CreateListenSocketP2P( IntPtr self, int nVirtualPort, int nOptions, ref NetConfig_t pOptions ); + private static extern Socket _CreateListenSocketP2P( IntPtr self, int nVirtualPort, int nOptions, [In,Out] NetKeyValue[] pOptions ); #endregion - internal Socket CreateListenSocketP2P( int nVirtualPort, int nOptions, ref NetConfig_t pOptions ) + internal Socket CreateListenSocketP2P( int nVirtualPort, int nOptions, [In,Out] NetKeyValue[] pOptions ) { - var returnValue = _CreateListenSocketP2P( Self, nVirtualPort, nOptions, ref pOptions ); + var returnValue = _CreateListenSocketP2P( Self, nVirtualPort, nOptions, pOptions ); return returnValue; } #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_ConnectP2P")] - private static extern Connection _ConnectP2P( IntPtr self, ref NetIdentity identityRemote, int nVirtualPort, int nOptions, ref NetConfig_t pOptions ); + private static extern Connection _ConnectP2P( IntPtr self, ref NetIdentity identityRemote, int nVirtualPort, int nOptions, [In,Out] NetKeyValue[] pOptions ); #endregion - internal Connection ConnectP2P( ref NetIdentity identityRemote, int nVirtualPort, int nOptions, ref NetConfig_t pOptions ) + internal Connection ConnectP2P( ref NetIdentity identityRemote, int nVirtualPort, int nOptions, [In,Out] NetKeyValue[] pOptions ) { - var returnValue = _ConnectP2P( Self, ref identityRemote, nVirtualPort, nOptions, ref pOptions ); + var returnValue = _ConnectP2P( Self, ref identityRemote, nVirtualPort, nOptions, pOptions ); return returnValue; } @@ -352,12 +352,12 @@ namespace Steamworks #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_ConnectToHostedDedicatedServer")] - private static extern Connection _ConnectToHostedDedicatedServer( IntPtr self, ref NetIdentity identityTarget, int nVirtualPort, int nOptions, ref NetConfig_t pOptions ); + private static extern Connection _ConnectToHostedDedicatedServer( IntPtr self, ref NetIdentity identityTarget, int nVirtualPort, int nOptions, [In,Out] NetKeyValue[] pOptions ); #endregion - internal Connection ConnectToHostedDedicatedServer( ref NetIdentity identityTarget, int nVirtualPort, int nOptions, ref NetConfig_t pOptions ) + internal Connection ConnectToHostedDedicatedServer( ref NetIdentity identityTarget, int nVirtualPort, int nOptions, [In,Out] NetKeyValue[] pOptions ) { - var returnValue = _ConnectToHostedDedicatedServer( Self, ref identityTarget, nVirtualPort, nOptions, ref pOptions ); + var returnValue = _ConnectToHostedDedicatedServer( Self, ref identityTarget, nVirtualPort, nOptions, pOptions ); return returnValue; } @@ -396,12 +396,12 @@ namespace Steamworks #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_CreateHostedDedicatedServerListenSocket")] - private static extern Socket _CreateHostedDedicatedServerListenSocket( IntPtr self, int nVirtualPort, int nOptions, ref NetConfig_t pOptions ); + private static extern Socket _CreateHostedDedicatedServerListenSocket( IntPtr self, int nVirtualPort, int nOptions, [In,Out] NetKeyValue[] pOptions ); #endregion - internal Socket CreateHostedDedicatedServerListenSocket( int nVirtualPort, int nOptions, ref NetConfig_t pOptions ) + internal Socket CreateHostedDedicatedServerListenSocket( int nVirtualPort, int nOptions, [In,Out] NetKeyValue[] pOptions ) { - var returnValue = _CreateHostedDedicatedServerListenSocket( Self, nVirtualPort, nOptions, ref pOptions ); + var returnValue = _CreateHostedDedicatedServerListenSocket( Self, nVirtualPort, nOptions, pOptions ); return returnValue; } @@ -418,12 +418,12 @@ namespace Steamworks #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_ConnectP2PCustomSignaling")] - private static extern Connection _ConnectP2PCustomSignaling( IntPtr self, IntPtr pSignaling, ref NetIdentity pPeerIdentity, int nOptions, ref NetConfig_t pOptions ); + private static extern Connection _ConnectP2PCustomSignaling( IntPtr self, IntPtr pSignaling, ref NetIdentity pPeerIdentity, int nOptions, [In,Out] NetKeyValue[] pOptions ); #endregion - internal Connection ConnectP2PCustomSignaling( IntPtr pSignaling, ref NetIdentity pPeerIdentity, int nOptions, ref NetConfig_t pOptions ) + internal Connection ConnectP2PCustomSignaling( IntPtr pSignaling, ref NetIdentity pPeerIdentity, int nOptions, [In,Out] NetKeyValue[] pOptions ) { - var returnValue = _ConnectP2PCustomSignaling( Self, pSignaling, ref pPeerIdentity, nOptions, ref pOptions ); + var returnValue = _ConnectP2PCustomSignaling( Self, pSignaling, ref pPeerIdentity, nOptions, pOptions ); return returnValue; } diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs index 083834f..6285843 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs @@ -270,10 +270,10 @@ namespace Steamworks #region FunctionMeta [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingUtils_SetConfigValueStruct")] [return: MarshalAs( UnmanagedType.I1 )] - private static extern bool _SetConfigValueStruct( IntPtr self, ref NetConfig_t opt, NetConfigScope eScopeType, long scopeObj ); + private static extern bool _SetConfigValueStruct( IntPtr self, ref NetKeyValue opt, NetConfigScope eScopeType, long scopeObj ); #endregion - internal bool SetConfigValueStruct( ref NetConfig_t opt, NetConfigScope eScopeType, long scopeObj ) + internal bool SetConfigValueStruct( ref NetKeyValue opt, NetConfigScope eScopeType, long scopeObj ) { var returnValue = _SetConfigValueStruct( Self, ref opt, eScopeType, scopeObj ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/SteamEnums.cs b/Facepunch.Steamworks/Generated/SteamEnums.cs index 67a64bd..f6614b4 100644 --- a/Facepunch.Steamworks/Generated/SteamEnums.cs +++ b/Facepunch.Steamworks/Generated/SteamEnums.cs @@ -2037,7 +2037,7 @@ namespace Steamworks // // ESteamNetworkingConfigScope // - internal enum SteamNetworkingConfigScope : int + internal enum NetConfigScope : int { Global = 1, SocketsInterface = 2, diff --git a/Facepunch.Steamworks/Generated/SteamStructs.cs b/Facepunch.Steamworks/Generated/SteamStructs.cs index f852492..2db0bc1 100644 --- a/Facepunch.Steamworks/Generated/SteamStructs.cs +++ b/Facepunch.Steamworks/Generated/SteamStructs.cs @@ -195,20 +195,6 @@ namespace Steamworks.Data } - [StructLayout( LayoutKind.Sequential, Pack = Platform.StructPlatformPackSize )] - internal struct NetConfig_t - { - internal NetConfig Value; // m_eValue ESteamNetworkingConfigValue - internal NetConfigType DataType; // m_eDataType ESteamNetworkingConfigDataType - internal long Nt64; // m_int64 int64_t - internal int Val_int32; // m_val_int32 int32_t - internal long Val_int64; // m_val_int64 int64_t - internal float Val_float; // m_val_float float - internal string Val_string; // m_val_string const char * - internal IntPtr Val_functionPtr; // m_val_functionPtr void * - - } - [StructLayout( LayoutKind.Sequential, Pack = Platform.StructPlatformPackSize )] internal struct SteamDatagramHostedAddress { diff --git a/Facepunch.Steamworks/Structs/NetKeyValue.cs b/Facepunch.Steamworks/Structs/NetKeyValue.cs new file mode 100644 index 0000000..88bc7ee --- /dev/null +++ b/Facepunch.Steamworks/Structs/NetKeyValue.cs @@ -0,0 +1,31 @@ +using Steamworks.Data; +using System; +using System.Runtime.InteropServices; + +namespace Steamworks.Data +{ + [StructLayout( LayoutKind.Explicit, Pack = Platform.StructPlatformPackSize )] + internal struct NetKeyValue + { + [FieldOffset(0)] + internal NetConfig Value; // m_eValue ESteamNetworkingConfigValue + + [FieldOffset( 4 )] + internal NetConfigType DataType; // m_eDataType ESteamNetworkingConfigDataType + + [FieldOffset( 8 )] + internal long Int64Value; // m_int64 int64_t + + [FieldOffset( 8 )] + internal int Int32Value; // m_val_int32 int32_t + + [FieldOffset( 8 )] + internal float FloatValue; // m_val_float float + + [FieldOffset( 8 )] + internal IntPtr PointerValue; // m_val_functionPtr void * + + + // TODO - support strings, maybe + } +} \ No newline at end of file diff --git a/Generator/Cleanup.cs b/Generator/Cleanup.cs index b519730..c098b3f 100644 --- a/Generator/Cleanup.cs +++ b/Generator/Cleanup.cs @@ -34,6 +34,7 @@ public static class Cleanup type = type.Replace( "SteamItemDef_t", "InventoryDefId" ); type = type.Replace( "ChatRoomEnterResponse", "RoomEnter" ); type = type.Replace( "SteamNetworkPingLocation_t", "PingLocation" ); + type = type.Replace( "SteamNetworkingConfigValue_t", "NetKeyValue" ); type = type.Replace( "SteamNetworkingConfigValue", "NetConfig" ); type = type.Replace( "SteamNetworkingConfigScope", "NetConfigScope" ); type = type.Replace( "SteamNetworkingConfigDataType", "NetConfigType" ); @@ -81,6 +82,7 @@ public static class Cleanup if ( type == "NetIdentity" ) return false; if ( type == "SteamNetworkingQuickConnectionStatus" ) return false; if ( type == "SteamNetworkingErrMsg" ) return false; + if ( type == "NetKeyValue" ) return false; return true; } diff --git a/Generator/CodeWriter/Types/BaseType.cs b/Generator/CodeWriter/Types/BaseType.cs index 880adef..ef66259 100644 --- a/Generator/CodeWriter/Types/BaseType.cs +++ b/Generator/CodeWriter/Types/BaseType.cs @@ -62,6 +62,7 @@ internal class BaseType if ( basicType == "AnalogState" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType }; if ( basicType == "MotionState" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType }; if ( basicType == "NetMsg" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType }; + if ( basicType == "NetKeyValue" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType }; if ( basicType.StartsWith( "E" ) && char.IsUpper( basicType[1] ) ) return new EnumType { NativeType = type.Substring( 1 ), VarName = varname }; if ( basicType.EndsWith( "_t" ) ) return new StructType { NativeType = type, VarName = varname, StructName = basicType }; @@ -87,6 +88,7 @@ internal class BaseType if ( Func == "ReadP2PPacket" ) return false; if ( Func == "SendP2PPacket" ) return false; if ( VarName == "pOutMessageNumber" ) return false; + if ( VarName == "pOptions" ) return true; if ( VarName == "pOut" ) return false; if ( VarName == "pOutBuffer" ) return false;