Пример #1
0
        internal bool InitClient(BaseSteamworks steamworks)
        {
            isServer = false;

            api = new SteamNative.SteamApi(steamworks, (IntPtr)1);

            if (!api.SteamAPI_Init())
            {
                return(false);
            }

            hUser = api.SteamAPI_GetHSteamUser();
            hPipe = api.SteamAPI_GetHSteamPipe();
            if (hPipe == 0)
            {
                return(false);
            }

            FillInterfaces(steamworks, hUser, hPipe);

            if (!user.IsValid)
            {
                return(false);
            }

            // Ensure that the user has logged into Steam. This will always return true if the game is launched
            // from Steam, but if Steam is at the login prompt when you run your game it will return false.
            if (!user.BLoggedOn())
            {
                return(false);
            }

            return(true);
        }
Пример #2
0
        internal bool InitServer(BaseSteamworks steamworks, uint IpAddress /*uint32*/, ushort usPort /*uint16*/, ushort GamePort /*uint16*/, ushort QueryPort /*uint16*/, int eServerMode /*int*/, string pchVersionString /*const char **/)
        {
            isServer = true;

            api = new SteamNative.SteamApi(steamworks, ( IntPtr)1);

            if (!api.SteamInternal_GameServer_Init(IpAddress, usPort, GamePort, QueryPort, eServerMode, pchVersionString))
            {
                return(false);
            }

            hUser = api.SteamGameServer_GetHSteamUser();
            hPipe = api.SteamGameServer_GetHSteamPipe();
            if (hPipe == 0)
            {
                return(false);
            }

            FillInterfaces(steamworks, hPipe, hUser);

            if (!gameServer.IsValid)
            {
                gameServer = null;
                throw new System.Exception("Steam Server: Couldn't load SteamGameServer012");
            }

            return(true);
        }
Пример #3
0
        internal bool InitClient(BaseSteamworks steamworks, out string state)
        {
            if (Steamworks.Server.Instance != null)
            {
                throw new System.Exception("Steam client should be initialized before steam server - or there's big trouble.");
            }

            isServer = false;

            api = new SteamNative.SteamApi();

            if (!api.SteamAPI_Init())
            {
                Console.Error.WriteLine("InitClient: SteamAPI_Init returned false");
                state = "InitClient: SteamAPI_Init returned false";
                return(false);
            }

            var hUser = api.SteamAPI_GetHSteamUser();
            var hPipe = api.SteamAPI_GetHSteamPipe();

            if (hPipe == 0)
            {
                Console.Error.WriteLine("InitClient: hPipe == 0");
                state = "InitClient: hPipe == 0";
                return(false);
            }

            FillInterfaces(steamworks, hUser, hPipe);

            if (!user.IsValid)
            {
                Console.Error.WriteLine("InitClient: ISteamUser is null");
                state = "InitClient: ISteamUser is null";
                return(false);
            }

            // Ensure that the user has logged into Steam. This will always return true if the game is launched
            // from Steam, but if Steam is at the login prompt when you run your game it will return false.
            if (!user.BLoggedOn())
            {
                Console.Error.WriteLine("InitClient: Not Logged On");
                state = "InitClient: Not Logged On";
                return(false);
            }

            state = "Loaded";
            return(true);
        }
Пример #4
0
        internal bool InitClient(BaseSteamworks steamworks)
        {
            isServer = false;

            api = new SteamNative.SteamApi();

            if (!api.SteamAPI_Init())
            {
                Console.Error.WriteLine("InitClient: SteamAPI_Init returned false");
                return(false);
            }

            hUser = api.SteamAPI_GetHSteamUser();
            hPipe = api.SteamAPI_GetHSteamPipe();
            if (hPipe == 0)
            {
                Console.Error.WriteLine("InitClient: hPipe == 0");
                return(false);
            }

            FillInterfaces(steamworks, hUser, hPipe);

            if (!user.IsValid)
            {
                Console.Error.WriteLine("InitClient: ISteamUser is null");
                return(false);
            }

            // Ensure that the user has logged into Steam. This will always return true if the game is launched
            // from Steam, but if Steam is at the login prompt when you run your game it will return false.
            if (!user.BLoggedOn())
            {
                Console.Error.WriteLine("InitClient: Not Logged On");
                return(false);
            }

            return(true);
        }
