mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-26 06:35:49 +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 )
|
||||
{
|
||||
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 )
|
||||
throw new System.Exception( "Steamworks is uninitialized" );
|
||||
|
||||
if ( server )
|
||||
{
|
||||
Self = SteamInternal.FindOrCreateGameServerInterface( hUser, InterfaceName );
|
||||
}
|
||||
else
|
||||
{
|
||||
Self = SteamInternal.FindOrCreateUserInterface( hUser, InterfaceName );
|
||||
}
|
||||
Self = server ?
|
||||
SteamInternal.FindOrCreateGameServerInterface( hUser, InterfaceName ) :
|
||||
SteamInternal.FindOrCreateUserInterface( hUser, InterfaceName );
|
||||
|
||||
if ( Self == IntPtr.Zero )
|
||||
throw new System.Exception( $"Couldn't find interface {InterfaceName} (server:{server})" );
|
||||
@ -45,6 +48,10 @@ public BaseSteamInterface( bool server = false )
|
||||
|
||||
public abstract void InitInternals();
|
||||
|
||||
|
||||
//
|
||||
// Dedicated string conversion buffer
|
||||
//
|
||||
static byte[] stringbuffer = new byte[1024 * 128];
|
||||
|
||||
internal string GetString( IntPtr p )
|
||||
|
Loading…
Reference in New Issue
Block a user