mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 06:38:01 +03:00
Merge branch 'master' into workshop
This commit is contained in:
commit
3d4e367d3b
@ -21,17 +21,17 @@ namespace Facepunch.Steamworks.Test
|
||||
int unCompressed = 0;
|
||||
int compressed = 0;
|
||||
|
||||
client.Voice.OnCompressedData = ( ptr, length ) =>
|
||||
client.Voice.OnCompressedData = ( buffer, length ) =>
|
||||
{
|
||||
compressed += length;
|
||||
|
||||
if ( !client.Voice.Decompress( ptr, 0, length, decompressStream ) )
|
||||
if ( !client.Voice.Decompress( buffer, length, decompressStream ) )
|
||||
{
|
||||
Assert.Fail( "Decompress returned false" );
|
||||
}
|
||||
};
|
||||
|
||||
client.Voice.OnUncompressedData = ( ptr, length ) =>
|
||||
client.Voice.OnUncompressedData = ( buffer, length ) =>
|
||||
{
|
||||
unCompressed += length;
|
||||
};
|
||||
@ -62,7 +62,7 @@ namespace Facepunch.Steamworks.Test
|
||||
{
|
||||
int compressed = 0;
|
||||
|
||||
client.Voice.OnCompressedData = ( ptr, length ) =>
|
||||
client.Voice.OnCompressedData = ( buffer, length ) =>
|
||||
{
|
||||
compressed += length;
|
||||
};
|
||||
@ -89,7 +89,7 @@ namespace Facepunch.Steamworks.Test
|
||||
{
|
||||
int unCompressed = 0;
|
||||
|
||||
client.Voice.OnUncompressedData = ( ptr, length ) =>
|
||||
client.Voice.OnUncompressedData = ( buffer, length ) =>
|
||||
{
|
||||
unCompressed += length;
|
||||
};
|
||||
|
@ -108,15 +108,15 @@ namespace Facepunch.Steamworks
|
||||
/// </summary>
|
||||
public void UpdateWhile( Func<bool> func )
|
||||
{
|
||||
const int sleepMs = 1;
|
||||
|
||||
while ( func() )
|
||||
{
|
||||
Update();
|
||||
|
||||
const int waitPeriodMillis = 1;
|
||||
#if NETCORE
|
||||
System.Threading.Tasks.Task.Delay( waitPeriodMillis ).Wait();
|
||||
#if NET_CORE
|
||||
System.Threading.Tasks.Task.Delay( sleepMs ).Wait();
|
||||
#else
|
||||
System.Threading.Thread.Sleep( waitPeriodMillis );
|
||||
System.Threading.Thread.Sleep( sleepMs );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,9 @@ namespace Facepunch.Steamworks
|
||||
SteamId = native.user.GetSteamID();
|
||||
BetaName = native.apps.GetCurrentBetaName();
|
||||
OwnerSteamId = native.apps.GetAppOwner();
|
||||
InstallFolder = new DirectoryInfo( native.apps.GetAppInstallDir( AppId ) );
|
||||
var appInstallDir = native.apps.GetAppInstallDir(AppId);
|
||||
if (!String.IsNullOrEmpty(appInstallDir) && Directory.Exists(appInstallDir))
|
||||
InstallFolder = new DirectoryInfo(appInstallDir);
|
||||
BuildId = native.apps.GetAppBuildId();
|
||||
CurrentLanguage = native.apps.GetCurrentGameLanguage();
|
||||
AvailableLanguages = native.apps.GetAvailableGameLanguages().Split( new[] {';'}, StringSplitOptions.RemoveEmptyEntries ); // TODO: Assumed colon separated
|
||||
@ -156,7 +158,6 @@ namespace Facepunch.Steamworks
|
||||
{
|
||||
if ( Voice != null )
|
||||
{
|
||||
Voice.Dispose();
|
||||
Voice = null;
|
||||
}
|
||||
|
||||
|
@ -278,6 +278,19 @@ namespace Facepunch.Steamworks
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove this file from remote storage, while keeping a local copy.
|
||||
/// Writing to this file again will re-add it to the cloud.
|
||||
/// </summary>
|
||||
/// <returns>True if the file was forgotten</returns>
|
||||
public bool Forget()
|
||||
{
|
||||
if ( !Exists ) return false;
|
||||
if ( _isUgc ) return false;
|
||||
|
||||
return remoteStorage.native.FileForget( FileName );
|
||||
}
|
||||
|
||||
private void GetUGCDetails()
|
||||
{
|
||||
if ( !_isUgc ) throw new InvalidOperationException();
|
||||
|
@ -75,7 +75,7 @@ namespace Facepunch.Steamworks
|
||||
remoteStorage.native.FileWriteStreamCancel( _handle );
|
||||
}
|
||||
|
||||
#if NETCORE
|
||||
#if NET_CORE
|
||||
public void Close()
|
||||
#else
|
||||
public override void Close()
|
||||
|
@ -5,7 +5,7 @@ using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
#if !NETCORE
|
||||
#if !NET_CORE
|
||||
|
||||
internal class SourceServerQuery :IDisposable
|
||||
{
|
||||
|
@ -7,19 +7,19 @@ using System.Text;
|
||||
|
||||
namespace Facepunch.Steamworks
|
||||
{
|
||||
public class Voice : IDisposable
|
||||
public class Voice
|
||||
{
|
||||
const int ReadBufferSize = 1024 * 128;
|
||||
|
||||
internal Client client;
|
||||
|
||||
internal IntPtr ReadCompressedBuffer;
|
||||
internal IntPtr ReadUncompressedBuffer;
|
||||
internal byte[] ReadCompressedBuffer = new byte[ReadBufferSize];
|
||||
internal byte[] ReadUncompressedBuffer = new byte[ReadBufferSize];
|
||||
|
||||
internal byte[] UncompressBuffer = new byte[1024 * 256];
|
||||
|
||||
public Action<IntPtr, int> OnCompressedData;
|
||||
public Action<IntPtr, int> OnUncompressedData;
|
||||
public Action<byte[], int> OnCompressedData;
|
||||
public Action<byte[], int> OnUncompressedData;
|
||||
|
||||
private System.Diagnostics.Stopwatch UpdateTimer = System.Diagnostics.Stopwatch.StartNew();
|
||||
|
||||
@ -73,21 +73,12 @@ namespace Facepunch.Steamworks
|
||||
internal Voice( Client client )
|
||||
{
|
||||
this.client = client;
|
||||
|
||||
ReadCompressedBuffer = Marshal.AllocHGlobal( ReadBufferSize );
|
||||
ReadUncompressedBuffer = Marshal.AllocHGlobal( ReadBufferSize );
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Marshal.FreeHGlobal( ReadCompressedBuffer );
|
||||
Marshal.FreeHGlobal( ReadUncompressedBuffer );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This gets called inside Update - so there's no need to call this manually if you're calling update
|
||||
/// </summary>
|
||||
public void Update()
|
||||
public unsafe void Update()
|
||||
{
|
||||
if ( OnCompressedData == null && OnUncompressedData == null )
|
||||
return;
|
||||
@ -109,9 +100,13 @@ namespace Facepunch.Steamworks
|
||||
return;
|
||||
}
|
||||
|
||||
result = client.native.user.GetVoice( OnCompressedData != null, ReadCompressedBuffer, ReadBufferSize, out bufferCompressedLastWrite,
|
||||
OnUncompressedData != null, (IntPtr) ReadUncompressedBuffer, ReadBufferSize, out bufferRegularLastWrite,
|
||||
DesiredSampleRate == 0 ? OptimalSampleRate : DesiredSampleRate );
|
||||
fixed (byte* compressedPtr = ReadCompressedBuffer)
|
||||
fixed (byte* uncompressedPtr = ReadUncompressedBuffer)
|
||||
{
|
||||
result = client.native.user.GetVoice( OnCompressedData != null, (IntPtr) compressedPtr, ReadBufferSize, out bufferCompressedLastWrite,
|
||||
OnUncompressedData != null, (IntPtr) uncompressedPtr, ReadBufferSize, out bufferRegularLastWrite,
|
||||
DesiredSampleRate == 0 ? OptimalSampleRate : DesiredSampleRate );
|
||||
}
|
||||
|
||||
IsRecording = true;
|
||||
|
||||
@ -136,15 +131,31 @@ namespace Facepunch.Steamworks
|
||||
|
||||
}
|
||||
|
||||
public unsafe bool Decompress( byte[] input, MemoryStream output, uint samepleRate = 0 )
|
||||
public bool Decompress( byte[] input, MemoryStream output, uint samepleRate = 0 )
|
||||
{
|
||||
return Decompress( input, 0, input.Length, output, samepleRate );
|
||||
}
|
||||
|
||||
public bool Decompress( byte[] input, int inputsize, MemoryStream output, uint samepleRate = 0 )
|
||||
{
|
||||
return Decompress( input, 0, inputsize, output, samepleRate );
|
||||
}
|
||||
|
||||
public unsafe bool Decompress( byte[] input, int inputoffset, int inputsize, MemoryStream output, uint samepleRate = 0 )
|
||||
{
|
||||
if ( inputoffset < 0 || inputoffset >= input.Length )
|
||||
throw new ArgumentOutOfRangeException( "inputoffset" );
|
||||
|
||||
if ( inputsize <= 0 || inputoffset + inputsize > input.Length )
|
||||
throw new ArgumentOutOfRangeException( "inputsize" );
|
||||
|
||||
fixed ( byte* p = input )
|
||||
{
|
||||
return Decompress( (IntPtr)p, 0, input.Length, output, samepleRate );
|
||||
return Decompress( (IntPtr)p, inputoffset, inputsize, output, samepleRate );
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe bool Decompress( IntPtr input, int inputoffset, int inputsize, MemoryStream output, uint samepleRate = 0 )
|
||||
private unsafe bool Decompress( IntPtr input, int inputoffset, int inputsize, MemoryStream output, uint samepleRate = 0 )
|
||||
{
|
||||
if ( samepleRate == 0 )
|
||||
samepleRate = OptimalSampleRate;
|
||||
|
@ -22,11 +22,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
|
||||
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);NET_CORE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="*AssemblyInfo.cs"/>
|
||||
<Compile Remove="*AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
@ -263,15 +263,16 @@ namespace Facepunch.Steamworks
|
||||
/// </summary>
|
||||
public void Block()
|
||||
{
|
||||
const int sleepMs = 10;
|
||||
|
||||
workshop.steamworks.Update();
|
||||
|
||||
while ( IsRunning )
|
||||
{
|
||||
const int waitPeriodMillis = 10;
|
||||
#if NETCORE
|
||||
System.Threading.Tasks.Task.Delay( waitPeriodMillis ).Wait();
|
||||
#if NET_CORE
|
||||
System.Threading.Tasks.Task.Delay( sleepMs ).Wait();
|
||||
#else
|
||||
System.Threading.Thread.Sleep( waitPeriodMillis );
|
||||
System.Threading.Thread.Sleep( sleepMs );
|
||||
#endif
|
||||
workshop.steamworks.Update();
|
||||
}
|
||||
|
@ -71,9 +71,9 @@ namespace Facepunch.Steamworks.Interop
|
||||
ThisVTable.InternalRulesFailedToRespond db = ( _ ) => InternalOnRulesFailedToRespond();
|
||||
ThisVTable.InternalRulesRefreshComplete dc = ( _ ) => InternalOnRulesRefreshComplete();
|
||||
|
||||
RulesRespondPin = GCHandle.Alloc( da );
|
||||
FailedRespondPin = GCHandle.Alloc( db );
|
||||
CompletePin = GCHandle.Alloc( dc );
|
||||
RulesRespondPin = GCHandle.Alloc( da, GCHandleType.Pinned );
|
||||
FailedRespondPin = GCHandle.Alloc( db, GCHandleType.Pinned );
|
||||
CompletePin = GCHandle.Alloc( dc, GCHandleType.Pinned );
|
||||
|
||||
var t = new ThisVTable()
|
||||
{
|
||||
@ -93,9 +93,9 @@ namespace Facepunch.Steamworks.Interop
|
||||
StdVTable.InternalRulesFailedToRespond db = InternalOnRulesFailedToRespond;
|
||||
StdVTable.InternalRulesRefreshComplete dc = InternalOnRulesRefreshComplete;
|
||||
|
||||
RulesRespondPin = GCHandle.Alloc( da );
|
||||
FailedRespondPin = GCHandle.Alloc( db );
|
||||
CompletePin = GCHandle.Alloc( dc );
|
||||
RulesRespondPin = GCHandle.Alloc( da, GCHandleType.Pinned );
|
||||
FailedRespondPin = GCHandle.Alloc( db, GCHandleType.Pinned );
|
||||
CompletePin = GCHandle.Alloc( dc, GCHandleType.Pinned );
|
||||
|
||||
var t = new StdVTable()
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#if !NETCORE
|
||||
#if !NET_CORE
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
|
@ -37,7 +37,7 @@ namespace SteamNative
|
||||
{
|
||||
_os = Facepunch.Steamworks.OperatingSystem.Windows;
|
||||
|
||||
#if !NETCORE
|
||||
#if !NET_CORE
|
||||
//
|
||||
// These checks aren't so accurate on older versions of mono
|
||||
//
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -317,9 +317,9 @@ namespace Generator
|
||||
WriteLine( "//" );
|
||||
WriteLine( "// Allocate a handle to each function, so they don't get disposed" );
|
||||
WriteLine( "//" );
|
||||
WriteLine( "handle.FuncA = GCHandle.Alloc( funcA );" );
|
||||
WriteLine( "handle.FuncB = GCHandle.Alloc( funcB );" );
|
||||
WriteLine( "handle.FuncC = GCHandle.Alloc( funcC );" );
|
||||
WriteLine( "handle.FuncA = GCHandle.Alloc( funcA, GCHandleType.Pinned );" );
|
||||
WriteLine( "handle.FuncB = GCHandle.Alloc( funcB, GCHandleType.Pinned );" );
|
||||
WriteLine( "handle.FuncC = GCHandle.Alloc( funcC, GCHandleType.Pinned );" );
|
||||
WriteLine();
|
||||
|
||||
WriteLine( "//" );
|
||||
|
@ -63,7 +63,11 @@ Or use it in a using block if you can.
|
||||
To create a server do this.
|
||||
|
||||
```csharp
|
||||
var server = new Facepunch.Steamworks.Server( 252490, 0, 28015, true, "MyGame453" );
|
||||
ServerInit options = new ServerInit("GameDirectoryName", "GameDescription");
|
||||
```
|
||||
|
||||
```csharp
|
||||
var server = new Facepunch.Steamworks.Server(252490, options);
|
||||
```
|
||||
|
||||
This will register a secure server for game 252490, any ip, port 28015. Again, more usage in the Facepunch.Steamworks.Test project.
|
||||
@ -108,7 +112,7 @@ The TLDR is before you create the Client or the Server, call this to let Facepun
|
||||
Facepunch.Steamworks.Config.ForUnity( Application.platform.ToString() );
|
||||
```
|
||||
|
||||
You'll also want to put steam_api64.dll and steam_appid.txt (on windows 64) in your project root next to Assets.
|
||||
You'll also want to put steam_api64.dll and steam_appid.txt (on windows 64) in your project root next to Assets, and use an editor script like [this](https://github.com/Facepunch/Facepunch.Steamworks.Unity/blob/master/Assets/Scripts/Editor/CopySteamLibraries.cs) to copy them into standalone builds.
|
||||
|
||||
# Help
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user