mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-26 14:45:51 +03:00
BaseSteamInterface open interfaces as server if no client
This commit is contained in:
parent
a4f446d009
commit
28e8f261e2
@ -18,19 +18,22 @@ internal abstract class BaseSteamInterface
|
|||||||
|
|
||||||
public BaseSteamInterface( bool server = false )
|
public BaseSteamInterface( bool server = false )
|
||||||
{
|
{
|
||||||
var hUser = server ? SteamApi.SteamGameServer_GetHSteamUser() : SteamApi.GetHSteamUser();
|
//
|
||||||
|
// If teh client isn't initialized but the server is,
|
||||||
|
// try to open this interface in server mode
|
||||||
|
//
|
||||||
|
if ( !SteamClient.IsValid && SteamServer.IsValid ) server = true;
|
||||||
|
|
||||||
|
var hUser = server ?
|
||||||
|
SteamApi.SteamGameServer_GetHSteamUser() :
|
||||||
|
SteamApi.GetHSteamUser();
|
||||||
|
|
||||||
if ( hUser == 0 )
|
if ( hUser == 0 )
|
||||||
throw new System.Exception( "Steamworks is uninitialized" );
|
throw new System.Exception( "Steamworks is uninitialized" );
|
||||||
|
|
||||||
if ( server )
|
Self = server ?
|
||||||
{
|
SteamInternal.FindOrCreateGameServerInterface( hUser, InterfaceName ) :
|
||||||
Self = SteamInternal.FindOrCreateGameServerInterface( hUser, InterfaceName );
|
SteamInternal.FindOrCreateUserInterface( hUser, InterfaceName );
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Self = SteamInternal.FindOrCreateUserInterface( hUser, InterfaceName );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( Self == IntPtr.Zero )
|
if ( Self == IntPtr.Zero )
|
||||||
throw new System.Exception( $"Couldn't find interface {InterfaceName} (server:{server})" );
|
throw new System.Exception( $"Couldn't find interface {InterfaceName} (server:{server})" );
|
||||||
@ -45,6 +48,10 @@ public BaseSteamInterface( bool server = false )
|
|||||||
|
|
||||||
public abstract void InitInternals();
|
public abstract void InitInternals();
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Dedicated string conversion buffer
|
||||||
|
//
|
||||||
static byte[] stringbuffer = new byte[1024 * 128];
|
static byte[] stringbuffer = new byte[1024 * 128];
|
||||||
|
|
||||||
internal string GetString( IntPtr p )
|
internal string GetString( IntPtr p )
|
||||||
|
Loading…
Reference in New Issue
Block a user