void TasClient_ChannelJoinFailed(object sender, TasEventArgs e)
 {
     if (e.ServerParams[0].Contains("Already in the channel!"))
     {
         return;
     }
     WarningBar.DisplayWarning("Channel Joining Error - " + e.ServerParams[0]);
 }
        public static void SpawnAutohost(string gameName, string battleTitle, string password, IEnumerable <string> springieCommands)
        {
            var hostSpawnerName = SpringieCommand.GetHostSpawnerName(gameName);

            if (hostSpawnerName == null)
            {
                MessageBox.Show("Unable to locate AutoHost for given game type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            var spawnCommand = SpringieCommand.Spawn(gameName, battleTitle, password);

            var waitingBar = WarningBar.DisplayWarning("Waiting for AutoHost to start", "Waiting for room");

            EventHandler <CancelEventArgs <TasSayEventArgs> > joinGame = null;

            joinGame = (s, e) =>
            {
                if (e.Data.Place == SayPlace.User && (e.Data.Text == spawnCommand.Reply))
                {
                    e.Cancel = true;
                    Program.NotifySection.RemoveBar(waitingBar);
                    Program.TasClient.PreviewSaid -= joinGame;
                    var myHostName = e.Data.UserName;
                    var battle     = Program.TasClient.ExistingBattles.Values.First(b => b.Founder.Name == myHostName);

                    EventHandler <Battle> battleJoined = null;
                    battleJoined = (s2, e2) =>
                    {
                        if (e2.BattleID == battle.BattleID)
                        {
                            if (springieCommands != null)
                            {
                                foreach (var command in springieCommands)
                                {
                                    HidePM(command);
                                    Program.TasClient.Say(SayPlace.User, myHostName, command, false);
                                }
                            }
                            HidePM("!map");
                            Program.TasClient.Say(SayPlace.User, myHostName, "!map", false);
                            Program.TasClient.BattleJoined -= battleJoined;
                        }
                    };

                    Program.TasClient.BattleJoined += battleJoined;
                    JoinBattle(battle.BattleID, password);
                    NavigationControl.Instance.Path = "chat/battle";
                }
            };

            Program.TasClient.PreviewSaid += joinGame;
            HidePM(spawnCommand.Command);
            Program.TasClient.Say(SayPlace.User, hostSpawnerName, spawnCommand.Command, false);
        }
 public static void StartMission(string name)
 {
     try
     {
         Program.MainWindow.SwitchMusicOnOff(false);
         new MissionStarter().StartMission(name);
     } catch (Exception ex)
     {
         Trace.TraceError("Problem starting mission {0} : {1}", name, ex);
         WarningBar.DisplayWarning("Mission start failed: " + ex.Message);
     }
 }
 public static void StartReplay(string url, string mod, string map, string engine)
 {
     try
     {
         Program.MainWindow.SwitchMusicOnOff(false);
         new ReplayStarter().StartReplay(url, mod, map, engine);
     }
     catch (Exception ex)
     {
         Trace.TraceError("Problem starting replay {0} : {1}", url, ex);
         WarningBar.DisplayWarning("Replay start failed: " + ex.Message);
     }
 }
        public void StartReplay(string demoUrl, string modName, string mapName, string engineVersion)
        {
            var downloads = new List <Download>();

            downloads.Add(Program.Downloader.GetResource(DownloadType.ENGINE, engineVersion));
            downloads.Add(Program.Downloader.GetResource(DownloadType.RAPID, modName));
            downloads.Add(Program.Downloader.GetResource(DownloadType.MAP, mapName));
            downloads.Add(Program.Downloader.GetResource(DownloadType.DEMO, demoUrl));
            downloads = downloads.Where(x => x != null).ToList();
            if (downloads.Count > 0)
            {
                var dd = new WaitDownloadDialog(downloads);
                if (dd.ShowDialog(Program.MainWindow) == DialogResult.Cancel)
                {
                    Program.NotifySection.RemoveBar(this);
                    return;
                }
            }

            var path = Utils.MakePath(Program.SpringPaths.WritableDirectory, "demos", new Uri(demoUrl).Segments.Last());

            try
            {
                var optirun        = Environment.GetEnvironmentVariable("OPTIRUN");              //get OPTIRUN filename from OS
                var springFilename = Program.SpringPaths.GetSpringExecutablePath(engineVersion); //use springMT or standard

                Program.SpringPaths.SetDefaultEnvVars(null, engineVersion);
                if (string.IsNullOrEmpty(optirun))
                {
                    Process.Start(springFilename, string.Format("\"{0}\" --config \"{1}\"", path, Program.SpringPaths.GetSpringConfigPath()));
                }
                else
                {
                    Process.Start(optirun,
                                  string.Format("\"{0}\" \"{1}\" --config \"{2}\"", springFilename, path, Program.SpringPaths.GetSpringConfigPath()));
                }

                Program.MainWindow.InvokeFunc(() => Program.NotifySection.RemoveBar(this));
            }
            catch (Exception ex)
            {
                Trace.TraceError("Error starting replay: {0}", ex);
                Program.MainWindow.InvokeFunc(() =>
                {
                    WarningBar.DisplayWarning(string.Format("Error starting replay {0}", demoUrl));
                });
            }
        }
        void TasClient_ChannelForceLeave(object sender, TasEventArgs e)
        {
            var channelName = e.ServerParams[0];
            var userName    = e.ServerParams[1];
            var reason      = e.ServerParams[2];

            WarningBar.DisplayWarning("You have been kicked from chat channel " + channelName + " by " + userName + ".\r\nReason: " + reason);
            var chatControl = GetChannelControl(channelName);

            if (chatControl != null)
            {
                chatControl.Reset();
                chatControl.Dispose();
                toolTabs.RemoveChannelTab(channelName);
            }
        }
Exemple #7
0
 void TasClient_ChannelJoinFailed(object sender, EventArgs <JoinChannelResponse> joinChannelResponse)
 {
     WarningBar.DisplayWarning("Channel Joining Error - " + joinChannelResponse.Data.Reason, "Cannot join channel");
 }
Exemple #8
0
        void client_Said(object sender, TasSayEventArgs e)
        {
            var tas = (TasClient)sender;

            if (Program.Conf.IgnoredUsers.Contains(e.UserName))
            {
                return;
            }

            if (e.Place == SayPlace.Battle && !e.IsEmote && !Program.TasClient.MyUser.IsInGame)
            {
                Program.MainWindow.NotifyUser("chat/battle", null);
            }
            if (e.Place == SayPlace.Channel && !IsIgnoredChannel(e.Channel))
            {
                Program.MainWindow.NotifyUser("chat/channel/" + e.Channel, null);
            }
            else if (e.Place == SayPlace.User)
            {
                var otherUserName = e.UserName == tas.UserName ? e.Channel : e.UserName;

                // support for offline pm and persistent channels
                if (otherUserName == GlobalConst.NightwatchName && e.Text.StartsWith("!pm"))
                {
                    // message received
                    if (e.UserName == GlobalConst.NightwatchName)
                    {
                        var regex = Regex.Match(e.Text, "!pm\\|([^\\|]*)\\|([^\\|]+)\\|([^\\|]+)\\|([^\\|]+)");
                        if (regex.Success)
                        {
                            var chan = regex.Groups[1].Value;
                            var name = regex.Groups[2].Value;
                            var time = DateTime.Parse(regex.Groups[3].Value, CultureInfo.InvariantCulture).ToLocalTime();
                            var text = regex.Groups[4].Value;

                            if (string.IsNullOrEmpty(chan))
                            {
                                var pmControl = GetPrivateMessageControl(name) ?? CreatePrivateMessageControl(name);
                                pmControl.AddLine(new SaidLine(name, text, time));
                                MainWindow.Instance.NotifyUser("chat/user/" + name, string.Format("{0}: {1}", name, text), false, true);
                            }
                            else
                            {
                                var chatControl = GetChannelControl(chan) ?? CreateChannelControl(chan);
                                chatControl.AddLine(new SaidLine(name, text, time));
                                Program.MainWindow.NotifyUser("chat/channel/" + chan, null);
                            }
                        }
                        else
                        {
                            Trace.TraceWarning("Incomprehensible Nightwatch message: {0}", e.Text);
                        }
                    }
                    else // message sent to nightwatch
                    {
                        var regex = Regex.Match(e.Text, "!pm ([^ ]+) (.*)");
                        if (regex.Success)
                        {
                            var name      = regex.Groups[1].Value;
                            var text      = regex.Groups[2].Value;
                            var pmControl = GetPrivateMessageControl(name) ?? CreatePrivateMessageControl(name);
                            pmControl.AddLine(new SaidLine(Program.Conf.LobbyPlayerName, text));
                        }
                    }
                }
                else
                {
                    var pmControl = GetPrivateMessageControl(otherUserName);
                    // block non friend messages
                    if (pmControl == null && Program.Conf.BlockNonFriendPm && !Program.FriendManager.Friends.Contains(otherUserName) && !Program.TasClient.ExistingUsers[e.UserName].IsBot)
                    {
                        if (e.UserName != Program.TasClient.UserName)
                        {
                            Program.TasClient.Say(SayPlace.User,
                                                  otherUserName,
                                                  "Sorry, I'm busy and do not receive messages. If you want to ask something, use #zk channel. If you have issue to report use http://code.google.com/p/zero-k/issues/list",
                                                  false);
                        }
                    }
                    else
                    {
                        pmControl = pmControl ?? CreatePrivateMessageControl(otherUserName);
                        if (!e.IsEmote)
                        {
                            pmControl.AddLine(new SaidLine(e.UserName, e.Text));
                        }
                        else
                        {
                            pmControl.AddLine(new SaidExLine(e.UserName, e.Text));
                        }
                        if (e.UserName != Program.TasClient.MyUser.Name)
                        {
                            MainWindow.Instance.NotifyUser("chat/user/" + otherUserName,
                                                           string.Format("{0}: {1}", otherUserName, e.Text),
                                                           false,
                                                           true);
                        }
                    }
                }
            }
            else if (e.Place == SayPlace.MessageBox)
            {
                Trace.TraceInformation("TASC: {0}", e.Text);
            }
            if (e.Place == SayPlace.MessageBox)
            {
                WarningBar.DisplayWarning(e.Text, "Message from server");
            }
        }
        public static void Main(string[] args)
        {
            try
            {
                //Stopwatch stopWatch = new Stopwatch(); stopWatch.Start();
                Trace.Listeners.Add(new ConsoleTraceListener());


                if (Environment.OSVersion.Platform != PlatformID.Unix)
                {
                    var ver = GetNetVersionFromRegistry();
                    if (ver < 378675)
                    {
                        MessageBox.Show(new Form {
                            TopMost = true
                        },
                                        "Zero-K launcher needs Microsoft .NET framework 4.5.1\nPlease download and install it first",
                                        "Program is unable to run",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }

                Directory.SetCurrentDirectory(StartupPath);

                // extract fonts
                EmbeddedResourceExtractor.ExtractFile("ZeroKLobby.NativeLibs.SM.ttf", "SM.ttf");
                EmbeddedResourceExtractor.ExtractFile("ZeroKLobby.NativeLibs.OpenSans-Regular.ttf", "OpenSans-Regular.ttf");

                Conf = new Config();

                IsSteamFolder = File.Exists(Path.Combine(StartupPath, "steamfolder.txt"));

                SelfUpdater = new SelfUpdater("Zero-K");

                StartupArgs = args;

                try
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                }
                catch (Exception ex)
                {
                    Trace.TraceWarning("Failed to set rendering compatibility: {0}", ex);
                }

                if (!Debugger.IsAttached)
                {
                    try
                    {
                        AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                        Thread.GetDomain().UnhandledException += UnhandledException;
                        Application.ThreadException += Application_ThreadException;
                        Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceWarning("Failed to set exception handling :{0}", ex);
                    }
                }



                //HttpWebRequest.DefaultCachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
                Trace.TraceInformation("Starting with version {0}", SelfUpdater.CurrentVersion);

                WebRequest.DefaultWebProxy = null;
                ThreadPool.SetMaxThreads(500, 2000);
                ServicePointManager.Expect100Continue = false;
                LoadConfig();



                Trace.Listeners.Add(new LogTraceListener());
                if (Environment.OSVersion.Platform != PlatformID.Unix && !Conf.UseExternalBrowser)
                {
                    Utils.SetIeCompatibility();                                                                                //set to current IE version
                }
                var contentDir = !string.IsNullOrEmpty(Conf.DataFolder) ? Conf.DataFolder : StartupPath;
                if (!Directory.Exists(contentDir) || !SpringPaths.IsDirectoryWritable(contentDir))
                {
                    var dc = new SelectWritableFolder {
                        SelectedPath = SpringPaths.GetMySpringDocPath()
                    };
                    if (dc.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    contentDir = dc.SelectedPath;
                }
                if (Conf.DataFolder != StartupPath)
                {
                    Conf.DataFolder = contentDir;
                }
                else
                {
                    Conf.DataFolder = null;
                }

                if (!SpringPaths.IsDirectoryWritable(StartupPath))
                {
                    var newTarget = Path.Combine(contentDir, "Zero-K.exe");
                    if (SelfUpdater.CheckForUpdate(newTarget, true))
                    {
                        Conf.Save(Path.Combine(contentDir, Config.ConfigFileName));
                        Process.Start(newTarget);
                        return;
                    }
                    MessageBox.Show(new Form {
                        TopMost = true
                    }, "Move failed, please copy Zero-K.exe to a writable folder");
                    return;
                }



                SpringPaths = new SpringPaths(contentDir, true, true);

                if (
                    MessageBox.Show(new Form()
                {
                    TopMost = true
                },
                                    "WARNING: Zero-K lobby is now obsolete. Starting Chobby instead, ok? ",
                                    "WARNING: launcher obsolete",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    var targetPath = Path.Combine(SpringPaths.WritableDirectory, "Chobby.exe");
                    if (!File.Exists(targetPath))
                    {
                        var wc = new WebClient();
                        wc.DownloadFile(GlobalConst.BaseSiteUrl + "/lobby/Chobby.exe", targetPath);
                    }
                    Process.Start(targetPath);
                    Environment.Exit(0);
                }

                // speed up spring start
                SpringPaths.SpringVersionChanged += (sender, engine) =>
                {
                    ZkData.Utils.StartAsync(
                        () =>
                    {
                        UnitSync unitSync = null;
                        try
                        {
                            unitSync = new UnitSync(SpringPaths, engine);     // initialize unitsync to avoid slowdowns when starting

                            if (unitSync.UnitsyncWritableFolder != SpringPaths.WritableDirectory)
                            {
                                // unitsync created its cache in different folder than is used to start spring -> move it
                                var fi = ArchiveCache.GetCacheFile(unitSync.UnitsyncWritableFolder);
                                if (fi != null)
                                {
                                    File.Copy(fi.FullName, Path.Combine(SpringPaths.WritableDirectory, "cache", fi.Name), true);
                                }
                            }
                        }
                        finally
                        {
                            unitSync?.Dispose();
                        }
                    });
                };

                SaveConfig();


                // write license files
                try
                {
                    var path    = SpringPaths.WritableDirectory;
                    var pathGPL = Utils.MakePath(path, "license_GPLv3");
                    var gpl     = Encoding.UTF8.GetString(License.GPLv3);
                    if (!File.Exists(pathGPL))
                    {
                        File.WriteAllText(pathGPL, gpl);
                    }
                    var pathMIT = Utils.MakePath(path, "license_MIT");
                    var mit     = Encoding.UTF8.GetString(License.MITlicense);
                    if (!File.Exists(pathMIT))
                    {
                        File.WriteAllText(pathMIT, mit);
                    }
                }
                catch (Exception ex)
                {
                    Trace.TraceError(ex.ToString());
                }



                if (Conf.IsFirstRun)
                {
                    if (!IsSteamFolder)
                    {
                        Utils.CreateDesktopShortcut();
                    }
                    if (Environment.OSVersion.Platform != PlatformID.Unix)
                    {
                        Utils.RegisterProtocol();
                    }
                }

                MetaData           = new MetaDataCache(SpringPaths);
                AutoJoinManager    = new AutoJoinManager();
                EngineConfigurator = new EngineConfigurator(SpringPaths.WritableDirectory);

                SpringScanner = new PlasmaResourceChecker(SpringPaths);
                SpringScanner.LocalResourceAdded   += (s, e) => Trace.TraceInformation("New resource found: {0}", e.Item.InternalName);
                SpringScanner.LocalResourceRemoved += (s, e) => Trace.TraceInformation("Resource removed: {0}", e.Item.InternalName);
                Downloader = new PlasmaDownloader.PlasmaDownloader(SpringScanner, SpringPaths); //rapid
                Downloader.DownloadAdded += (s, e) => Trace.TraceInformation("Download started: {0}", e.Data.Name);
                //Downloader.GetResource(DownloadType.ENGINE, GlobalConst.DefaultEngineOverride);

                var isLinux = Environment.OSVersion.Platform == PlatformID.Unix;
                TasClient = new TasClient(string.Format("ZK {0}{1}", SelfUpdater.CurrentVersion, isLinux ? " linux" : ""));

                SayCommandHandler = new SayCommandHandler(TasClient);

                ServerImages = new ServerImagesHandler(SpringPaths, TasClient);


                // log, for debugging
                TasClient.Connected     += (s, e) => Trace.TraceInformation("TASC connected");
                TasClient.LoginAccepted += (s, e) =>
                {
                    Trace.TraceInformation("TASC login accepted");
                    Trace.TraceInformation("Server is using Spring version {0}", TasClient.ServerSpringVersion);
                    if (Environment.OSVersion.Platform == PlatformID.Unix || Conf.UseExternalBrowser)
                    {
                        if (MainWindow != null)
                        {
                            MainWindow.navigationControl.Path = "battles";
                        }
                    }
                };

                TasClient.LoginDenied     += (s, e) => Trace.TraceInformation("TASC login denied");
                TasClient.ChannelJoined   += (s, e) => { Trace.TraceInformation("TASC channel joined: " + e.Name); };
                TasClient.ConnectionLost  += (s, e) => Trace.TraceInformation("Connection lost");
                TasClient.WelcomeReceived += (s, e) =>
                {
                    Downloader.GetResource(DownloadType.ENGINE, e.Engine);
                    Downloader.GetResource(DownloadType.RAPID, e.Game);
                };

                Program.AreYouReadyDialog = new AreYouReadyDialog(TasClient);

                // special handling
                TasClient.PreviewSaid += (s, e) =>
                {
                    var  tas  = (TasClient)s;
                    User user = null;
                    if (e.Data.UserName != null)
                    {
                        tas.ExistingUsers.TryGetValue(e.Data.UserName, out user);
                        if ((user != null && user.BanMute) || TasClient.Ignores.Contains(e.Data.UserName))
                        {
                            e.Cancel = true;
                        }
                    }
                };

                TasClient.SiteToLobbyCommandReceived += (eventArgs, o) =>
                {
                    if (MainWindow != null)
                    {
                        MainWindow.navigationControl.Path = o.Command;
                        MainWindow.PopupSelf();
                    }
                };

                ModStore = new ModStore();

                ConnectBar        = new ConnectBar(TasClient);
                ToolTip           = new ToolTipHandler();
                BrowserInterop    = new BrowserInterop(TasClient, Conf);
                BattleIconManager = new BattleIconManager();
                Application.AddMessageFilter(ToolTip);

                SteamHandler = new ZklSteamHandler(TasClient);

                MainWindow = new MainWindow();

                Application.AddMessageFilter(new ScrollMessageFilter());

                MainWindow.Size = new Size(
                    Math.Min(SystemInformation.VirtualScreen.Width - 30, MainWindow.Width),
                    Math.Min(SystemInformation.VirtualScreen.Height - 30, MainWindow.Height)); //in case user have less space than 1024x768

                BattleBar     = new BattleBar();
                VoteBar       = new VoteBar();
                PwBar         = new PwBar();
                MatchMakerBar = new MatchMakerBar(TasClient);

                SelfUpdater.ProgramUpdated += s =>
                {
                    Program.MainWindow.InvokeFunc(
                        () => WarningBar.DisplayWarning($"New version of Zero-K launcher downloaded, restart it to apply changes", "Restart", Restart));
                };
                if (!Debugger.IsAttached && !Conf.DisableAutoUpdate && !IsSteamFolder)
                {
                    SelfUpdater.StartChecking();
                }

                if (GlobalConst.Mode != ModeType.Local)
                {
                    SteamHandler.Connect();
                }
                Application.Run(MainWindow);

                ShutDown();
            }
            catch (Exception ex)
            {
                ErrorHandling.HandleException(ex, true);
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }
            }
            finally
            {
                ShutDown();
            }
            if (ErrorHandling.HasFatalException && !CloseOnNext)
            {
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }
                Application.Restart();
            }
        }
        void client_Said(object sender, TasSayEventArgs e)
        {
            var tas = (TasClient)sender;

            if (Program.Conf.IgnoredUsers.Contains(e.UserName))
            {
                return;
            }

            if (e.Place == SayPlace.Battle && !e.IsEmote && !Program.TasClient.MyUser.IsInGame)
            {
                Program.MainWindow.NotifyUser("chat/battle", null);
            }
            if (e.Place == SayPlace.Channel && !IsIgnoredChannel(e.Channel))
            {
                Program.MainWindow.NotifyUser("chat/channel/" + e.Channel, null);
            }
            else if (e.Place == SayPlace.User)
            {
                var otherUserName = e.UserName == tas.UserName ? e.Channel : e.UserName;

                var pmControl = GetPrivateMessageControl(otherUserName);
                // block non friend messages
                if (pmControl == null && Program.Conf.BlockNonFriendPm && !Program.FriendManager.Friends.Contains(otherUserName) && !Program.TasClient.ExistingUsers[e.UserName].IsBot)
                {
                    if (e.UserName != Program.TasClient.UserName)
                    {
                        Program.TasClient.Say(SayPlace.User,
                                              otherUserName,
                                              "Sorry, I'm busy and do not receive messages. If you want to ask something, use #zk channel. If you have issue to report use http://code.google.com/p/zero-k/issues/list",
                                              false);
                    }
                }
                else
                {
                    pmControl = pmControl ?? CreatePrivateMessageControl(otherUserName);
                    if (!e.IsEmote)
                    {
                        pmControl.AddLine(new SaidLine(e.UserName, e.Text, e.Time));
                    }
                    else
                    {
                        pmControl.AddLine(new SaidExLine(e.UserName, e.Text, e.Time));
                    }
                    if (e.UserName != Program.TasClient.MyUser.Name)
                    {
                        MainWindow.Instance.NotifyUser("chat/user/" + otherUserName,
                                                       string.Format("{0}: {1}", otherUserName, e.Text),
                                                       false,
                                                       true);
                    }
                }
            }
            else if (e.Place == SayPlace.MessageBox)
            {
                Trace.TraceInformation("TASC: {0}", e.Text);
            }
            if (e.Place == SayPlace.MessageBox)
            {
                WarningBar.DisplayWarning(e.Text, "Message from server");
            }
        }
Exemple #11
0
 void TasClient_ChannelJoinFailed(object sender, JoinChannelResponse joinChannelResponse)
 {
     WarningBar.DisplayWarning("Channel Joining Error - " + joinChannelResponse.Reason);
 }
        public void StartMission(string missionName)
        {
            var down = Program.Downloader.GetResource(DownloadType.MISSION, missionName);

            if (down == null)
            {
                //okay Mission exist, but lets check for dependency!
                down = Program.Downloader.GetDependenciesOnly(missionName);
            }

            var engine = Program.Downloader.GetResource(DownloadType.ENGINE, Program.TasClient.ServerWelcome.Engine ?? GlobalConst.DefaultEngineOverride);

            var metaWait = new EventWaitHandle(false, EventResetMode.ManualReset);
            Mod modInfo  = null;

            Program.MetaData.GetModAsync(missionName,
                                         mod =>
            {
                if (!mod.IsMission)
                {
                    Program.MainWindow.InvokeFunc(() => { WarningBar.DisplayWarning(string.Format("{0} is not a valid mission", missionName)); });
                }

                else
                {
                    modInfo = mod;
                }

                metaWait.Set();
            },
                                         error =>
            {
                Program.MainWindow.InvokeFunc(() =>
                {
                    WarningBar.DisplayWarning(string.Format("Download of metadata failed: {0}", error.Message));
                    //container.btnStop.Enabled = true;
                });
                metaWait.Set();
            });

            var downloads = new List <Download>()
            {
                down, engine
            }.Where(x => x != null).ToList();

            if (downloads.Count > 0)
            {
                var dd = new WaitDownloadDialog(downloads);
                if (dd.ShowDialog(Program.MainWindow) == DialogResult.Cancel)
                {
                    Program.MainWindow.InvokeFunc(() => Program.NotifySection.RemoveBar(this));
                    return;
                }
            }
            metaWait.WaitOne();

            var spring = new Spring(Program.SpringPaths);

            spring.RunLocalScriptGame(modInfo.MissionScript, Program.TasClient.ServerWelcome.Engine ?? GlobalConst.DefaultEngineOverride);
            var cs = GlobalConst.GetContentService();

            cs.NotifyMissionRun(Program.Conf.LobbyPlayerName, missionName);
            spring.SpringExited += (o, args) => RecordMissionResult(spring, modInfo);
            Program.MainWindow.InvokeFunc(() => Program.NotifySection.RemoveBar(this));
        }
 void TasClient_BattleForceQuit(object sender, EventArgs e)
 {
     WarningBar.DisplayWarning("You were kicked from battle");
 }