mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-13 23:28:11 +03:00
Update how interfaces are initialized so we can initialize userless
This commit is contained in:
parent
87ff387ca6
commit
1c1925bae9
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamApps : SteamInterface
|
||||
{
|
||||
public ISteamApps( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "STEAMAPPS_INTERFACE_VERSION008";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamFriends : SteamInterface
|
||||
{
|
||||
public ISteamFriends( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "SteamFriends017";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamGameServer : SteamInterface
|
||||
{
|
||||
public ISteamGameServer( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "SteamGameServer012";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamInventory : SteamInterface
|
||||
{
|
||||
public ISteamInventory( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "STEAMINVENTORY_INTERFACE_V003";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamMatchmaking : SteamInterface
|
||||
{
|
||||
public ISteamMatchmaking( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "SteamMatchMaking009";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamMatchmakingServers : SteamInterface
|
||||
{
|
||||
public ISteamMatchmakingServers( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "SteamMatchMakingServers002";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamMusic : SteamInterface
|
||||
{
|
||||
public ISteamMusic( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "STEAMMUSIC_INTERFACE_VERSION001";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamNetworking : SteamInterface
|
||||
{
|
||||
public ISteamNetworking( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "SteamNetworking005";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamNetworkingUtils : SteamInterface
|
||||
{
|
||||
public ISteamNetworkingUtils( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "SteamNetworkingUtils001";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamParentalSettings : SteamInterface
|
||||
{
|
||||
public ISteamParentalSettings( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "STEAMPARENTALSETTINGS_INTERFACE_VERSION001";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamParties : SteamInterface
|
||||
{
|
||||
public ISteamParties( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "SteamParties002";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamRemoteStorage : SteamInterface
|
||||
{
|
||||
public ISteamRemoteStorage( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "STEAMREMOTESTORAGE_INTERFACE_VERSION014";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamScreenshots : SteamInterface
|
||||
{
|
||||
public ISteamScreenshots( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "STEAMSCREENSHOTS_INTERFACE_VERSION003";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamUGC : SteamInterface
|
||||
{
|
||||
public ISteamUGC( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "STEAMUGC_INTERFACE_VERSION012";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamUser : SteamInterface
|
||||
{
|
||||
public ISteamUser( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "SteamUser020";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamUserStats : SteamInterface
|
||||
{
|
||||
public ISteamUserStats( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "STEAMUSERSTATS_INTERFACE_VERSION011";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamUtils : SteamInterface
|
||||
{
|
||||
public ISteamUtils( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "SteamUtils009";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
||||
{
|
||||
internal class ISteamVideo : SteamInterface
|
||||
{
|
||||
public ISteamVideo( bool server = false ) : base( server )
|
||||
{
|
||||
}
|
||||
|
||||
public override string InterfaceName => "STEAMVIDEO_INTERFACE_V002";
|
||||
|
||||
public override void InitInternals()
|
||||
|
@ -18,7 +18,10 @@ namespace Steamworks.ServerList
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamMatchmakingServers();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -19,7 +19,10 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamApps();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ namespace Steamworks
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamFriends();
|
||||
_internal.InitClient();
|
||||
|
||||
richPresence = new Dictionary<string, string>();
|
||||
}
|
||||
|
@ -20,7 +20,10 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamInventory();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -18,7 +18,10 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamMatchmaking();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -21,7 +21,10 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamMusic();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -16,7 +16,10 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamNetworking();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -18,7 +18,10 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamParentalSettings();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -15,7 +15,10 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamParties();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -18,7 +18,10 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamRemoteStorage();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -18,7 +18,10 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamScreenshots();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -20,7 +20,10 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
_internal = new ISteamGameServer( true );
|
||||
{
|
||||
_internal = new ISteamGameServer( );
|
||||
_internal.InitServer();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -17,7 +17,10 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamInventory();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ namespace Steamworks
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamUGC();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
|
@ -22,6 +22,7 @@ namespace Steamworks
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamUser();
|
||||
_internal.InitClient();
|
||||
|
||||
richPresence = new Dictionary<string, string>();
|
||||
|
||||
|
@ -17,6 +17,8 @@ namespace Steamworks
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamUserStats();
|
||||
_internal.InitClient();
|
||||
|
||||
RequestCurrentStats();
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,10 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamUtils();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -18,7 +18,10 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamVideo();
|
||||
_internal.InitClient();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
@ -16,28 +16,42 @@ namespace Steamworks
|
||||
|
||||
public virtual string InterfaceName => null;
|
||||
|
||||
public SteamInterface( bool server = false )
|
||||
public virtual void InitClient()
|
||||
{
|
||||
//
|
||||
// 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 ?
|
||||
SteamGameServer.GetHSteamUser() :
|
||||
SteamAPI.GetHSteamUser();
|
||||
|
||||
if ( hUser == 0 )
|
||||
throw new System.Exception( "Steamworks is uninitialized" );
|
||||
|
||||
Self = server ?
|
||||
SteamInternal.FindOrCreateGameServerInterface( hUser, InterfaceName ) :
|
||||
SteamInternal.FindOrCreateUserInterface( hUser, InterfaceName );
|
||||
var user = SteamAPI.GetHSteamUser();
|
||||
Self = SteamInternal.FindOrCreateUserInterface( user, InterfaceName );
|
||||
|
||||
if ( Self == IntPtr.Zero )
|
||||
throw new System.Exception( $"Couldn't find interface {InterfaceName} (server:{server})" );
|
||||
throw new System.Exception( $"Couldn't find interface {InterfaceName}" );
|
||||
|
||||
VTable = Marshal.ReadIntPtr( Self, 0 );
|
||||
if ( Self == IntPtr.Zero )
|
||||
throw new System.Exception( $"Invalid VTable for {InterfaceName}" );
|
||||
|
||||
InitInternals();
|
||||
}
|
||||
|
||||
public virtual void InitServer()
|
||||
{
|
||||
var user = SteamGameServer.GetHSteamUser();
|
||||
Self = SteamInternal.FindOrCreateGameServerInterface( user, InterfaceName );
|
||||
|
||||
if ( Self == IntPtr.Zero )
|
||||
throw new System.Exception( $"Couldn't find server interface {InterfaceName}" );
|
||||
|
||||
VTable = Marshal.ReadIntPtr( Self, 0 );
|
||||
if ( Self == IntPtr.Zero )
|
||||
throw new System.Exception( $"Invalid VTable for server {InterfaceName}" );
|
||||
|
||||
InitInternals();
|
||||
}
|
||||
|
||||
public virtual void InitUserless()
|
||||
{
|
||||
Self = SteamInternal.FindOrCreateUserInterface( 0, InterfaceName );
|
||||
|
||||
if ( Self == IntPtr.Zero )
|
||||
throw new System.Exception( $"Couldn't find interface {InterfaceName}" );
|
||||
|
||||
VTable = Marshal.ReadIntPtr( Self, 0 );
|
||||
if ( Self == IntPtr.Zero )
|
||||
|
@ -27,13 +27,6 @@ namespace Generator
|
||||
{
|
||||
StartBlock( $"internal class {clss.Name} : SteamInterface" );
|
||||
{
|
||||
StartBlock( $"public {clss.Name}( bool server = false ) : base( server )" );
|
||||
{
|
||||
|
||||
}
|
||||
EndBlock();
|
||||
WriteLine();
|
||||
|
||||
WriteLine( $"public override string InterfaceName => \"{clss.InterfaceString}\";" );
|
||||
WriteLine();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user