diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index e25bf74..11ee059 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -6,12 +6,14 @@ jobs: build: runs-on: windows-latest - + steps: - uses: actions/checkout@v2 - - - name: setup-msbuild - uses: microsoft/setup-msbuild@v1 + - name: Setup dotnet 6.0.x + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '6.0.x' + include-prerelease: true - name: Restore Win64 run: dotnet restore Facepunch.Steamworks\Facepunch.Steamworks.Win64.csproj @@ -21,13 +23,13 @@ jobs: run: dotnet restore Facepunch.Steamworks\Facepunch.Steamworks.Posix.csproj - name: Build Win64 - run: msbuild Facepunch.Steamworks\Facepunch.Steamworks.Win64.csproj + run: dotnet build Facepunch.Steamworks\Facepunch.Steamworks.Win64.csproj - name: Build Win32 - run: msbuild Facepunch.Steamworks\Facepunch.Steamworks.Win32.csproj + run: dotnet build Facepunch.Steamworks\Facepunch.Steamworks.Win32.csproj - name: Build Posix - run: msbuild Facepunch.Steamworks\Facepunch.Steamworks.Posix.csproj + run: dotnet build Facepunch.Steamworks\Facepunch.Steamworks.Posix.csproj - uses: actions/upload-artifact@v1 with: name: Compiled Files - path: Facepunch.Steamworks/bin \ No newline at end of file + path: Facepunch.Steamworks/bin diff --git a/Facepunch.Steamworks.Test/Facepunch.Steamworks.TestWin32.csproj b/Facepunch.Steamworks.Test/Facepunch.Steamworks.TestWin32.csproj index 278596f..b5d97a7 100644 --- a/Facepunch.Steamworks.Test/Facepunch.Steamworks.TestWin32.csproj +++ b/Facepunch.Steamworks.Test/Facepunch.Steamworks.TestWin32.csproj @@ -1,156 +1,55 @@ - - - - - Debug - AnyCPU - {3F6183AD-D966-44F2-A6EB-42E61E591B49} - Library - Properties - Facepunch.Steamworks.TestWin32 - Facepunch.Steamworks.TestWin32 - v4.6 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - + - true - full - false - bin\Debug\ TRACE;DEBUG;TEST_WIN32 - prompt - 4 x86 true - pdbonly - true - bin\Release\ TRACE;TEST_WIN32 - prompt - 4 x64 true - true bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt MinimumRecommendedRules.ruleset true bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt MinimumRecommendedRules.ruleset true - true bin\x86\Debug\ - DEBUG;TRACE - full x64 - prompt MinimumRecommendedRules.ruleset true bin\x86\Release\ - TRACE - true - pdbonly x64 - prompt MinimumRecommendedRules.ruleset true + + net6.0 + false + - - ..\packages\MSTest.TestFramework.2.0.0-beta4\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.2.0.0-beta4\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - ..\packages\Newtonsoft.Json.9.0.2-beta1\lib\net45\Newtonsoft.Json.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {2d6247f6-8ab2-405f-a00e-3a364b808a55} - Facepunch.Steamworks.Win32 - + Always - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/Facepunch.Steamworks.Test/Facepunch.Steamworks.TestWin64.csproj b/Facepunch.Steamworks.Test/Facepunch.Steamworks.TestWin64.csproj index c4353e2..2a18571 100644 --- a/Facepunch.Steamworks.Test/Facepunch.Steamworks.TestWin64.csproj +++ b/Facepunch.Steamworks.Test/Facepunch.Steamworks.TestWin64.csproj @@ -1,156 +1,54 @@ - - - - - Debug - AnyCPU - {165081E3-BD96-404B-B83E-A635F1AF7CDE} - Library - Properties - Facepunch.Steamworks.TestWin64 - Facepunch.Steamworks.TestWin64 - v4.6 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - + - true - full - false - bin\Debug\ TRACE;DEBUG;TEST_WIN64 - prompt - 4 x64 true - pdbonly - true - bin\Release\ - TRACE - prompt - 4 x64 true - true bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt MinimumRecommendedRules.ruleset true bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt MinimumRecommendedRules.ruleset true - true bin\x86\Debug\ - DEBUG;TRACE - full x64 - prompt MinimumRecommendedRules.ruleset true bin\x86\Release\ - TRACE - true - pdbonly x64 - prompt MinimumRecommendedRules.ruleset true + + net6.0 + false + - - ..\packages\MSTest.TestFramework.2.0.0-beta4\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.2.0.0-beta4\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - ..\packages\Newtonsoft.Json.9.0.2-beta1\lib\net45\Newtonsoft.Json.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {8c73da93-73ad-4445-9a2c-15d4a44337d3} - Facepunch.Steamworks.Win64 - + Always - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/Facepunch.Steamworks/Facepunch.Steamworks.Posix.csproj b/Facepunch.Steamworks/Facepunch.Steamworks.Posix.csproj index 0a0e3c5..525e62d 100644 --- a/Facepunch.Steamworks/Facepunch.Steamworks.Posix.csproj +++ b/Facepunch.Steamworks/Facepunch.Steamworks.Posix.csproj @@ -3,9 +3,9 @@ Facepunch.Steamworks.Posix $(DefineConstants);PLATFORM_POSIX - netstandard2.0;net46 + netstandard2.1;net6.0 true - 7.1 + 10 true false Steamworks diff --git a/Facepunch.Steamworks/Facepunch.Steamworks.Win32.csproj b/Facepunch.Steamworks/Facepunch.Steamworks.Win32.csproj index 9304d2d..3730d8a 100644 --- a/Facepunch.Steamworks/Facepunch.Steamworks.Win32.csproj +++ b/Facepunch.Steamworks/Facepunch.Steamworks.Win32.csproj @@ -3,9 +3,8 @@ Facepunch.Steamworks.Win32 $(DefineConstants);PLATFORM_WIN32;PLATFORM_WIN - netstandard2.0;net46 - true - 7.1 + netstandard2.1;net6.0 + true true true Steamworks @@ -19,19 +18,25 @@ https://github.com/Facepunch/Facepunch.Steamworks Facepunch.Steamworks.jpg facepunch;steam;unity;steamworks;valve - latest + 10 MIT https://github.com/Facepunch/Facepunch.Steamworks.git git + true - + + true + / + + Always - - + true + content + - \ No newline at end of file + diff --git a/Facepunch.Steamworks/Facepunch.Steamworks.Win64.csproj b/Facepunch.Steamworks/Facepunch.Steamworks.Win64.csproj index 4b41172..73ba39c 100644 --- a/Facepunch.Steamworks/Facepunch.Steamworks.Win64.csproj +++ b/Facepunch.Steamworks/Facepunch.Steamworks.Win64.csproj @@ -3,9 +3,8 @@ Facepunch.Steamworks.Win64 $(DefineConstants);PLATFORM_WIN64;PLATFORM_WIN;PLATFORM_64 - netstandard2.0;net46 - true - 7.1 + netstandard2.1;net6.0 + true true true Steamworks @@ -19,23 +18,23 @@ https://github.com/Facepunch/Facepunch.Steamworks Facepunch.Steamworks.jpg facepunch;steam;unity;steamworks;valve - latest + 10 MIT https://github.com/Facepunch/Facepunch.Steamworks.git git + true - - - - - - - - - - + + true + / + + + Always + true + content + diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamAppList.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamAppList.cs index f483dbd..b674575 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamAppList.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamAppList.cs @@ -49,7 +49,7 @@ namespace Steamworks #endregion internal int GetAppName( AppId nAppID, out string pchName ) { - IntPtr mempchName = Helpers.TakeMemory(); + using var mempchName = Helpers.TakeMemory(); var returnValue = _GetAppName( Self, nAppID, mempchName, (1024 * 32) ); pchName = Helpers.MemoryToString( mempchName ); return returnValue; @@ -62,7 +62,7 @@ namespace Steamworks #endregion internal int GetAppInstallDir( AppId nAppID, out string pchDirectory ) { - IntPtr mempchDirectory = Helpers.TakeMemory(); + using var mempchDirectory = Helpers.TakeMemory(); var returnValue = _GetAppInstallDir( Self, nAppID, mempchDirectory, (1024 * 32) ); pchDirectory = Helpers.MemoryToString( mempchDirectory ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs index a9d9480..3918dca 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs @@ -159,7 +159,7 @@ namespace Steamworks #endregion internal bool BGetDLCDataByIndex( int iDLC, ref AppId pAppID, [MarshalAs( UnmanagedType.U1 )] ref bool pbAvailable, out string pchName ) { - IntPtr mempchName = Helpers.TakeMemory(); + using var mempchName = Helpers.TakeMemory(); var returnValue = _BGetDLCDataByIndex( Self, iDLC, ref pAppID, ref pbAvailable, mempchName, (1024 * 32) ); pchName = Helpers.MemoryToString( mempchName ); return returnValue; @@ -203,7 +203,7 @@ namespace Steamworks #endregion internal bool GetCurrentBetaName( out string pchName ) { - IntPtr mempchName = Helpers.TakeMemory(); + using var mempchName = Helpers.TakeMemory(); var returnValue = _GetCurrentBetaName( Self, mempchName, (1024 * 32) ); pchName = Helpers.MemoryToString( mempchName ); return returnValue; @@ -239,7 +239,7 @@ namespace Steamworks #endregion internal uint GetAppInstallDir( AppId appID, out string pchFolder ) { - IntPtr mempchFolder = Helpers.TakeMemory(); + using var mempchFolder = Helpers.TakeMemory(); var returnValue = _GetAppInstallDir( Self, appID, mempchFolder, (1024 * 32) ); pchFolder = Helpers.MemoryToString( mempchFolder ); return returnValue; @@ -330,7 +330,7 @@ namespace Steamworks #endregion internal int GetLaunchCommandLine( out string pszCommandLine ) { - IntPtr mempszCommandLine = Helpers.TakeMemory(); + using var mempszCommandLine = Helpers.TakeMemory(); var returnValue = _GetLaunchCommandLine( Self, mempszCommandLine, (1024 * 32) ); pszCommandLine = Helpers.MemoryToString( mempszCommandLine ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameSearch.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameSearch.cs index ac4c2eb..3c70b84 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameSearch.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameSearch.cs @@ -82,7 +82,7 @@ namespace Steamworks #endregion internal GameSearchErrorCode_t RetrieveConnectionDetails( SteamId steamIDHost, out string pchConnectionDetails ) { - IntPtr mempchConnectionDetails = Helpers.TakeMemory(); + using var mempchConnectionDetails = Helpers.TakeMemory(); var returnValue = _RetrieveConnectionDetails( Self, steamIDHost, mempchConnectionDetails, (1024 * 32) ); pchConnectionDetails = Helpers.MemoryToString( mempchConnectionDetails ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs index 10340de..09d7783 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs @@ -60,7 +60,7 @@ namespace Steamworks #endregion internal bool GetResultItemProperty( SteamInventoryResult_t resultHandle, uint unItemIndex, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchPropertyName, out string pchValueBuffer, ref uint punValueBufferSizeOut ) { - IntPtr mempchValueBuffer = Helpers.TakeMemory(); + using var mempchValueBuffer = Helpers.TakeMemory(); var returnValue = _GetResultItemProperty( Self, resultHandle, unItemIndex, pchPropertyName, mempchValueBuffer, ref punValueBufferSizeOut ); pchValueBuffer = Helpers.MemoryToString( mempchValueBuffer ); return returnValue; @@ -327,7 +327,7 @@ namespace Steamworks #endregion internal bool GetItemDefinitionProperty( InventoryDefId iDefinition, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchPropertyName, out string pchValueBuffer, ref uint punValueBufferSizeOut ) { - IntPtr mempchValueBuffer = Helpers.TakeMemory(); + using var mempchValueBuffer = Helpers.TakeMemory(); var returnValue = _GetItemDefinitionProperty( Self, iDefinition, pchPropertyName, mempchValueBuffer, ref punValueBufferSizeOut ); pchValueBuffer = Helpers.MemoryToString( mempchValueBuffer ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmaking.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmaking.cs index 4ac1647..801d410 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmaking.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmaking.cs @@ -266,8 +266,8 @@ namespace Steamworks #endregion internal bool GetLobbyDataByIndex( SteamId steamIDLobby, int iLobbyData, out string pchKey, out string pchValue ) { - IntPtr mempchKey = Helpers.TakeMemory(); - IntPtr mempchValue = Helpers.TakeMemory(); + using var mempchKey = Helpers.TakeMemory(); + using var mempchValue = Helpers.TakeMemory(); var returnValue = _GetLobbyDataByIndex( Self, steamIDLobby, iLobbyData, mempchKey, (1024 * 32), mempchValue, (1024 * 32) ); pchKey = Helpers.MemoryToString( mempchKey ); pchValue = Helpers.MemoryToString( mempchValue ); diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs index 46e5b17..e359320 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs @@ -143,7 +143,7 @@ namespace Steamworks #endregion internal bool GetConnectionName( Connection hPeer, out string pszName ) { - IntPtr mempszName = Helpers.TakeMemory(); + using var mempszName = Helpers.TakeMemory(); var returnValue = _GetConnectionName( Self, hPeer, mempszName, (1024 * 32) ); pszName = Helpers.MemoryToString( mempszName ); return returnValue; @@ -223,7 +223,7 @@ namespace Steamworks #endregion internal int GetDetailedConnectionStatus( Connection hConn, out string pszBuf ) { - IntPtr mempszBuf = Helpers.TakeMemory(); + using var mempszBuf = Helpers.TakeMemory(); var returnValue = _GetDetailedConnectionStatus( Self, hConn, mempszBuf, (1024 * 32) ); pszBuf = Helpers.MemoryToString( mempszBuf ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs index f1cd609..acdf50c 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs @@ -92,7 +92,7 @@ namespace Steamworks #endregion internal void ConvertPingLocationToString( ref NetPingLocation location, out string pszBuf ) { - IntPtr mempszBuf = Helpers.TakeMemory(); + using var mempszBuf = Helpers.TakeMemory(); _ConvertPingLocationToString( Self, ref location, mempszBuf, (1024 * 32) ); pszBuf = Helpers.MemoryToString( mempszBuf ); } @@ -395,7 +395,7 @@ namespace Steamworks #endregion internal void SteamNetworkingIPAddr_ToString( ref NetAddress addr, out string buf, [MarshalAs( UnmanagedType.U1 )] bool bWithPort ) { - IntPtr membuf = Helpers.TakeMemory(); + using var membuf = Helpers.TakeMemory(); _SteamNetworkingIPAddr_ToString( Self, ref addr, membuf, (1024 * 32), bWithPort ); buf = Helpers.MemoryToString( membuf ); } @@ -419,7 +419,7 @@ namespace Steamworks #endregion internal void SteamNetworkingIdentity_ToString( ref NetIdentity identity, out string buf ) { - IntPtr membuf = Helpers.TakeMemory(); + using var membuf = Helpers.TakeMemory(); _SteamNetworkingIdentity_ToString( Self, ref identity, membuf, (1024 * 32) ); buf = Helpers.MemoryToString( membuf ); } diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamParties.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamParties.cs index 86b6a1d..e9585ec 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamParties.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamParties.cs @@ -50,7 +50,7 @@ namespace Steamworks #endregion internal bool GetBeaconDetails( PartyBeaconID_t ulBeaconID, ref SteamId pSteamIDBeaconOwner, ref SteamPartyBeaconLocation_t pLocation, out string pchMetadata ) { - IntPtr mempchMetadata = Helpers.TakeMemory(); + using var mempchMetadata = Helpers.TakeMemory(); var returnValue = _GetBeaconDetails( Self, ulBeaconID, ref pSteamIDBeaconOwner, ref pLocation, mempchMetadata, (1024 * 32) ); pchMetadata = Helpers.MemoryToString( mempchMetadata ); return returnValue; @@ -153,7 +153,7 @@ namespace Steamworks #endregion internal bool GetBeaconLocationData( SteamPartyBeaconLocation_t BeaconLocation, SteamPartyBeaconLocationData eData, out string pchDataStringOut ) { - IntPtr mempchDataStringOut = Helpers.TakeMemory(); + using var mempchDataStringOut = Helpers.TakeMemory(); var returnValue = _GetBeaconLocationData( Self, BeaconLocation, eData, mempchDataStringOut, (1024 * 32) ); pchDataStringOut = Helpers.MemoryToString( mempchDataStringOut ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs index 0a6d7c2..b79dad5 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs @@ -109,7 +109,7 @@ namespace Steamworks #endregion internal bool GetQueryUGCTag( UGCQueryHandle_t handle, uint index, uint indexTag, out string pchValue ) { - IntPtr mempchValue = Helpers.TakeMemory(); + using var mempchValue = Helpers.TakeMemory(); var returnValue = _GetQueryUGCTag( Self, handle, index, indexTag, mempchValue, (1024 * 32) ); pchValue = Helpers.MemoryToString( mempchValue ); return returnValue; @@ -123,7 +123,7 @@ namespace Steamworks #endregion internal bool GetQueryUGCTagDisplayName( UGCQueryHandle_t handle, uint index, uint indexTag, out string pchValue ) { - IntPtr mempchValue = Helpers.TakeMemory(); + using var mempchValue = Helpers.TakeMemory(); var returnValue = _GetQueryUGCTagDisplayName( Self, handle, index, indexTag, mempchValue, (1024 * 32) ); pchValue = Helpers.MemoryToString( mempchValue ); return returnValue; @@ -137,7 +137,7 @@ namespace Steamworks #endregion internal bool GetQueryUGCPreviewURL( UGCQueryHandle_t handle, uint index, out string pchURL ) { - IntPtr mempchURL = Helpers.TakeMemory(); + using var mempchURL = Helpers.TakeMemory(); var returnValue = _GetQueryUGCPreviewURL( Self, handle, index, mempchURL, (1024 * 32) ); pchURL = Helpers.MemoryToString( mempchURL ); return returnValue; @@ -151,7 +151,7 @@ namespace Steamworks #endregion internal bool GetQueryUGCMetadata( UGCQueryHandle_t handle, uint index, out string pchMetadata ) { - IntPtr mempchMetadata = Helpers.TakeMemory(); + using var mempchMetadata = Helpers.TakeMemory(); var returnValue = _GetQueryUGCMetadata( Self, handle, index, mempchMetadata, (1024 * 32) ); pchMetadata = Helpers.MemoryToString( mempchMetadata ); return returnValue; @@ -200,8 +200,8 @@ namespace Steamworks #endregion internal bool GetQueryUGCAdditionalPreview( UGCQueryHandle_t handle, uint index, uint previewIndex, out string pchURLOrVideoID, out string pchOriginalFileName, ref ItemPreviewType pPreviewType ) { - IntPtr mempchURLOrVideoID = Helpers.TakeMemory(); - IntPtr mempchOriginalFileName = Helpers.TakeMemory(); + using var mempchURLOrVideoID = Helpers.TakeMemory(); + using var mempchOriginalFileName = Helpers.TakeMemory(); var returnValue = _GetQueryUGCAdditionalPreview( Self, handle, index, previewIndex, mempchURLOrVideoID, (1024 * 32), mempchOriginalFileName, (1024 * 32), ref pPreviewType ); pchURLOrVideoID = Helpers.MemoryToString( mempchURLOrVideoID ); pchOriginalFileName = Helpers.MemoryToString( mempchOriginalFileName ); @@ -227,8 +227,8 @@ namespace Steamworks #endregion internal bool GetQueryUGCKeyValueTag( UGCQueryHandle_t handle, uint index, uint keyValueTagIndex, out string pchKey, out string pchValue ) { - IntPtr mempchKey = Helpers.TakeMemory(); - IntPtr mempchValue = Helpers.TakeMemory(); + using var mempchKey = Helpers.TakeMemory(); + using var mempchValue = Helpers.TakeMemory(); var returnValue = _GetQueryUGCKeyValueTag( Self, handle, index, keyValueTagIndex, mempchKey, (1024 * 32), mempchValue, (1024 * 32) ); pchKey = Helpers.MemoryToString( mempchKey ); pchValue = Helpers.MemoryToString( mempchValue ); @@ -243,7 +243,7 @@ namespace Steamworks #endregion internal bool GetQueryUGCKeyValueTag( UGCQueryHandle_t handle, uint index, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchKey, out string pchValue ) { - IntPtr mempchValue = Helpers.TakeMemory(); + using var mempchValue = Helpers.TakeMemory(); var returnValue = _GetQueryUGCKeyValueTag( Self, handle, index, pchKey, mempchValue, (1024 * 32) ); pchValue = Helpers.MemoryToString( mempchValue ); return returnValue; @@ -832,7 +832,7 @@ namespace Steamworks #endregion internal bool GetItemInstallInfo( PublishedFileId nPublishedFileID, ref ulong punSizeOnDisk, out string pchFolder, ref uint punTimeStamp ) { - IntPtr mempchFolder = Helpers.TakeMemory(); + using var mempchFolder = Helpers.TakeMemory(); var returnValue = _GetItemInstallInfo( Self, nPublishedFileID, ref punSizeOnDisk, mempchFolder, (1024 * 32), ref punTimeStamp ); pchFolder = Helpers.MemoryToString( mempchFolder ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs index 5e903b7..7b4852b 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs @@ -93,7 +93,7 @@ namespace Steamworks #endregion internal bool GetUserDataFolder( out string pchBuffer ) { - IntPtr mempchBuffer = Helpers.TakeMemory(); + using var mempchBuffer = Helpers.TakeMemory(); var returnValue = _GetUserDataFolder( Self, mempchBuffer, (1024 * 32) ); pchBuffer = Helpers.MemoryToString( mempchBuffer ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs index b738b30..5ec2053 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs @@ -433,7 +433,7 @@ namespace Steamworks #endregion internal int GetMostAchievedAchievementInfo( out string pchName, ref float pflPercent, [MarshalAs( UnmanagedType.U1 )] ref bool pbAchieved ) { - IntPtr mempchName = Helpers.TakeMemory(); + using var mempchName = Helpers.TakeMemory(); var returnValue = _GetMostAchievedAchievementInfo( Self, mempchName, (1024 * 32), ref pflPercent, ref pbAchieved ); pchName = Helpers.MemoryToString( mempchName ); return returnValue; @@ -446,7 +446,7 @@ namespace Steamworks #endregion internal int GetNextMostAchievedAchievementInfo( int iIteratorPrevious, out string pchName, ref float pflPercent, [MarshalAs( UnmanagedType.U1 )] ref bool pbAchieved ) { - IntPtr mempchName = Helpers.TakeMemory(); + using var mempchName = Helpers.TakeMemory(); var returnValue = _GetNextMostAchievedAchievementInfo( Self, iIteratorPrevious, mempchName, (1024 * 32), ref pflPercent, ref pbAchieved ); pchName = Helpers.MemoryToString( mempchName ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs index b1a39b8..ce4d1b5 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs @@ -256,7 +256,7 @@ namespace Steamworks #endregion internal bool GetEnteredGamepadTextInput( out string pchText ) { - IntPtr mempchText = Helpers.TakeMemory(); + using var mempchText = Helpers.TakeMemory(); var returnValue = _GetEnteredGamepadTextInput( Self, mempchText, (1024 * 32) ); pchText = Helpers.MemoryToString( mempchText ); return returnValue; @@ -370,7 +370,7 @@ namespace Steamworks #endregion internal int FilterText( TextFilteringContext eContext, SteamId sourceSteamID, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchInputMessage, out string pchOutFilteredText ) { - IntPtr mempchOutFilteredText = Helpers.TakeMemory(); + using var mempchOutFilteredText = Helpers.TakeMemory(); var returnValue = _FilterText( Self, eContext, sourceSteamID, pchInputMessage, mempchOutFilteredText, (1024 * 32) ); pchOutFilteredText = Helpers.MemoryToString( mempchOutFilteredText ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamVideo.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamVideo.cs index 0e462fd..bd4d029 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamVideo.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamVideo.cs @@ -60,7 +60,7 @@ namespace Steamworks #endregion internal bool GetOPFStringForApp( AppId unVideoAppID, out string pchBuffer, ref int pnBufferSize ) { - IntPtr mempchBuffer = Helpers.TakeMemory(); + using var mempchBuffer = Helpers.TakeMemory(); var returnValue = _GetOPFStringForApp( Self, unVideoAppID, mempchBuffer, ref pnBufferSize ); pchBuffer = Helpers.MemoryToString( mempchBuffer ); return returnValue; diff --git a/Facepunch.Steamworks/Generated/SteamEnums.cs b/Facepunch.Steamworks/Generated/SteamEnums.cs index 329672c..f87174e 100644 --- a/Facepunch.Steamworks/Generated/SteamEnums.cs +++ b/Facepunch.Steamworks/Generated/SteamEnums.cs @@ -756,7 +756,7 @@ namespace Steamworks // // ETextFilteringContext // - internal enum TextFilteringContext : int + public enum TextFilteringContext : int { Unknown = 0, GameContent = 1, diff --git a/Facepunch.Steamworks/Networking/BroadcastBufferManager.cs b/Facepunch.Steamworks/Networking/BroadcastBufferManager.cs index 9122c3f..ba0ccc2 100644 --- a/Facepunch.Steamworks/Networking/BroadcastBufferManager.cs +++ b/Facepunch.Steamworks/Networking/BroadcastBufferManager.cs @@ -60,7 +60,9 @@ namespace Steamworks private static readonly Dictionary ReferenceCounters = new Dictionary( 1024 ); - public static readonly IntPtr FreeFunctionPointer = Marshal.GetFunctionPointerForDelegate( Free ); + private static readonly FreeFn FreeFunctionPin = new FreeFn( Free ); + + public static readonly IntPtr FreeFunctionPointer = Marshal.GetFunctionPointerForDelegate( FreeFunctionPin ); public static IntPtr Get( int size, int referenceCount ) { diff --git a/Facepunch.Steamworks/Networking/NetAddress.cs b/Facepunch.Steamworks/Networking/NetAddress.cs index cc47166..09db1e8 100644 --- a/Facepunch.Steamworks/Networking/NetAddress.cs +++ b/Facepunch.Steamworks/Networking/NetAddress.cs @@ -147,7 +147,7 @@ namespace Steamworks.Data public override string ToString() { - var ptr = Helpers.TakeMemory(); + using var ptr = Helpers.TakeMemory(); var self = this; InternalToString( ref self, ptr, Helpers.MemoryBufferSize, true ); return Helpers.MemoryToString( ptr ); diff --git a/Facepunch.Steamworks/SteamFriends.cs b/Facepunch.Steamworks/SteamFriends.cs index a07199d..3a8d338 100644 --- a/Facepunch.Steamworks/SteamFriends.cs +++ b/Facepunch.Steamworks/SteamFriends.cs @@ -97,7 +97,7 @@ namespace Steamworks var friend = new Friend( data.SteamIDUser ); - var buffer = Helpers.TakeMemory(); + using var buffer = Helpers.TakeMemory(); var type = ChatEntryType.ChatMsg; var len = Internal.GetFriendMessage( data.SteamIDUser, data.MessageID, buffer, Helpers.MemoryBufferSize, ref type ); @@ -117,7 +117,7 @@ namespace Steamworks var friend = new Friend( data.SteamIDUser ); - var buffer = Helpers.TakeMemory(); + using var buffer = Helpers.TakeMemory(); var type = ChatEntryType.ChatMsg; SteamId chatter = data.SteamIDUser; diff --git a/Facepunch.Steamworks/SteamMatchmaking.cs b/Facepunch.Steamworks/SteamMatchmaking.cs index 9c5b2bf..3458fa6 100644 --- a/Facepunch.Steamworks/SteamMatchmaking.cs +++ b/Facepunch.Steamworks/SteamMatchmaking.cs @@ -72,7 +72,7 @@ namespace Steamworks { SteamId steamid = default; ChatEntryType chatEntryType = default; - var buffer = Helpers.TakeMemory(); + using var buffer = Helpers.TakeMemory(); var readData = Internal.GetLobbyChatEntry( callback.SteamIDLobby, (int)callback.ChatID, ref steamid, buffer, Helpers.MemoryBufferSize, ref chatEntryType ); diff --git a/Facepunch.Steamworks/SteamUgc.cs b/Facepunch.Steamworks/SteamUgc.cs index a36fb64..c727181 100644 --- a/Facepunch.Steamworks/SteamUgc.cs +++ b/Facepunch.Steamworks/SteamUgc.cs @@ -26,12 +26,22 @@ namespace Steamworks internal static void InstallEvents( bool server ) { Dispatch.Install( x => OnDownloadItemResult?.Invoke( x.Result ), server ); + Dispatch.Install( x => OnItemSubscribed?.Invoke( x.AppID.Value, x.PublishedFileId ), server ); + Dispatch.Install( x => OnItemUnsubscribed?.Invoke( x.AppID.Value, x.PublishedFileId ), server ); + Dispatch.Install( x => OnItemInstalled?.Invoke( x.AppID.Value, x.PublishedFileId ), server ); } /// /// Posted after Download call /// public static event Action OnDownloadItemResult; + + /// + /// Posted when new item is subscribed + /// + public static event Action OnItemSubscribed; + public static event Action OnItemUnsubscribed; + public static event Action OnItemInstalled; public static async Task DeleteFileAsync( PublishedFileId fileId ) { diff --git a/Facepunch.Steamworks/SteamUtils.cs b/Facepunch.Steamworks/SteamUtils.cs index 9d3eea0..8ca3f83 100644 --- a/Facepunch.Steamworks/SteamUtils.cs +++ b/Facepunch.Steamworks/SteamUtils.cs @@ -261,5 +261,21 @@ namespace Steamworks /// Returns whether this steam client is a Steam China specific client, vs the global client /// public static bool IsSteamChinaLauncher => Internal.IsSteamChinaLauncher(); + + /// + /// Initializes text filtering, loading dictionaries for the language the game is running in. + /// Users can customize the text filter behavior in their Steam Account preferences + /// + public static bool InitFilterText() => Internal.InitFilterText( 0 ); + + /// + /// Filters the provided input message and places the filtered result into pchOutFilteredText, + /// using legally required filtering and additional filtering based on the context and user settings. + /// + public string FilterText( TextFilteringContext context, SteamId sourceSteamID, string inputMessage ) + { + Internal.FilterText( context, sourceSteamID, inputMessage, out var filteredString ); + return filteredString; + } } } \ No newline at end of file diff --git a/Facepunch.Steamworks/Structs/UgcEditor.cs b/Facepunch.Steamworks/Structs/UgcEditor.cs index a6d47ce..ffd00f0 100644 --- a/Facepunch.Steamworks/Structs/UgcEditor.cs +++ b/Facepunch.Steamworks/Structs/UgcEditor.cs @@ -246,7 +246,7 @@ namespace Steamworks.Ugc case ItemUpdateStatus.UploadingContent: { var uploaded = total > 0 ? ((float)processed / (float)total) : 0.0f; - progress?.Report( 0.2f + uploaded * 0.7f ); + progress?.Report( 0.2f + uploaded * 0.6f ); break; } case ItemUpdateStatus.UploadingPreviewFile: diff --git a/Facepunch.Steamworks/Utility/Helpers.cs b/Facepunch.Steamworks/Utility/Helpers.cs index 5801905..3f481ce 100644 --- a/Facepunch.Steamworks/Utility/Helpers.cs +++ b/Facepunch.Steamworks/Utility/Helpers.cs @@ -9,30 +9,50 @@ namespace Steamworks { public const int MemoryBufferSize = 1024 * 32; - private static IntPtr[] MemoryPool = new IntPtr[] + internal struct Memory : IDisposable { - Marshal.AllocHGlobal( MemoryBufferSize ), - Marshal.AllocHGlobal( MemoryBufferSize ), - Marshal.AllocHGlobal( MemoryBufferSize ), - Marshal.AllocHGlobal( MemoryBufferSize ) - }; - private static int MemoryPoolIndex; + private const int MaxBagSize = 4; + private static readonly Queue BufferBag = new Queue(); - public static unsafe IntPtr TakeMemory() - { - lock ( MemoryPool ) + public IntPtr Ptr { get; private set; } + + public static implicit operator IntPtr(in Memory m) => m.Ptr; + + internal static unsafe Memory Take() { - MemoryPoolIndex++; - - if ( MemoryPoolIndex >= MemoryPool.Length ) - MemoryPoolIndex = 0; - - var take = MemoryPool[MemoryPoolIndex]; - - ((byte*)take)[0] = 0; - - return take; + IntPtr ptr; + lock (BufferBag) + { + ptr = BufferBag.Count > 0 ? BufferBag.Dequeue() : Marshal.AllocHGlobal(MemoryBufferSize); + } + ((byte*)ptr)[0] = 0; + return new Memory + { + Ptr = ptr + }; } + + public void Dispose() + { + if (Ptr == IntPtr.Zero) { return; } + lock (BufferBag) + { + if (BufferBag.Count < MaxBagSize) + { + BufferBag.Enqueue(Ptr); + } + else + { + Marshal.FreeHGlobal(Ptr); + } + } + Ptr = IntPtr.Zero; + } + } + + public static Memory TakeMemory() + { + return Memory.Take(); } diff --git a/Generator/App.config b/Generator/App.config deleted file mode 100644 index 88fa402..0000000 --- a/Generator/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Generator/Cleanup.cs b/Generator/Cleanup.cs index 77239ff..036699e 100644 --- a/Generator/Cleanup.cs +++ b/Generator/Cleanup.cs @@ -144,6 +144,7 @@ public static class Cleanup if ( name == "NetDebugOutput" ) return "public"; if ( name == "ItemPreviewType" ) return "public"; if ( name == "OverlayToStoreFlag" ) return "public"; + if ( name == "TextFilteringContext " ) return "public"; return "internal"; } diff --git a/Generator/CodeWriter/Interface.cs b/Generator/CodeWriter/Interface.cs index 1273cb9..790ec4c 100644 --- a/Generator/CodeWriter/Interface.cs +++ b/Generator/CodeWriter/Interface.cs @@ -152,7 +152,7 @@ namespace Generator { if ( arg is FetchStringType sb ) { - WriteLine( $"IntPtr mem{sb.VarName} = Helpers.TakeMemory();" ); + WriteLine( $"using var mem{sb.VarName} = Helpers.TakeMemory();" ); } } diff --git a/Generator/Generator.csproj b/Generator/Generator.csproj index 7e014e4..e1199b0 100644 --- a/Generator/Generator.csproj +++ b/Generator/Generator.csproj @@ -1,86 +1,13 @@ - - - + - Debug - AnyCPU - {B7225D11-2AAA-49D6-AE93-A73696EA35FE} + net6.0 Exe - Properties - Generator - Generator - v4.5.2 - 512 - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + 10 - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - True - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 77ad32f..fc5a999 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [Another fucking c# Steamworks implementation](https://wiki.facepunch.com/steamworks/) -![Build All](https://github.com/Facepunch/Facepunch.Steamworks/workflows/Build%20All/badge.svg) +![Build All](https://github.com/Crytilis/Facepunch.Steamworks/workflows/Build%20All/badge.svg) ## Features