示例#1
0
 public override Task Read(SourceBufferReader buf, SourceDemo demo)
 {
     Protocol    = buf.ReadInt16();
     ServerCount = buf.ReadInt32();
     IsHltv      = buf.ReadBoolean();
     IsDedicated = buf.ReadBoolean();
     ClientCrc   = buf.ReadInt32();
     MaxClasses  = buf.ReadUInt16();
     MapCrc      = buf.ReadInt32();
     PlayerSlot  = buf.ReadByte();
     MaxClients  = buf.ReadByte();
     if (demo.Protocol == 4)
     {
         Unk = buf.ReadInt32();
     }
     else if (demo.NetworkProtocol == 24)
     {
         Unk = buf.ReadBits(96);
     }
     TickInterval    = buf.ReadSingle();
     OperatingSystem = buf.ReadChar();
     GameDir         = buf.ReadString();
     MapName         = buf.ReadString();
     SkyName         = buf.ReadString();
     HostName        = buf.ReadString();
     return(Task.CompletedTask);
 }
示例#2
0
        public static Task Read(this SourceDemo demo, StringTables frame)
        {
            var buf    = frame.Buffer;
            int tables = buf.ReadByte();

            for (int i = 0; i < tables; i++)
            {
                var name  = buf.ReadString();
                var table = new StringTable(name);

                var entries = buf.ReadInt16();
                for (int j = 0; j < entries; j++)
                {
                    var entry   = buf.ReadString();
                    var data    = default(byte[]);
                    var version = default(long);
                    var xuid    = default(long);
                    var info    = default(TableInfoBase);

                    if (buf.ReadBoolean())
                    {
                        var length = buf.ReadInt16();
                        data = buf.ReadBytes(length);

                        // TODO
                        if (name == Const.INSTANCE_BASELINE_TABLENAME)
                        {
                            info = new InstanceBaseline()
                            {
                                Id = int.Parse(entry)
                            };
                        }
                        else if (name == Const.LIGHT_STYLES_TABLENAME)
                        {
                        }
                        else if (name == Const.SERVER_STARTUP_DATA_TABLENAME)
                        {
                        }
                        else if (name == Const.USER_INFO_TABLENAME)
                        {
                            var buf2 = new SourceBufferReader(data);
                            if (demo.GameDirectory == "csgo")
                            {
                                // 8 bytes
                                version = BitConverter.ToInt64(buf2.ReadBytes(8), 0);
                                // 8 bytes
                                xuid = BitConverter.ToInt64(buf2.ReadBytes(8), 0);
                            }
                            else
                            {
                                // 4 bytes
                                version = buf2.ReadInt32();
                                // 4 bytes
                                xuid = buf2.ReadInt32();
                            }

                            info = new PlayerInfo()
                            {
                                // 32 bytes
                                Name = Encoding.ASCII.GetString(buf2.ReadBytes(Const.MAX_PLAYER_NAME_LENGTH)).TrimEnd('\0'),
                                // 4 bytes
                                UserId = buf2.ReadInt32(),
                                // 33 bytes
                                Guid = Encoding.ASCII.GetString(buf2.ReadBytes(Const.SIGNED_GUID_LEN + 1)).TrimEnd('\0'),
                                // 4 bytes
                                FriendsId = buf2.ReadInt32(),
                                // 32 bytes
                                FriendsName = Encoding.ASCII.GetString(buf2.ReadBytes(Const.MAX_PLAYER_NAME_LENGTH)).TrimEnd('\0'),
                                // 1 byte
                                Fakeplayer = buf2.ReadBoolean(),
                                // 1 byte
                                IsHltv = buf2.ReadBoolean(),
                                // 16 bytes
                                CustomFiles = new int[4]
                                {
                                    buf2.ReadInt32(),
                                        buf2.ReadInt32(),
                                        buf2.ReadInt32(),
                                        buf2.ReadInt32()
                                },
                                // 2 bytes
                                FilesDownloaded = buf2.ReadChar()
                            };
                        }
                    }
                    table.AddEntry(new StringTableEntry()
                    {
                        Name    = entry,
                        RawData = data,
                        Version = version,
                        Xuid    = xuid,
                        Info    = info
                    });
                }

                if (buf.ReadBoolean())
                {
                    var centries = buf.ReadInt16();
                    for (var j = 0; j < centries; j++)
                    {
                        var centry = buf.ReadString();
                        var ddata  = default(byte[]);
                        if (buf.ReadBoolean())
                        {
                            var length = buf.ReadInt16();
                            ddata = buf.ReadBytes(length);
                        }
                        table.AddClientEntry(new ClientEntry()
                        {
                            Name    = centry,
                            RawData = ddata
                        });
                    }
                }
                frame.Tables.Add(table);
            }
            return(Task.CompletedTask);
        }