diff --git a/Facepunch.Steamworks/Interop/Native.cs b/Facepunch.Steamworks/Interop/Native.cs index 24c0a1c..f79b74b 100644 --- a/Facepunch.Steamworks/Interop/Native.cs +++ b/Facepunch.Steamworks/Interop/Native.cs @@ -36,7 +36,7 @@ internal bool InitClient( BaseSteamworks steamworks ) { isServer = false; - api = new SteamNative.SteamApi( steamworks, (IntPtr) 1 ); + api = new SteamNative.SteamApi(); if ( !api.SteamAPI_Init() ) return false; @@ -63,7 +63,7 @@ internal bool InitServer( BaseSteamworks steamworks, uint IpAddress /*uint32*/, { isServer = true; - api = new SteamNative.SteamApi( steamworks, ( IntPtr)1 ); + api = new SteamNative.SteamApi(); if ( !api.SteamInternal_GameServer_Init( IpAddress, usPort, GamePort, QueryPort, eServerMode, pchVersionString ) ) { diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamApi.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamApi.cs index 026bfa5..698de98 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamApi.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamApi.cs @@ -10,20 +10,18 @@ internal unsafe class SteamApi : IDisposable // Holds a platform specific implentation // internal Platform.Interface platform; - internal Facepunch.Steamworks.BaseSteamworks steamworks; // // Constructor decides which implementation to use based on current platform // - internal SteamApi( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer ) + internal SteamApi() { - this.steamworks = steamworks; - if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer ); - else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer ); - else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer ); - else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer ); - else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer ); + if ( Platform.IsWindows64 ) platform = new Platform.Win64( ((IntPtr)1) ); + else if ( Platform.IsWindows32 ) platform = new Platform.Win32( ((IntPtr)1) ); + else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( ((IntPtr)1) ); + else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( ((IntPtr)1) ); + else if ( Platform.IsOsx ) platform = new Platform.Mac( ((IntPtr)1) ); } // diff --git a/Generator/CodeWriter/Class.cs b/Generator/CodeWriter/Class.cs index 84451a7..df76dbc 100644 --- a/Generator/CodeWriter/Class.cs +++ b/Generator/CodeWriter/Class.cs @@ -41,23 +41,45 @@ private void Class( string classname, SteamApiDefinition.MethodDef[] methodDef ) WriteLine( "// Holds a platform specific implentation" ); WriteLine( "//" ); WriteLine( "internal Platform.Interface platform;" ); - WriteLine( "internal Facepunch.Steamworks.BaseSteamworks steamworks;" ); + + if ( classname != "SteamApi" ) + WriteLine( "internal Facepunch.Steamworks.BaseSteamworks steamworks;" ); + WriteLine(); WriteLine( "//" ); WriteLine( "// Constructor decides which implementation to use based on current platform" ); WriteLine( "//" ); - StartBlock( $"internal {InterfaceNameToClass( classname )}( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )" ); + + if ( classname == "SteamApi" ) { - WriteLine( "this.steamworks = steamworks;" ); - WriteLine( "" ); - WriteLine( "if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );" ); - WriteLine( "else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );" ); - WriteLine( "else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );" ); - WriteLine( "else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );" ); - WriteLine( "else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );" ); + + StartBlock( $"internal {InterfaceNameToClass( classname )}()" ); + { + WriteLine( "" ); + WriteLine( "if ( Platform.IsWindows64 ) platform = new Platform.Win64( ((IntPtr)1) );" ); + WriteLine( "else if ( Platform.IsWindows32 ) platform = new Platform.Win32( ((IntPtr)1) );" ); + WriteLine( "else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( ((IntPtr)1) );" ); + WriteLine( "else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( ((IntPtr)1) );" ); + WriteLine( "else if ( Platform.IsOsx ) platform = new Platform.Mac( ((IntPtr)1) );" ); + } + EndBlock(); } - EndBlock(); + else + { + StartBlock( $"internal {InterfaceNameToClass( classname )}( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )" ); + { + WriteLine( "this.steamworks = steamworks;" ); + WriteLine( "" ); + WriteLine( "if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );" ); + WriteLine( "else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );" ); + WriteLine( "else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );" ); + WriteLine( "else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );" ); + WriteLine( "else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );" ); + } + EndBlock(); + } + WriteLine(); WriteLine( "//" );