/*public static ulong[] RegisteredIds => new ulong[]
         *  {
         *      76561198408785287ul, // Favelin
         *      76561198001658409ul, // elamaunt
         *      76561198064050301ul, // SunRay
         *      76561198137977374ul, // Anibus
         *
         *      76561198011215928ul, // Bukan1
         *      76561198005325871ul, // Bukan2
         *
         *      76561198858224000ul, // Igor_kocerev
         *      76561198233237924ul, // Flashbang
         *      76561198855597623ul, // onebillygrimm
         *      76561198856913976ul, // Jabka_X
         *      76561198174310885ul, // Mizopolak
         *      76561198842926724ul, // veloziraptor
         *      76561198098129338ul, // DAG05 Simon
         *      76561198021093802ul, // ki4a
         *      76561198072623723ul, // Master Yoba
         *      76561198137292489ul, // ZADGE
         *      76561198116829514ul, // Maugan Ra
         *      76561198036915935ul, // SorroWfuL LivED
         *      76561198143540732ul, // YbuBaKa
         *      76561198981516933ul, // Cg_JGHAMO
         *      76561198003604494ul, // Gigamok
         *      76561198360256453ul, // Gedeon
         *      76561198225092112ul, // vladirus
         *      76561198090267618ul, // deREXte
         *      76561198027618614ul, // Sm0kEZ
         *      76561198107179356ul, // Made in USSR
         *      76561198132447203ul, // Dolorosa
         *      76561198386642785ul  // Super_cega
         *  };*/

        private void OnRender(object sender, EventArgs e)
        {
            GameServer.RunCallbacks();
            SteamAPI.RunCallbacks();
            PortBindingManager.UpdateFrame();
        }
        public Task LaunchGameAndWait()
        {
            return(Task.Factory.StartNew(async() =>
            {
                ProcessManager.KillAllGameProccessesWithoutWindow();


                if (ProcessManager.GameIsRunning())
                {
                    throw new Exception("Game is running");
                }

                if (!PathFinder.IsPathFound())
                {
                    throw new Exception("Path to game not found in Steam");
                }

                IPHostEntry entry = null;


                try
                {
                    entry = Dns.GetHostEntry("gamespygp");
                }
                catch (Exception)
                {
                    FixHosts();
                }


                if (entry != null)
                {
                    var address = IPAddress.Parse(GameConstants.SERVER_ADDRESS);
                    if (!entry.AddressList.Any(x => x.Equals(address)))
                    {
                        FixHosts();
                    }
                }

                var tcs = new TaskCompletionSource <Process>();

                try
                {
                    Task.Factory.StartNew(() =>
                    {
                        while (!tcs.Task.IsCompleted)
                        {
                            GameServer.RunCallbacks();
                            SteamAPI.RunCallbacks();
                            PortBindingManager.UpdateFrame();
                            Thread.Sleep(5);
                        }
                    }, TaskCreationOptions.LongRunning);

                    var exeFileName = Path.Combine(LauncherPath, "GameFiles", "Patch1.2", "Soulstorm.exe");
                    var procParams = "-nomovies -forcehighpoly";
                    if (AppSettings.ThunderHawkModAutoSwitch)
                    {
                        procParams += " -modname ThunderHawk";
                    }

                    var ssProc = Process.Start(new ProcessStartInfo(exeFileName, procParams)
                    {
                        UseShellExecute = true,
                        WorkingDirectory = PathFinder.GamePath
                    });


                    ServerContext.Start(IPAddress.Any);

                    ssProc.EnableRaisingEvents = true;

                    Task.Run(() => RemoveFogLoop(tcs.Task, ssProc));

                    ssProc.Exited += (s, e) =>
                    {
                        tcs.TrySetResult(ssProc);
                    };
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    tcs.TrySetException(ex);
                }

                await tcs.Task;
                ServerContext.Stop();
            }).Unwrap());
        }