mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-14 15:48:06 +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
|
internal class ISteamApps : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamApps( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "STEAMAPPS_INTERFACE_VERSION008";
|
public override string InterfaceName => "STEAMAPPS_INTERFACE_VERSION008";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamFriends : SteamInterface
|
internal class ISteamFriends : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamFriends( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "SteamFriends017";
|
public override string InterfaceName => "SteamFriends017";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamGameServer : SteamInterface
|
internal class ISteamGameServer : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamGameServer( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "SteamGameServer012";
|
public override string InterfaceName => "SteamGameServer012";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamInventory : SteamInterface
|
internal class ISteamInventory : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamInventory( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "STEAMINVENTORY_INTERFACE_V003";
|
public override string InterfaceName => "STEAMINVENTORY_INTERFACE_V003";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamMatchmaking : SteamInterface
|
internal class ISteamMatchmaking : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamMatchmaking( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "SteamMatchMaking009";
|
public override string InterfaceName => "SteamMatchMaking009";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamMatchmakingServers : SteamInterface
|
internal class ISteamMatchmakingServers : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamMatchmakingServers( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "SteamMatchMakingServers002";
|
public override string InterfaceName => "SteamMatchMakingServers002";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamMusic : SteamInterface
|
internal class ISteamMusic : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamMusic( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "STEAMMUSIC_INTERFACE_VERSION001";
|
public override string InterfaceName => "STEAMMUSIC_INTERFACE_VERSION001";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamNetworking : SteamInterface
|
internal class ISteamNetworking : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamNetworking( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "SteamNetworking005";
|
public override string InterfaceName => "SteamNetworking005";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamNetworkingUtils : SteamInterface
|
internal class ISteamNetworkingUtils : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamNetworkingUtils( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "SteamNetworkingUtils001";
|
public override string InterfaceName => "SteamNetworkingUtils001";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamParentalSettings : SteamInterface
|
internal class ISteamParentalSettings : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamParentalSettings( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "STEAMPARENTALSETTINGS_INTERFACE_VERSION001";
|
public override string InterfaceName => "STEAMPARENTALSETTINGS_INTERFACE_VERSION001";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamParties : SteamInterface
|
internal class ISteamParties : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamParties( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "SteamParties002";
|
public override string InterfaceName => "SteamParties002";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamRemoteStorage : SteamInterface
|
internal class ISteamRemoteStorage : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamRemoteStorage( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "STEAMREMOTESTORAGE_INTERFACE_VERSION014";
|
public override string InterfaceName => "STEAMREMOTESTORAGE_INTERFACE_VERSION014";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamScreenshots : SteamInterface
|
internal class ISteamScreenshots : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamScreenshots( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "STEAMSCREENSHOTS_INTERFACE_VERSION003";
|
public override string InterfaceName => "STEAMSCREENSHOTS_INTERFACE_VERSION003";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamUGC : SteamInterface
|
internal class ISteamUGC : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamUGC( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "STEAMUGC_INTERFACE_VERSION012";
|
public override string InterfaceName => "STEAMUGC_INTERFACE_VERSION012";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamUser : SteamInterface
|
internal class ISteamUser : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamUser( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "SteamUser020";
|
public override string InterfaceName => "SteamUser020";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamUserStats : SteamInterface
|
internal class ISteamUserStats : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamUserStats( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "STEAMUSERSTATS_INTERFACE_VERSION011";
|
public override string InterfaceName => "STEAMUSERSTATS_INTERFACE_VERSION011";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamUtils : SteamInterface
|
internal class ISteamUtils : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamUtils( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "SteamUtils009";
|
public override string InterfaceName => "SteamUtils009";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -9,10 +9,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
internal class ISteamVideo : SteamInterface
|
internal class ISteamVideo : SteamInterface
|
||||||
{
|
{
|
||||||
public ISteamVideo( bool server = false ) : base( server )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string InterfaceName => "STEAMVIDEO_INTERFACE_V002";
|
public override string InterfaceName => "STEAMVIDEO_INTERFACE_V002";
|
||||||
|
|
||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
|
@ -18,7 +18,10 @@ namespace Steamworks.ServerList
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new ISteamMatchmakingServers();
|
_internal = new ISteamMatchmakingServers();
|
||||||
|
_internal.InitClient();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,10 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new ISteamApps();
|
_internal = new ISteamApps();
|
||||||
|
_internal.InitClient();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ namespace Steamworks
|
|||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
{
|
{
|
||||||
_internal = new ISteamFriends();
|
_internal = new ISteamFriends();
|
||||||
|
_internal.InitClient();
|
||||||
|
|
||||||
richPresence = new Dictionary<string, string>();
|
richPresence = new Dictionary<string, string>();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,10 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new ISteamInventory();
|
_internal = new ISteamInventory();
|
||||||
|
_internal.InitClient();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,10 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new ISteamMatchmaking();
|
_internal = new ISteamMatchmaking();
|
||||||
|
_internal.InitClient();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,10 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new ISteamMusic();
|
_internal = new ISteamMusic();
|
||||||
|
_internal.InitClient();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,10 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new ISteamNetworking();
|
_internal = new ISteamNetworking();
|
||||||
|
_internal.InitClient();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,10 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new ISteamParentalSettings();
|
_internal = new ISteamParentalSettings();
|
||||||
|
_internal.InitClient();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,10 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new ISteamParties();
|
_internal = new ISteamParties();
|
||||||
|
_internal.InitClient();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,10 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new ISteamRemoteStorage();
|
_internal = new ISteamRemoteStorage();
|
||||||
|
_internal.InitClient();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,10 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new ISteamScreenshots();
|
_internal = new ISteamScreenshots();
|
||||||
|
_internal.InitClient();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,10 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
_internal = new ISteamGameServer( true );
|
{
|
||||||
|
_internal = new ISteamGameServer( );
|
||||||
|
_internal.InitServer();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,10 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new ISteamInventory();
|
_internal = new ISteamInventory();
|
||||||
|
_internal.InitClient();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ namespace Steamworks
|
|||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
{
|
{
|
||||||
_internal = new ISteamUGC();
|
_internal = new ISteamUGC();
|
||||||
|
_internal.InitClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
|
@ -22,6 +22,7 @@ namespace Steamworks
|
|||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
{
|
{
|
||||||
_internal = new ISteamUser();
|
_internal = new ISteamUser();
|
||||||
|
_internal.InitClient();
|
||||||
|
|
||||||
richPresence = new Dictionary<string, string>();
|
richPresence = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@ namespace Steamworks
|
|||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
{
|
{
|
||||||
_internal = new ISteamUserStats();
|
_internal = new ISteamUserStats();
|
||||||
|
_internal.InitClient();
|
||||||
|
|
||||||
RequestCurrentStats();
|
RequestCurrentStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,10 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new ISteamUtils();
|
_internal = new ISteamUtils();
|
||||||
|
_internal.InitClient();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,10 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new ISteamVideo();
|
_internal = new ISteamVideo();
|
||||||
|
_internal.InitClient();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
|
@ -16,28 +16,42 @@ namespace Steamworks
|
|||||||
|
|
||||||
public virtual string InterfaceName => null;
|
public virtual string InterfaceName => null;
|
||||||
|
|
||||||
public SteamInterface( bool server = false )
|
public virtual void InitClient()
|
||||||
{
|
{
|
||||||
//
|
var user = SteamAPI.GetHSteamUser();
|
||||||
// If teh client isn't initialized but the server is,
|
Self = SteamInternal.FindOrCreateUserInterface( user, InterfaceName );
|
||||||
// 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 );
|
|
||||||
|
|
||||||
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}" );
|
||||||
|
|
||||||
|
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 );
|
VTable = Marshal.ReadIntPtr( Self, 0 );
|
||||||
if ( Self == IntPtr.Zero )
|
if ( Self == IntPtr.Zero )
|
||||||
|
@ -27,13 +27,6 @@ namespace Generator
|
|||||||
{
|
{
|
||||||
StartBlock( $"internal class {clss.Name} : SteamInterface" );
|
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( $"public override string InterfaceName => \"{clss.InterfaceString}\";" );
|
||||||
WriteLine();
|
WriteLine();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user