Exemple #1
0
        public ChobbylaLocalListener(Chobbyla chobbyla, SteamClientHelper steam, ulong initialConnectLobbyID)
        {
            LastUserAction             = DateTime.Now;
            this.chobbyla              = chobbyla;
            this.steam                 = steam;
            steam.Listener             = this;
            this.initialConnectLobbyID = initialConnectLobbyID;
            serializer                 = new CommandJsonSerializer(Utils.GetAllTypesWithAttribute <ChobbyMessageAttribute>());
            tts = TextToSpeechBase.Create();
            steam.JoinFriendRequest          += SteamOnJoinFriendRequest;
            steam.OverlayActivated           += SteamOnOverlayActivated;
            steam.SteamOnline                += () => { SendSteamOnline(); };
            steam.SteamOffline               += () => { SendSteamOffline(); };
            discordController                 = new DiscordController(GlobalConst.ZeroKDiscordID, GlobalConst.SteamAppID.ToString());
            discordController.OnJoin         += DiscordOnJoinCallback;
            discordController.OnDisconnected += DiscordOnDisconnectedCallback;
            discordController.OnError        += DiscordOnErrorCallback;
            discordController.OnReady        += DiscordOnReadyCallback;
            discordController.OnRequest      += DiscordOnRequestCallback;
            discordController.OnSpectate     += DiscordOnSpectateCallback;

            timer      = new Timer((o) => OnTimerTick(), this, 500, 500);
            idleReport = new Timer((o) => SendCommand(new UserActivity()
            {
                IdleSeconds = WindowsApi.IdleTime.TotalSeconds
            }), this, 5000, 5000);
        }
        public ChobbylaForm(Chobbyla chobbyla)
        {
            this.chobbyla = chobbyla;
            InitializeComponent();
            btnCancel.Image      = Shraka.exit.GetResized(16, 16);
            btnCancel.ImageAlign = ContentAlignment.MiddleCenter;

            DoubleBuffered = true;
        }