Пример #5
0
        internal bool InitClient(BaseSteamworks steamworks)
        {
            if (Steamworks.Server.Instance != null)
            {
                throw new System.Exception("Steam client should be initialized before steam server - or there's big trouble.");
            }

            isServer = false;

            api = new SteamNative.SteamApi();

            if (!api.SteamAPI_Init())
            {
                Console.Error.WriteLine("InitClient: SteamAPI_Init returned false");
                return(false);
            }

            var hUser = api.SteamAPI_GetHSteamUser();
            var hPipe = api.SteamAPI_GetHSteamPipe();

            if (hPipe == 0)
            {
                Console.Error.WriteLine("InitClient: hPipe == 0");
                return(false);
            }

            FillInterfaces(steamworks, hUser, hPipe);

            if (!user.IsValid)
            {
                Console.Error.WriteLine("InitClient: ISteamUser is null");
                return(false);
            }

            return(true);
        }
Пример #6
0
        public void Dispose()
        {
            if (client != null)
            {
                if (hPipe != 0)
                {
                    if (hUser != 0)
                    {
                        client.ReleaseUser(hPipe, hUser);
                        hUser = 0;
                    }

                    client.BReleaseSteamPipe(hPipe);
                    hPipe = 0;
                }

                if (!client.BShutdownIfAllPipesClosed())
                {
                    Console.WriteLine("BShutdownIfAllPipesClosed returned false");
                }

                client.Dispose();
                client = null;
            }

            if (user != null)
            {
                user.Dispose();
                user = null;
            }

            if (utils != null)
            {
                utils.Dispose();
                utils = null;
            }

            if (networking != null)
            {
                networking.Dispose();
                networking = null;
            }

            if (gameServerStats != null)
            {
                gameServerStats.Dispose();
                gameServerStats = null;
            }

            if (http != null)
            {
                http.Dispose();
                http = null;
            }

            if (inventory != null)
            {
                inventory.Dispose();
                inventory = null;
            }

            if (ugc != null)
            {
                ugc.Dispose();
                ugc = null;
            }

            if (apps != null)
            {
                apps.Dispose();
                apps = null;
            }

            if (gameServer != null)
            {
                //
                // Calling this can cause the process to hang
                //
                //gameServer.LogOff();

                gameServer.Dispose();
                gameServer = null;
            }

            if (friends != null)
            {
                friends.Dispose();
                friends = null;
            }

            if (servers != null)
            {
                servers.Dispose();
                servers = null;
            }

            if (userstats != null)
            {
                userstats.Dispose();
                userstats = null;
            }

            if (screenshots != null)
            {
                screenshots.Dispose();
                screenshots = null;
            }

            if (remoteStorage != null)
            {
                remoteStorage.Dispose();
                remoteStorage = null;
            }

            if (api != null)
            {
                if (isServer)
                {
                    api.SteamGameServer_Shutdown();
                }
                else
                {
                    api.SteamAPI_Shutdown();
                }

                api.Dispose();
                api = null;
            }
        }
Пример #7
0
        public void Dispose()
        {
            if (user != null)
            {
                user.Dispose();
                user = null;
            }

            if (utils != null)
            {
                utils.Dispose();
                utils = null;
            }

            if (networking != null)
            {
                networking.Dispose();
                networking = null;
            }

            if (gameServerStats != null)
            {
                gameServerStats.Dispose();
                gameServerStats = null;
            }

            if (http != null)
            {
                http.Dispose();
                http = null;
            }

            if (inventory != null)
            {
                inventory.Dispose();
                inventory = null;
            }

            if (ugc != null)
            {
                ugc.Dispose();
                ugc = null;
            }

            if (apps != null)
            {
                apps.Dispose();
                apps = null;
            }

            if (gameServer != null)
            {
                gameServer.Dispose();
                gameServer = null;
            }

            if (friends != null)
            {
                friends.Dispose();
                friends = null;
            }

            if (servers != null)
            {
                servers.Dispose();
                servers = null;
            }

            if (userstats != null)
            {
                userstats.Dispose();
                userstats = null;
            }

            if (screenshots != null)
            {
                screenshots.Dispose();
                screenshots = null;
            }

            if (remoteStorage != null)
            {
                remoteStorage.Dispose();
                remoteStorage = null;
            }

            if (matchmaking != null)
            {
                matchmaking.Dispose();
                matchmaking = null;
            }

            if (applist != null)
            {
                applist.Dispose();
                applist = null;
            }

            if (client != null)
            {
                client.Dispose();
                client = null;
            }

            if (api != null)
            {
                if (isServer)
                {
                    api.SteamGameServer_Shutdown();
                }
                else
                {
                    api.SteamAPI_Shutdown();
                }

                //
                // The functions above destroy the pipeline handles
                // and all of the classes. Trying to call a steam function
                // at this point will result in a crash - because any
                // pointers we stored are not invalid.
                //

                api.Dispose();
                api = null;
            }
        }