コード例 #1
0
ファイル: CrossDemoParser.cs プロジェクト: Traderain/VVDemLib
        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);
        }
コード例 #2
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());
        }