public virtual void InitUserless()
 {
     this.Self = SteamInternal.FindOrCreateUserInterface(0, this.InterfaceName);
     if (this.Self == IntPtr.Zero)
     {
         throw new Exception(String.Concat("Couldn't find interface ", this.InterfaceName));
     }
     this.VTable = Marshal.ReadIntPtr(this.Self, 0);
     if (this.Self == IntPtr.Zero)
     {
         throw new Exception(String.Concat("Invalid VTable for ", this.InterfaceName));
     }
     this.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)
            {
                throw new System.Exception($"Invalid VTable for {InterfaceName}");
            }

            InitInternals();
        }
        public virtual void InitClient()
        {
            var user = SteamAPI.GetHSteamUser();

            Self = SteamInternal.FindOrCreateUserInterface(user, InterfaceName);

            if (Self == IntPtr.Zero)
            {
                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 void InitClient()
 {
     this.Self = SteamInternal.CreateInterface(this.InterfaceName);
     if (this.Self == IntPtr.Zero)
     {
         HSteamUser hSteamUser = SteamAPI.GetHSteamUser();
         this.Self = SteamInternal.FindOrCreateUserInterface(hSteamUser, this.InterfaceName);
     }
     if (this.Self == IntPtr.Zero)
     {
         throw new Exception(String.Concat("Couldn't find interface ", this.InterfaceName));
     }
     this.VTable = Marshal.ReadIntPtr(this.Self, 0);
     if (this.Self == IntPtr.Zero)
     {
         throw new Exception(String.Concat("Invalid VTable for ", this.InterfaceName));
     }
     this.InitInternals();
     SteamClient.WatchInterface(this);
 }
        public void InitClient()
        {
            //
            // There's an issue for us using FindOrCreateUserInterface on Rust.
            // We have a different appid for our staging branch, but we use Rust's
            // appid so we can still test with the live data/setup. The issue is
            // if we run the staging branch and get interfaces using FindOrCreate
            // then some callbacks don't work. I assume this is because these interfaces
            // have already been initialized using the old appid pipe, but since I
            // can't see inside Steam this is just a gut feeling. Either way using
            // CreateInterface doesn't seem to have caused any fires, so we'll just use that.
            //

            //
            // var pipe = SteamAPI.GetHSteamPipe();
            //

            Self = SteamInternal.CreateInterface(InterfaceName);

            if (Self == IntPtr.Zero)
            {
                var user = SteamAPI.GetHSteamUser();
                Self = SteamInternal.FindOrCreateUserInterface(user, InterfaceName);
            }

            if (Self == IntPtr.Zero)
            {
                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();
            SteamClient.WatchInterface(this);
        }
예제 #6
0
        public SteamInterface(bool server = false)
        {
            //
            // 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);

            if (Self == IntPtr.Zero)
            {
                throw new System.Exception($"Couldn't find interface {InterfaceName} (server:{server})");
            }


            VTable = Marshal.ReadIntPtr(Self, 0);
            if (Self == IntPtr.Zero)
            {
                throw new System.Exception($"Invalid VTable for {InterfaceName}");
            }

            InitInternals();
        }