Esempio n. 1
0
        /// <summary>
        /// Parses a demo file from any engine
        /// </summary>
        /// <param name="filename">Path to the file</param>
        /// <returns></returns>
        public static CrossParseResult Parse(string filename)
        {
            var cpr = new CrossParseResult();

            switch (CheckDemoType(filename))
            {
            case Parseresult.GoldSource:
                cpr.Type       = Parseresult.GoldSource;
                cpr.GsDemoInfo = GoldSourceParser.ReadGoldSourceDemo(filename);
                break;

            case Parseresult.UnsupportedFile:
                cpr.Type = Parseresult.UnsupportedFile;
                Main.Log("Demotype check resulted in an unsupported file.");
                break;

            case Parseresult.Source:
                cpr.Type = Parseresult.Source;
                var a = new SourceParser(new MemoryStream(File.ReadAllBytes(filename)));
                cpr.Sdi = a.Info;
                if (cpr.Sdi.GameDirectory == "portal")
                {
                    cpr.Type = Parseresult.Portal;
                    var lp = new L4D2BranchParser();
                    cpr.L4D2BranchInfo = lp.Parse(filename);
                }
                break;

            case Parseresult.Hlsooe:
                cpr.Type           = Parseresult.Hlsooe;
                cpr.HlsooeDemoInfo = GoldSourceParser.ParseDemoHlsooe(filename);
                break;

            case Parseresult.L4D2Branch:
                cpr.Type = Parseresult.L4D2Branch;
                var l = new L4D2BranchParser();
                cpr.L4D2BranchInfo = l.Parse(filename);
                break;

            default:
                cpr.Type = Parseresult.UnsupportedFile;
                Main.Log(
                    "No idea how the f**k did this happen but default happened at switch(CheckDemoType(filename))");
                break;
            }
            if (cpr.Type == Parseresult.GoldSource)
            {
                if (cpr.GsDemoInfo.ParsingErrors.Count > 0)
                {
                    if (MessageBox.Show(@"Would you like to open the demo doctor?", @"Demo errors detected!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        using (var dd = new DemoDoctor(filename))
                            dd.ShowDialog();
                    }
                }
            }
            cpr.DisplayData = GetDemoDataTuples(cpr);
            return(cpr);
        }
Esempio n. 2
0
 /// <summary>
 ///     Show the demo doctor
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void demoDoctorToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var dd = new DemoDoctor(CurrentFile))
         dd.ShowDialog();
 }