mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 14:48:02 +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 unCompressed = 0;
|
||||||
int compressed = 0;
|
int compressed = 0;
|
||||||
|
|
||||||
client.Voice.OnCompressedData = ( ptr, length ) =>
|
client.Voice.OnCompressedData = ( buffer, length ) =>
|
||||||
{
|
{
|
||||||
compressed += length;
|
compressed += length;
|
||||||
|
|
||||||
if ( !client.Voice.Decompress( ptr, 0, length, decompressStream ) )
|
if ( !client.Voice.Decompress( buffer, length, decompressStream ) )
|
||||||
{
|
{
|
||||||
Assert.Fail( "Decompress returned false" );
|
Assert.Fail( "Decompress returned false" );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
client.Voice.OnUncompressedData = ( ptr, length ) =>
|
client.Voice.OnUncompressedData = ( buffer, length ) =>
|
||||||
{
|
{
|
||||||
unCompressed += length;
|
unCompressed += length;
|
||||||
};
|
};
|
||||||
@ -62,7 +62,7 @@ namespace Facepunch.Steamworks.Test
|
|||||||
{
|
{
|
||||||
int compressed = 0;
|
int compressed = 0;
|
||||||
|
|
||||||
client.Voice.OnCompressedData = ( ptr, length ) =>
|
client.Voice.OnCompressedData = ( buffer, length ) =>
|
||||||
{
|
{
|
||||||
compressed += length;
|
compressed += length;
|
||||||
};
|
};
|
||||||
@ -89,7 +89,7 @@ namespace Facepunch.Steamworks.Test
|
|||||||
{
|
{
|
||||||
int unCompressed = 0;
|
int unCompressed = 0;
|
||||||
|
|
||||||
client.Voice.OnUncompressedData = ( ptr, length ) =>
|
client.Voice.OnUncompressedData = ( buffer, length ) =>
|
||||||
{
|
{
|
||||||
unCompressed += length;
|
unCompressed += length;
|
||||||
};
|
};
|
||||||
|
@ -108,15 +108,15 @@ namespace Facepunch.Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void UpdateWhile( Func<bool> func )
|
public void UpdateWhile( Func<bool> func )
|
||||||
{
|
{
|
||||||
|
const int sleepMs = 1;
|
||||||
|
|
||||||
while ( func() )
|
while ( func() )
|
||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
|
#if NET_CORE
|
||||||
const int waitPeriodMillis = 1;
|
System.Threading.Tasks.Task.Delay( sleepMs ).Wait();
|
||||||
#if NETCORE
|
|
||||||
System.Threading.Tasks.Task.Delay( waitPeriodMillis ).Wait();
|
|
||||||
#else
|
#else
|
||||||
System.Threading.Thread.Sleep( waitPeriodMillis );
|
System.Threading.Thread.Sleep( sleepMs );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,9 @@ namespace Facepunch.Steamworks
|
|||||||
SteamId = native.user.GetSteamID();
|
SteamId = native.user.GetSteamID();
|
||||||
BetaName = native.apps.GetCurrentBetaName();
|
BetaName = native.apps.GetCurrentBetaName();
|
||||||
OwnerSteamId = native.apps.GetAppOwner();
|
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();
|
BuildId = native.apps.GetAppBuildId();
|
||||||
CurrentLanguage = native.apps.GetCurrentGameLanguage();
|
CurrentLanguage = native.apps.GetCurrentGameLanguage();
|
||||||
AvailableLanguages = native.apps.GetAvailableGameLanguages().Split( new[] {';'}, StringSplitOptions.RemoveEmptyEntries ); // TODO: Assumed colon separated
|
AvailableLanguages = native.apps.GetAvailableGameLanguages().Split( new[] {';'}, StringSplitOptions.RemoveEmptyEntries ); // TODO: Assumed colon separated
|
||||||
@ -156,7 +158,6 @@ namespace Facepunch.Steamworks
|
|||||||
{
|
{
|
||||||
if ( Voice != null )
|
if ( Voice != null )
|
||||||
{
|
{
|
||||||
Voice.Dispose();
|
|
||||||
Voice = null;
|
Voice = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,6 +278,19 @@ namespace Facepunch.Steamworks
|
|||||||
return true;
|
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()
|
private void GetUGCDetails()
|
||||||
{
|
{
|
||||||
if ( !_isUgc ) throw new InvalidOperationException();
|
if ( !_isUgc ) throw new InvalidOperationException();
|
||||||
|
@ -75,7 +75,7 @@ namespace Facepunch.Steamworks
|
|||||||
remoteStorage.native.FileWriteStreamCancel( _handle );
|
remoteStorage.native.FileWriteStreamCancel( _handle );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NETCORE
|
#if NET_CORE
|
||||||
public void Close()
|
public void Close()
|
||||||
#else
|
#else
|
||||||
public override void Close()
|
public override void Close()
|
||||||
|
@ -5,7 +5,7 @@ using System.Net;
|
|||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
#if !NETCORE
|
#if !NET_CORE
|
||||||
|
|
||||||
internal class SourceServerQuery :IDisposable
|
internal class SourceServerQuery :IDisposable
|
||||||
{
|
{
|
||||||
|
@ -7,19 +7,19 @@ using System.Text;
|
|||||||
|
|
||||||
namespace Facepunch.Steamworks
|
namespace Facepunch.Steamworks
|
||||||
{
|
{
|
||||||
public class Voice : IDisposable
|
public class Voice
|
||||||
{
|
{
|
||||||
const int ReadBufferSize = 1024 * 128;
|
const int ReadBufferSize = 1024 * 128;
|
||||||
|
|
||||||
internal Client client;
|
internal Client client;
|
||||||
|
|
||||||
internal IntPtr ReadCompressedBuffer;
|
internal byte[] ReadCompressedBuffer = new byte[ReadBufferSize];
|
||||||
internal IntPtr ReadUncompressedBuffer;
|
internal byte[] ReadUncompressedBuffer = new byte[ReadBufferSize];
|
||||||
|
|
||||||
internal byte[] UncompressBuffer = new byte[1024 * 256];
|
internal byte[] UncompressBuffer = new byte[1024 * 256];
|
||||||
|
|
||||||
public Action<IntPtr, int> OnCompressedData;
|
public Action<byte[], int> OnCompressedData;
|
||||||
public Action<IntPtr, int> OnUncompressedData;
|
public Action<byte[], int> OnUncompressedData;
|
||||||
|
|
||||||
private System.Diagnostics.Stopwatch UpdateTimer = System.Diagnostics.Stopwatch.StartNew();
|
private System.Diagnostics.Stopwatch UpdateTimer = System.Diagnostics.Stopwatch.StartNew();
|
||||||
|
|
||||||
@ -73,21 +73,12 @@ namespace Facepunch.Steamworks
|
|||||||
internal Voice( Client client )
|
internal Voice( Client client )
|
||||||
{
|
{
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
|
||||||
ReadCompressedBuffer = Marshal.AllocHGlobal( ReadBufferSize );
|
|
||||||
ReadUncompressedBuffer = Marshal.AllocHGlobal( ReadBufferSize );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Marshal.FreeHGlobal( ReadCompressedBuffer );
|
|
||||||
Marshal.FreeHGlobal( ReadUncompressedBuffer );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This gets called inside Update - so there's no need to call this manually if you're calling update
|
/// This gets called inside Update - so there's no need to call this manually if you're calling update
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Update()
|
public unsafe void Update()
|
||||||
{
|
{
|
||||||
if ( OnCompressedData == null && OnUncompressedData == null )
|
if ( OnCompressedData == null && OnUncompressedData == null )
|
||||||
return;
|
return;
|
||||||
@ -109,9 +100,13 @@ namespace Facepunch.Steamworks
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = client.native.user.GetVoice( OnCompressedData != null, ReadCompressedBuffer, ReadBufferSize, out bufferCompressedLastWrite,
|
fixed (byte* compressedPtr = ReadCompressedBuffer)
|
||||||
OnUncompressedData != null, (IntPtr) ReadUncompressedBuffer, ReadBufferSize, out bufferRegularLastWrite,
|
fixed (byte* uncompressedPtr = ReadUncompressedBuffer)
|
||||||
DesiredSampleRate == 0 ? OptimalSampleRate : DesiredSampleRate );
|
{
|
||||||
|
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;
|
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 )
|
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 )
|
if ( samepleRate == 0 )
|
||||||
samepleRate = OptimalSampleRate;
|
samepleRate = OptimalSampleRate;
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
|
||||||
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
|
<DefineConstants>$(DefineConstants);NET_CORE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="*AssemblyInfo.cs"/>
|
<Compile Remove="*AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
@ -263,15 +263,16 @@ namespace Facepunch.Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Block()
|
public void Block()
|
||||||
{
|
{
|
||||||
|
const int sleepMs = 10;
|
||||||
|
|
||||||
workshop.steamworks.Update();
|
workshop.steamworks.Update();
|
||||||
|
|
||||||
while ( IsRunning )
|
while ( IsRunning )
|
||||||
{
|
{
|
||||||
const int waitPeriodMillis = 10;
|
#if NET_CORE
|
||||||
#if NETCORE
|
System.Threading.Tasks.Task.Delay( sleepMs ).Wait();
|
||||||
System.Threading.Tasks.Task.Delay( waitPeriodMillis ).Wait();
|
|
||||||
#else
|
#else
|
||||||
System.Threading.Thread.Sleep( waitPeriodMillis );
|
System.Threading.Thread.Sleep( sleepMs );
|
||||||
#endif
|
#endif
|
||||||
workshop.steamworks.Update();
|
workshop.steamworks.Update();
|
||||||
}
|
}
|
||||||
|
@ -71,9 +71,9 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
ThisVTable.InternalRulesFailedToRespond db = ( _ ) => InternalOnRulesFailedToRespond();
|
ThisVTable.InternalRulesFailedToRespond db = ( _ ) => InternalOnRulesFailedToRespond();
|
||||||
ThisVTable.InternalRulesRefreshComplete dc = ( _ ) => InternalOnRulesRefreshComplete();
|
ThisVTable.InternalRulesRefreshComplete dc = ( _ ) => InternalOnRulesRefreshComplete();
|
||||||
|
|
||||||
RulesRespondPin = GCHandle.Alloc( da );
|
RulesRespondPin = GCHandle.Alloc( da, GCHandleType.Pinned );
|
||||||
FailedRespondPin = GCHandle.Alloc( db );
|
FailedRespondPin = GCHandle.Alloc( db, GCHandleType.Pinned );
|
||||||
CompletePin = GCHandle.Alloc( dc );
|
CompletePin = GCHandle.Alloc( dc, GCHandleType.Pinned );
|
||||||
|
|
||||||
var t = new ThisVTable()
|
var t = new ThisVTable()
|
||||||
{
|
{
|
||||||
@ -93,9 +93,9 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
StdVTable.InternalRulesFailedToRespond db = InternalOnRulesFailedToRespond;
|
StdVTable.InternalRulesFailedToRespond db = InternalOnRulesFailedToRespond;
|
||||||
StdVTable.InternalRulesRefreshComplete dc = InternalOnRulesRefreshComplete;
|
StdVTable.InternalRulesRefreshComplete dc = InternalOnRulesRefreshComplete;
|
||||||
|
|
||||||
RulesRespondPin = GCHandle.Alloc( da );
|
RulesRespondPin = GCHandle.Alloc( da, GCHandleType.Pinned );
|
||||||
FailedRespondPin = GCHandle.Alloc( db );
|
FailedRespondPin = GCHandle.Alloc( db, GCHandleType.Pinned );
|
||||||
CompletePin = GCHandle.Alloc( dc );
|
CompletePin = GCHandle.Alloc( dc, GCHandleType.Pinned );
|
||||||
|
|
||||||
var t = new StdVTable()
|
var t = new StdVTable()
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
#if !NETCORE
|
#if !NET_CORE
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
@ -37,7 +37,7 @@ namespace SteamNative
|
|||||||
{
|
{
|
||||||
_os = Facepunch.Steamworks.OperatingSystem.Windows;
|
_os = Facepunch.Steamworks.OperatingSystem.Windows;
|
||||||
|
|
||||||
#if !NETCORE
|
#if !NET_CORE
|
||||||
//
|
//
|
||||||
// These checks aren't so accurate on older versions of mono
|
// 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( "//" );
|
||||||
WriteLine( "// Allocate a handle to each function, so they don't get disposed" );
|
WriteLine( "// Allocate a handle to each function, so they don't get disposed" );
|
||||||
WriteLine( "//" );
|
WriteLine( "//" );
|
||||||
WriteLine( "handle.FuncA = GCHandle.Alloc( funcA );" );
|
WriteLine( "handle.FuncA = GCHandle.Alloc( funcA, GCHandleType.Pinned );" );
|
||||||
WriteLine( "handle.FuncB = GCHandle.Alloc( funcB );" );
|
WriteLine( "handle.FuncB = GCHandle.Alloc( funcB, GCHandleType.Pinned );" );
|
||||||
WriteLine( "handle.FuncC = GCHandle.Alloc( funcC );" );
|
WriteLine( "handle.FuncC = GCHandle.Alloc( funcC, GCHandleType.Pinned );" );
|
||||||
WriteLine();
|
WriteLine();
|
||||||
|
|
||||||
WriteLine( "//" );
|
WriteLine( "//" );
|
||||||
|
@ -63,7 +63,11 @@ Or use it in a using block if you can.
|
|||||||
To create a server do this.
|
To create a server do this.
|
||||||
|
|
||||||
```csharp
|
```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.
|
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() );
|
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
|
# Help
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user