Ejemplo n.º 1
0
 // we're reading a player_info_t, so take alignment into account
 protected override void Parse(ref BitStreamReader bsr)
 {
     if (DemoInfo.NewDemoProtocol && !DemoInfo.IsLeft4Dead1())
     {
         SteamId = (CSteamId)bsr.ReadULong();
     }
     Name   = bsr.ReadStringOfLength(MaxPlayerNameLength);
     UserId = bsr.ReadSInt();
     Guid   = bsr.ReadStringOfLength(SignedGuidLen + 1);
     bsr.SkipBytes(3);
     FriendsId   = bsr.ReadUInt();
     FriendsName = bsr.ReadStringOfLength(MaxPlayerNameLength);
     FakePlayer  = bsr.ReadByte() != 0;
     IsHlTv      = bsr.ReadByte() != 0;
     bsr.SkipBytes(2);
     CustomFiles     = new[] { bsr.ReadUInt(), bsr.ReadUInt(), bsr.ReadUInt(), bsr.ReadUInt() };
     FilesDownloaded = bsr.ReadByte();
     bsr.SkipBytes(3);
     // for demo protocol 4 there's 4 additional bytes somewhere for some reason
 }
        protected override void Parse(ref BitStreamReader bsr)
        {
            SendPropType = DemoInfo.SendPropTypes[(int)bsr.ReadUInt(5)];
            Name         = bsr.ReadNullTerminatedString();
            Flags        = (int)bsr.ReadUInt(DemoInfo.SendPropFlagBits);
            if (DemoInfo.NewDemoProtocol && !DemoInfo.IsLeft4Dead1())
            {
                Priority = bsr.ReadByte();
            }
            if (SendPropType == SendPropType.DataTable || DemoInfo.PropFlagChecker.HasFlag(Flags, PropFlag.Exclude))
            {
                ExcludeDtName = bsr.ReadNullTerminatedString();
            }
            else
            {
                switch (SendPropType)
                {
                case SendPropType.String:
                case SendPropType.Int:
                case SendPropType.Float:
                case SendPropType.Vector3:
                case SendPropType.Vector2:
                    LowValue  = bsr.ReadFloat();
                    HighValue = bsr.ReadFloat();
                    NumBits   = bsr.ReadUInt(DemoInfo.SendPropNumBitsToGetNumBits);
                    break;

                case SendPropType.Array:
                    NumElements = bsr.ReadUInt(10);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(SendPropType),
                                                          $"Invalid prop type: {SendPropType}");
                }
            }
        }