Exemple #1
0
        // Methods
        public EnterChatResponse(byte[] data) : base(data)
        {
            this.clientVersion  = -1;
            this.characterType  = BattleNetCharacter.Unknown;
            this.characterLevel = -1;
            this.characterAct   = -1;
            this.characterTitle = CharacterTitle.None;
            this.username       = ByteConverter.GetNullString(data, 3);
            int startIndex = 4 + this.username.Length;

            this.client = (BattleNetClient)BitConverter.ToUInt32(data, startIndex);
            if (data[startIndex += 4] == 0)
            {
                this.account = ByteConverter.GetNullString(data, startIndex + 1);
            }
            else
            {
                this.realm  = ByteConverter.GetString(data, startIndex, -1, 0x2c);
                startIndex += 1 + this.realm.Length;
                this.name   = ByteConverter.GetString(data, startIndex, -1, 0x2c);
                startIndex += 1 + this.name.Length;
                int num2 = ByteConverter.GetByteOffset(data, 0, startIndex);
                this.account = ByteConverter.GetNullString(data, (startIndex + num2) + 1);
                if (this.client == BattleNetClient.Diablo2LoD)
                {
                    this.characterFlags |= CharacterFlags.Expansion;
                }
                StatString.ParseD2StatString(data, startIndex, ref this.clientVersion, ref this.characterType, ref this.characterLevel, ref this.characterFlags, ref this.characterAct, ref this.characterTitle);
            }
        }
Exemple #2
0
        public CharacterList(byte[] data)
            : base(data)
        {
            this.Requested  = BitConverter.ToUInt16(data, 1);
            this.Total      = BitConverter.ToUInt32(data, 3);
            this.Listed     = BitConverter.ToUInt16(data, 7);
            this.Characters = new D2Packets.CharacterInfo[this.Listed];
            int startIndex = 9;

            for (int i = 0; (i < this.Listed) && (startIndex < data.Length); i++)
            {
                this.Characters[i]         = new D2Packets.CharacterInfo();
                this.Characters[i].Expires = TimeUtils.ParseUnixTimeUtc(BitConverter.ToUInt32(data, startIndex));
                this.Characters[i].Name    = ByteConverter.GetNullString(data, startIndex += 4);
                startIndex += this.Characters[i].Name.Length + 1;
                StatString.ParseD2StatString(data, startIndex, ref this.Characters[i].ClientVersion, ref this.Characters[i].Class, ref this.Characters[i].Level, ref this.Characters[i].Flags, ref this.Characters[i].Act, ref this.Characters[i].Title);
                startIndex = ByteConverter.GetBytePosition(data, 0, startIndex) + 1;
            }
        }
Exemple #3
0
        // Methods
        public ChatEvent(byte[] data) : base(data)
        {
            this.clientVersion  = -1;
            this.characterType  = BattleNetCharacter.Unknown;
            this.characterLevel = -1;
            this.characterAct   = -1;
            this.characterTitle = CharacterTitle.None;
            this.eventType      = (ChatEventType)BitConverter.ToUInt32(data, 3);
            this.flags          = BitConverter.ToUInt32(data, 7);
            this.ping           = BitConverter.ToUInt32(data, 11);
            int length = ByteConverter.GetByteOffset(data, 0, 0x1b);
            int num2   = ByteConverter.GetByteOffset(data, 0x2a, 0x1b, length);

            if (num2 > 0)
            {
                this.name = ByteConverter.GetString(data, 0x1b, num2);
                length   -= num2 + 1;
                num2     += 0x1c;
            }
            else if (num2 == 0)
            {
                num2 = 0x1c;
                length--;
                this.characterType = BattleNetCharacter.OpenCharacter;
            }
            else
            {
                num2 = 0x1b;
            }
            this.account = ByteConverter.GetString(data, num2, length);
            length      += num2 + 1;
            if (this.eventType != ChatEventType.ChannelLeave)
            {
                if ((this.eventType == ChatEventType.ChannelJoin) || (this.eventType == ChatEventType.ChannelUser))
                {
                    if ((data.Length - length) > 3)
                    {
                        this.client = (BattleNetClient)BitConverter.ToUInt32(data, length);
                        length     += 4;
                    }
                    if ((((this.client != BattleNetClient.StarcraftShareware) && (this.client != BattleNetClient.Starcraft)) && (this.client != BattleNetClient.StarcraftBroodWar)) && ((this.client == BattleNetClient.Diablo2) || (this.client == BattleNetClient.Diablo2LoD)))
                    {
                        if (this.client == BattleNetClient.Diablo2LoD)
                        {
                            this.characterFlags |= CharacterFlags.Expansion;
                        }
                        if ((data.Length - length) >= 4)
                        {
                            this.realm = ByteConverter.GetString(data, length, -1, 0x2c);
                            length    += this.realm.Length + 1;
                            if (data.Length >= length)
                            {
                                length += ByteConverter.GetByteOffset(data, 0x2c, length) + 1;
                                if (((length != -1) && (data.Length > length)) && ((data.Length - length) >= 0x21))
                                {
                                    StatString.ParseD2StatString(data, length, ref this.clientVersion, ref this.characterType, ref this.characterLevel, ref this.characterFlags, ref this.characterAct, ref this.characterTitle);
                                }
                            }
                        }
                    }
                }
                else
                {
                    this.message = ByteConverter.GetNullString(data, length);
                }
            }
        }