예제 #1
0
파일: QDemo.cs 프로젝트: lagdotcom/qroute
        public static QDemo Load(string filename)
        {
            QDemo dem = new QDemo();

            using (FileStream stream = File.OpenRead(filename))
                using (BinaryReader br = new BinaryReader(stream))
                    dem.Read(br);

            return(dem);
        }
예제 #2
0
        public void Parse(QDemo dem)
        {
            short viewent = 0;

            if (!States.ContainsKey(0))
            {
                State     = new GameState(this, 0);
                States[0] = State;
            }
            Time = 0;

            foreach (QBlock block in dem.Blocks)
            {
                foreach (QMessage msg in block.Messages)
                {
                    switch (msg.ID)
                    {
                    case QMessageID.ClientData:
                        ClientData(msg as QClientDataMessage, viewent);
                        break;

                    case QMessageID.ServerInfo:
                        ServerInfo(msg as QServerInfoMessage);
                        break;

                    case QMessageID.SetView:
                        viewent = (msg as QSetViewMessage).Entity;
                        break;

                    case QMessageID.Time:
                        TimeMessage(msg as QTimeMessage);
                        break;

                    case QMessageID.UpdateColors:
                        UpdateColors(msg as QUpdateColorsMessage);
                        break;

                    case QMessageID.UpdateName:
                        UpdateName(msg as QUpdateNameMessage);
                        break;

                    default:
                        State.Apply(msg);
                        break;
                    }
                }
            }
        }
예제 #3
0
        private void MergeDemo(string filename)
        {
            QDemo      dem  = QDemo.Load(filename);
            ParsedDemo demo = new ParsedDemo();

            if (Demos.Count == 0)
            {
                MinTime = 100;
                MaxTime = 0;
            }
            demo.Parse(dem);
            Demos.Add(demo);

            MinTime = Math.Min(MinTime, demo.Start);
            MaxTime = Math.Max(MaxTime, demo.End);
        }
예제 #4
0
        private void OverlayDemo(string filename)
        {
            QDemo      dem = QDemo.Load(filename);
            ParsedDemo demo;

            if (Demos.Count > 0)
            {
                demo = Demos[0];
            }
            else
            {
                demo = new ParsedDemo();
                Demos.Add(demo);
                MinTime = 100;
                MaxTime = 0;
            }
            demo.Parse(dem);

            MinTime = Math.Min(MinTime, demo.Start);
            MaxTime = Math.Max(MaxTime, demo.End);
        }