From 1c1925bae9a4e23701bbd0edcc63ed77a52f6955 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Thu, 2 May 2019 13:27:46 +0100 Subject: [PATCH] Update how interfaces are initialized so we can initialize userless --- .../Generated/Interfaces/ISteamApps.cs | 4 -- .../Generated/Interfaces/ISteamFriends.cs | 4 -- .../Generated/Interfaces/ISteamGameServer.cs | 4 -- .../Generated/Interfaces/ISteamInventory.cs | 4 -- .../Generated/Interfaces/ISteamMatchmaking.cs | 4 -- .../Interfaces/ISteamMatchmakingServers.cs | 4 -- .../Generated/Interfaces/ISteamMusic.cs | 4 -- .../Generated/Interfaces/ISteamNetworking.cs | 4 -- .../Interfaces/ISteamNetworkingUtils.cs | 4 -- .../Interfaces/ISteamParentalSettings.cs | 4 -- .../Generated/Interfaces/ISteamParties.cs | 4 -- .../Interfaces/ISteamRemoteStorage.cs | 4 -- .../Generated/Interfaces/ISteamScreenshots.cs | 4 -- .../Generated/Interfaces/ISteamUGC.cs | 4 -- .../Generated/Interfaces/ISteamUser.cs | 4 -- .../Generated/Interfaces/ISteamUserStats.cs | 4 -- .../Generated/Interfaces/ISteamUtils.cs | 4 -- .../Generated/Interfaces/ISteamVideo.cs | 4 -- Facepunch.Steamworks/ServerList/Base.cs | 3 ++ Facepunch.Steamworks/SteamApps.cs | 3 ++ Facepunch.Steamworks/SteamFriends.cs | 1 + Facepunch.Steamworks/SteamInventory.cs | 3 ++ Facepunch.Steamworks/SteamMatchmaking.cs | 3 ++ Facepunch.Steamworks/SteamMusic.cs | 3 ++ Facepunch.Steamworks/SteamNetworking.cs | 3 ++ Facepunch.Steamworks/SteamParental.cs | 3 ++ Facepunch.Steamworks/SteamParties.cs | 3 ++ Facepunch.Steamworks/SteamRemoteStorage.cs | 3 ++ Facepunch.Steamworks/SteamScreenshots.cs | 3 ++ Facepunch.Steamworks/SteamServer.cs | 5 +- Facepunch.Steamworks/SteamServerInventory.cs | 3 ++ Facepunch.Steamworks/SteamUgc.cs | 1 + Facepunch.Steamworks/SteamUser.cs | 1 + Facepunch.Steamworks/SteamUserStats.cs | 2 + Facepunch.Steamworks/SteamUtils.cs | 3 ++ Facepunch.Steamworks/SteamVideo.cs | 3 ++ .../Utility/SteamInterface.cs | 50 ++++++++++++------- Generator/CodeWriter/ClassVTable.cs | 7 --- 38 files changed, 80 insertions(+), 98 deletions(-) diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs index 73f8171..da0f710 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs index 1ec2f66..fb77562 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs index 3833745..197ae43 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs index a465e07..6795c84 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmaking.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmaking.cs index 933f589..2d8ec92 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmaking.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmaking.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingServers.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingServers.cs index 58a65d5..f5e2c57 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingServers.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingServers.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamMusic.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamMusic.cs index f55dfac..c72987c 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamMusic.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamMusic.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworking.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworking.cs index 049c3cf..c3dbb4b 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworking.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworking.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs index da8cb4a..85af70c 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamParentalSettings.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamParentalSettings.cs index cd02329..ca89155 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamParentalSettings.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamParentalSettings.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamParties.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamParties.cs index e424e1d..78c3fc6 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamParties.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamParties.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamRemoteStorage.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamRemoteStorage.cs index c48783f..92332c0 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamRemoteStorage.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamRemoteStorage.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamScreenshots.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamScreenshots.cs index 251061b..c4428cd 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamScreenshots.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamScreenshots.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs index 7c6cef3..d3b3871 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs index 231a131..0794dfa 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs index 33b9d77..ee64642 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs index 005d0de..c0eb1de 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs @@ -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() diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamVideo.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamVideo.cs index 13a03f3..7b516bb 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamVideo.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamVideo.cs @@ -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() diff --git a/Facepunch.Steamworks/ServerList/Base.cs b/Facepunch.Steamworks/ServerList/Base.cs index fff68ae..ce447ca 100644 --- a/Facepunch.Steamworks/ServerList/Base.cs +++ b/Facepunch.Steamworks/ServerList/Base.cs @@ -18,7 +18,10 @@ namespace Steamworks.ServerList get { if ( _internal == null ) + { _internal = new ISteamMatchmakingServers(); + _internal.InitClient(); + } return _internal; } diff --git a/Facepunch.Steamworks/SteamApps.cs b/Facepunch.Steamworks/SteamApps.cs index d90594b..e7d95b1 100644 --- a/Facepunch.Steamworks/SteamApps.cs +++ b/Facepunch.Steamworks/SteamApps.cs @@ -19,7 +19,10 @@ namespace Steamworks get { if ( _internal == null ) + { _internal = new ISteamApps(); + _internal.InitClient(); + } return _internal; } diff --git a/Facepunch.Steamworks/SteamFriends.cs b/Facepunch.Steamworks/SteamFriends.cs index 62fee5c..244023a 100644 --- a/Facepunch.Steamworks/SteamFriends.cs +++ b/Facepunch.Steamworks/SteamFriends.cs @@ -20,6 +20,7 @@ namespace Steamworks if ( _internal == null ) { _internal = new ISteamFriends(); + _internal.InitClient(); richPresence = new Dictionary(); } diff --git a/Facepunch.Steamworks/SteamInventory.cs b/Facepunch.Steamworks/SteamInventory.cs index 21962db..71d2cde 100644 --- a/Facepunch.Steamworks/SteamInventory.cs +++ b/Facepunch.Steamworks/SteamInventory.cs @@ -20,7 +20,10 @@ namespace Steamworks get { if ( _internal == null ) + { _internal = new ISteamInventory(); + _internal.InitClient(); + } return _internal; } diff --git a/Facepunch.Steamworks/SteamMatchmaking.cs b/Facepunch.Steamworks/SteamMatchmaking.cs index bd88851..261c296 100644 --- a/Facepunch.Steamworks/SteamMatchmaking.cs +++ b/Facepunch.Steamworks/SteamMatchmaking.cs @@ -18,7 +18,10 @@ namespace Steamworks get { if ( _internal == null ) + { _internal = new ISteamMatchmaking(); + _internal.InitClient(); + } return _internal; } diff --git a/Facepunch.Steamworks/SteamMusic.cs b/Facepunch.Steamworks/SteamMusic.cs index 6c04b4f..27142e2 100644 --- a/Facepunch.Steamworks/SteamMusic.cs +++ b/Facepunch.Steamworks/SteamMusic.cs @@ -21,7 +21,10 @@ namespace Steamworks get { if ( _internal == null ) + { _internal = new ISteamMusic(); + _internal.InitClient(); + } return _internal; } diff --git a/Facepunch.Steamworks/SteamNetworking.cs b/Facepunch.Steamworks/SteamNetworking.cs index 4d72178..ad8c1b7 100644 --- a/Facepunch.Steamworks/SteamNetworking.cs +++ b/Facepunch.Steamworks/SteamNetworking.cs @@ -16,7 +16,10 @@ namespace Steamworks get { if ( _internal == null ) + { _internal = new ISteamNetworking(); + _internal.InitClient(); + } return _internal; } diff --git a/Facepunch.Steamworks/SteamParental.cs b/Facepunch.Steamworks/SteamParental.cs index 1d0c512..18fe938 100644 --- a/Facepunch.Steamworks/SteamParental.cs +++ b/Facepunch.Steamworks/SteamParental.cs @@ -18,7 +18,10 @@ namespace Steamworks get { if ( _internal == null ) + { _internal = new ISteamParentalSettings(); + _internal.InitClient(); + } return _internal; } diff --git a/Facepunch.Steamworks/SteamParties.cs b/Facepunch.Steamworks/SteamParties.cs index b961f19..6a97770 100644 --- a/Facepunch.Steamworks/SteamParties.cs +++ b/Facepunch.Steamworks/SteamParties.cs @@ -15,7 +15,10 @@ namespace Steamworks get { if ( _internal == null ) + { _internal = new ISteamParties(); + _internal.InitClient(); + } return _internal; } diff --git a/Facepunch.Steamworks/SteamRemoteStorage.cs b/Facepunch.Steamworks/SteamRemoteStorage.cs index a191856..c0287d8 100644 --- a/Facepunch.Steamworks/SteamRemoteStorage.cs +++ b/Facepunch.Steamworks/SteamRemoteStorage.cs @@ -18,7 +18,10 @@ namespace Steamworks get { if ( _internal == null ) + { _internal = new ISteamRemoteStorage(); + _internal.InitClient(); + } return _internal; } diff --git a/Facepunch.Steamworks/SteamScreenshots.cs b/Facepunch.Steamworks/SteamScreenshots.cs index 441fa0e..a3c69a9 100644 --- a/Facepunch.Steamworks/SteamScreenshots.cs +++ b/Facepunch.Steamworks/SteamScreenshots.cs @@ -18,7 +18,10 @@ namespace Steamworks get { if ( _internal == null ) + { _internal = new ISteamScreenshots(); + _internal.InitClient(); + } return _internal; } diff --git a/Facepunch.Steamworks/SteamServer.cs b/Facepunch.Steamworks/SteamServer.cs index 04b4d53..5b340fe 100644 --- a/Facepunch.Steamworks/SteamServer.cs +++ b/Facepunch.Steamworks/SteamServer.cs @@ -20,7 +20,10 @@ namespace Steamworks get { if ( _internal == null ) - _internal = new ISteamGameServer( true ); + { + _internal = new ISteamGameServer( ); + _internal.InitServer(); + } return _internal; } diff --git a/Facepunch.Steamworks/SteamServerInventory.cs b/Facepunch.Steamworks/SteamServerInventory.cs index 464998e..2eb8492 100644 --- a/Facepunch.Steamworks/SteamServerInventory.cs +++ b/Facepunch.Steamworks/SteamServerInventory.cs @@ -17,7 +17,10 @@ namespace Steamworks get { if ( _internal == null ) + { _internal = new ISteamInventory(); + _internal.InitClient(); + } return _internal; } diff --git a/Facepunch.Steamworks/SteamUgc.cs b/Facepunch.Steamworks/SteamUgc.cs index 7a99716..47348ea 100644 --- a/Facepunch.Steamworks/SteamUgc.cs +++ b/Facepunch.Steamworks/SteamUgc.cs @@ -22,6 +22,7 @@ namespace Steamworks if ( _internal == null ) { _internal = new ISteamUGC(); + _internal.InitClient(); } return _internal; diff --git a/Facepunch.Steamworks/SteamUser.cs b/Facepunch.Steamworks/SteamUser.cs index 6e4bcd2..2fffd84 100644 --- a/Facepunch.Steamworks/SteamUser.cs +++ b/Facepunch.Steamworks/SteamUser.cs @@ -22,6 +22,7 @@ namespace Steamworks if ( _internal == null ) { _internal = new ISteamUser(); + _internal.InitClient(); richPresence = new Dictionary(); diff --git a/Facepunch.Steamworks/SteamUserStats.cs b/Facepunch.Steamworks/SteamUserStats.cs index b9517e1..0638275 100644 --- a/Facepunch.Steamworks/SteamUserStats.cs +++ b/Facepunch.Steamworks/SteamUserStats.cs @@ -17,6 +17,8 @@ namespace Steamworks if ( _internal == null ) { _internal = new ISteamUserStats(); + _internal.InitClient(); + RequestCurrentStats(); } diff --git a/Facepunch.Steamworks/SteamUtils.cs b/Facepunch.Steamworks/SteamUtils.cs index f32dd5b..2726422 100644 --- a/Facepunch.Steamworks/SteamUtils.cs +++ b/Facepunch.Steamworks/SteamUtils.cs @@ -18,7 +18,10 @@ namespace Steamworks get { if ( _internal == null ) + { _internal = new ISteamUtils(); + _internal.InitClient(); + } return _internal; } diff --git a/Facepunch.Steamworks/SteamVideo.cs b/Facepunch.Steamworks/SteamVideo.cs index e0c65d3..6d0269f 100644 --- a/Facepunch.Steamworks/SteamVideo.cs +++ b/Facepunch.Steamworks/SteamVideo.cs @@ -18,7 +18,10 @@ namespace Steamworks get { if ( _internal == null ) + { _internal = new ISteamVideo(); + _internal.InitClient(); + } return _internal; } diff --git a/Facepunch.Steamworks/Utility/SteamInterface.cs b/Facepunch.Steamworks/Utility/SteamInterface.cs index 8e88760..75ea132 100644 --- a/Facepunch.Steamworks/Utility/SteamInterface.cs +++ b/Facepunch.Steamworks/Utility/SteamInterface.cs @@ -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 ) diff --git a/Generator/CodeWriter/ClassVTable.cs b/Generator/CodeWriter/ClassVTable.cs index 05a6799..c8609e5 100644 --- a/Generator/CodeWriter/ClassVTable.cs +++ b/Generator/CodeWriter/ClassVTable.cs @@ -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();