Exemple #3
0
 public ChobbylaLocalListener(Chobbyla chobbyla, SteamClientHelper steam, ulong initialConnectLobbyID)
 {
     this.chobbyla              = chobbyla;
     this.steam                 = steam;
     steam.Listener             = this;
     this.initialConnectLobbyID = initialConnectLobbyID;
     serializer                 = new CommandJsonSerializer(Utils.GetAllTypesWithAttribute <ChobbyMessageAttribute>());
     tts = TextToSpeechBase.Create();
     steam.JoinFriendRequest += SteamOnJoinFriendRequest;
     steam.OverlayActivated  += SteamOnOverlayActivated;
     steam.SteamOnline       += () => { SendSteamOnline(); };
 }
        private static void Main(string[] args)
        {
            Trace.Listeners.Add(new ConsoleTraceListener());


            string chobbyTag = null;
            string engineOverride = null;
            if (args.Length > 0)
            {
                if (args[0] == "--help" || args[0] == "-h" || args[0] == "/?")
                {
                    MessageBox.Show("chobby.exe [rapid_tag] [engine_override] \n\nUse zkmenu:stable or chobby:test\nTo run local dev version use chobby.exe dev");
                }
                chobbyTag = args[0];
                if (args.Length > 1) engineOverride = args[1];
            }

            var startupPath = Path.GetDirectoryName(Path.GetFullPath(Application.ExecutablePath));
            if (!SpringPaths.IsDirectoryWritable(startupPath))
            {
                MessageBox.Show("Please move this program to a writable folder", "Cannot write to startup folder", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            Application.EnableVisualStyles();

            try
            {

                var chobbyla = new Chobbyla(startupPath, chobbyTag, engineOverride);
                var cf = new ChobbylaForm(chobbyla) { StartPosition = FormStartPosition.CenterScreen };
                if (cf.ShowDialog() == DialogResult.OK)
                {
                    chobbyla.Run().Wait();
                    Environment.Exit(0);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("Error starting chobby: {0}", ex);
                MessageBox.Show(ex.ToString(), "Error starting Chobby", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

        }
Exemple #5
0
        private static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

            if (!Debugger.IsAttached)
            {
                Trace.Listeners.Add(new ConsoleTraceListener());
            }

            var logStringBuilder = new StringBuilder();
            var threadSafeWriter = TextWriter.Synchronized(new StringWriter(logStringBuilder));

            Trace.Listeners.Add(new TextWriterTraceListener(threadSafeWriter));

            try
            {
                GameAnalytics.Initialize(GlobalConst.GameAnalyticsGameKey, GlobalConst.GameAnalyticsToken);
            }
            catch (Exception ex)
            {
                Trace.TraceError("Error starting GameAnalytics: {0}", ex);
            }

            string chobbyTag, engineOverride;
            ulong  connectLobbyID;

            ParseCommandLine(args, out connectLobbyID, out chobbyTag, out engineOverride);

            var startupPath = Path.GetDirectoryName(Path.GetFullPath(Application.ExecutablePath));

            if (!SpringPaths.IsDirectoryWritable(startupPath))
            {
                MessageBox.Show("Please move this program to a writable folder",
                                "Cannot write to startup folder",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                try
                {
                    GameAnalytics.AddErrorEvent(EGAErrorSeverity.Error, "Wrapper cannot start, folder not writable");
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Error adding GA error event: {0}", ex);
                }
                Environment.Exit(0);
                return;
            }

            Application.EnableVisualStyles();

            try
            {
                var chobbyla = new Chobbyla(startupPath, chobbyTag, engineOverride);
                RunWrapper(chobbyla, connectLobbyID, threadSafeWriter, logStringBuilder);
            }
            catch (Exception ex)
            {
                Trace.TraceError("Error starting chobby: {0}", ex);
                MessageBox.Show(ex.ToString(), "Error starting Chobby", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                try
                {
                    GameAnalytics.AddErrorEvent(EGAErrorSeverity.Critical, "Wrapper crash: " + ex);
                }
                catch (Exception ex2)
                {
                    Trace.TraceError("Error adding GA error event: {0}", ex2);
                }
            }

            try
            {
                GameAnalytics.OnStop();
            }
            catch (Exception ex)
            {
                Trace.TraceWarning("Error ending GA session: {0}", ex);
            }

            threadSafeWriter.Flush();
            try
            {
                File.WriteAllText(Path.Combine(startupPath, "infolog_full.txt"), logStringBuilder.ToString());
            }
            catch (Exception ex)
            {
                Trace.TraceWarning("Error writing full infolog: {0}", ex);
            }
            Environment.Exit(0);
        }
Exemple #6
0
        private static void RunWrapper(Chobbyla chobbyla, ulong connectLobbyID, TextWriter logWriter, StringBuilder logSb)
        {
            if (!chobbyla.IsSteamFolder) // not steam, show gui
            {
                var cf = new ChobbylaForm(chobbyla)
                {
                    StartPosition = FormStartPosition.CenterScreen
                };
                if (cf.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            else if (!chobbyla.Prepare().Result)
            {
                return;                                  // otherwise just do simple prepare, no gui
            }
            var springRunOk = chobbyla.Run(connectLobbyID, logWriter);

            Trace.TraceInformation("Spring exited");
            if (!springRunOk)
            {
                Trace.TraceWarning("Spring crash detected");
            }

            logWriter.Flush();
            var logStr = logSb.ToString();

            var syncError = CrashReportHelper.IsDesyncMessage(logStr);

            if (syncError)
            {
                Trace.TraceWarning("Sync error detected");
            }

            var openGlFail = logStr.Contains("No OpenGL drivers installed.") ||
                             logStr.Contains("Please go to your GPU vendor's website and download their drivers.") ||
                             logStr.Contains("minimum required OpenGL version not supported, aborting") ||
                             logStr.Contains("Update your graphic-card driver!");


            if (openGlFail)
            {
                Trace.TraceWarning("Outdated OpenGL detected");
                MessageBox.Show("You have outdated graphics card drivers!\r\nPlease try finding ones for your graphics card and updating them.", "Outdate graphics card driver detected", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if ((!springRunOk && !openGlFail) || syncError) // crash has occured
            {
                if (
                    MessageBox.Show("We would like to send crash/desync data to Zero-K repository, it can contain chat. Do you agree?",
                                    "Automated crash report",
                                    MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    var ret = CrashReportHelper.ReportCrash(logSb.ToString(), syncError, chobbyla.engine);
                    if (ret != null)
                    {
                        try
                        {
                            Process.Start(ret.HtmlUrl.ToString());
                        }
                        catch { }
                    }
                }

                try
                {
                    GameAnalytics.AddErrorEvent(EGAErrorSeverity.Critical, "Spring crash");
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Error adding GA error event: {0}", ex);
                }
            }
        }
 public ChobbylaForm(Chobbyla chobbyla)
 {
     InitializeComponent();
     DoubleBuffered = true;
     this.chobbyla = chobbyla;
 }
        private static void RunWrapper(Chobbyla chobbyla, ulong connectLobbyID, TextWriter logWriter, StringBuilder logSb)
        {
            if (!chobbyla.IsSteamFolder) // not steam, show gui
            {
                var cf = new ChobbylaForm(chobbyla)
                {
                    StartPosition = FormStartPosition.CenterScreen
                };
                if (cf.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            else if (!chobbyla.Prepare().Result)
            {
                return;                                  // otherwise just do simple prepare, no gui
            }
            var springRunOk = chobbyla.Run(connectLobbyID, logWriter);

            Trace.TraceInformation("Spring exited");
            if (!springRunOk)
            {
                Trace.TraceWarning("Spring crash detected");
            }

            logWriter.Flush();
            var logStr = logSb.ToString();

            var syncError = CrashReportHelper.IsDesyncMessage(logStr);

            if (syncError)
            {
                Trace.TraceWarning("Sync error detected");
            }

            var openGlFail = logStr.Contains("No OpenGL drivers installed.") ||
                             logStr.Contains("This stack trace indicates a problem with your graphic card driver") ||
                             logStr.Contains("Please go to your GPU vendor's website and download their drivers.") ||
                             logStr.Contains("minimum required OpenGL version not supported, aborting") ||
                             logStr.Contains("Update your graphic-card driver!");


            if (openGlFail)
            {
                Trace.TraceWarning("Outdated OpenGL detected");

                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    if (MessageBox.Show("You have outdated graphics card drivers!\r\nPlease try finding ones for your graphics card and updating them. \r\n\r\nWould you like to see our Linux graphics driver guide?", "Outdated graphics card driver detected", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        Process.Start("http://zero-k.info/mediawiki/index.php?title=Optimized_Graphics_Linux");
                    }
                }
                else
                {
                    MessageBox.Show("You have outdated graphics card drivers!\r\nPlease try finding ones for your graphics card and updating them.", "Outdated graphics card driver detected", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            var luaErr = logStr.Contains("LUA_ERRRUN");



            if ((!springRunOk && !openGlFail) || syncError || luaErr || !string.IsNullOrEmpty(chobbyla.BugReportTitle)) // crash has occured
            {
                if (
                    MessageBox.Show("We would like to send crash/desync data to Zero-K repository, it can contain chat. Do you agree?",
                                    "Automated crash report",
                                    MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    var crashType = syncError ? CrashType.Desync : luaErr ? CrashType.LuaError : CrashType.Crash;
                    if (!string.IsNullOrEmpty(chobbyla.BugReportTitle))
                    {
                        crashType = CrashType.UserReport;
                    }

                    var ret = CrashReportHelper.ReportCrash(logSb.ToString(), crashType, chobbyla.engine, chobbyla.BugReportTitle, chobbyla.BugReportDescription);
                    if (ret != null)
                    {
                        try
                        {
                            Process.Start(ret.HtmlUrl.ToString());
                        }
                        catch { }
                    }
                }

                try
                {
                    GameAnalytics.AddErrorEvent(EGAErrorSeverity.Critical, "Spring crash");
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Error adding GA error event: {0}", ex);
                }
            }
        }