Example #1
0
        public static CrossParseResult Parse(string filename)
        {
            var cpr = new CrossParseResult();

            switch (CheckDemoType(filename))
            {
            case Parseresult.GoldSource:
                cpr.Type       = Parseresult.GoldSource;
                cpr.GsDemoInfo = GoldSourceParser.ParseGoldSourceDemo(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 fi = new FileInfo(filename);
                using (
                    var mmf = MemoryMappedFile.CreateFromFile(filename, FileMode.Open, "sourcemap", fi.Length + 1024,
                                                              MemoryMappedFileAccess.ReadWrite))
                    using (var cfs = mmf.CreateViewStream())
                    {
                        var a = new SourceParser(cfs);
                        cpr.Sdi = a.Info;
                        cfs.Close();
                    }
                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;
            }
            return(cpr);
        }
Example #2
0
        public DemoDecoder(Stream f)
        {
            InitializeComponent();
            File = f;
            messageList.Items.Clear();
            CurrentFile = new SourceParser(f);
            f.Close();

            foreach (var msg in CurrentFile.Info.Messages)
            {
                messageList.Items.Add(new DemoMessageItem(msg));
            }
        }
Example #3
0
        public static CrossParse Parse(string filename)
        {
            var cpr = new CrossParse();

            switch (CheckDemoType(filename))
            {
            case Parseresult.GoldSource:
            {
                GoldSourceParser.ParseDemoHlsooe(filename);
                break;
            }

            case Parseresult.UnsupportedFile:
            {
                Main.Log("Demotype check resulted in an unsupported file.");
                break;
            }

            case Parseresult.Source:
            {
                Stream cfs = File.Open(filename, FileMode.Open);
                var    a   = new SourceParser(cfs);
                cpr.Sdi = a.Info;
                cfs.Close();
                break;
            }

            default:
            {
                Main.Log(
                    "No idea how the f**k did this happen but default happened at switch(CheckDemoType(filename))");
                break;
            }
            }
            return(new CrossParse());
        }