示例#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);
            }
        }
示例#2
0
    private static string ConvertToString(StatString statString)
    {
        CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
        TextInfo    textInfo    = cultureInfo.TextInfo;

        return(textInfo.ToTitleCase(statString.ToString().Replace('_', ' ')));
    }
 public StatString Get(string key, string defaultValue = default(string))
 {
     StatString stat = StatsDictionary.Get(key);
     if (stat == null) {
         stat = new StatString(key, defaultValue);
         StatsDictionary.Add(stat.Key, stat);
         Stats.Add(stat);
     }
     return stat;
 }
    public StatString Get(string key, string defaultValue = default(string))
    {
        StatString stat = StatsDictionary.Get(key);

        if (stat == null)
        {
            stat = new StatString(key, defaultValue);
            StatsDictionary.Add(stat.Key, stat);
            Stats.Add(stat);
        }
        return(stat);
    }
示例#5
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;
            }
        }
示例#6
0
        public IPacket parse(BinaryReader br, int len)
        {
            x30GAMEDETAILS p = new x30GAMEDETAILS();

            p.product     = ConvertUtils.parseReverseString(br, 4);
            p.gameVersion = br.ReadUInt32();
            p.gameId      = br.ReadUInt32();
            p.entryKey    = br.ReadUInt32();
            p.gameName    = ConvertUtils.parseStringZ(br);
            p.passwd      = ConvertUtils.parseStringZ(br);
            p.stats       = StatString.decode(ConvertUtils.parseBytesZ(br));
            p.slots       = br.ReadUInt32();
            p.gameflags   = br.ReadUInt32();
            p.players     = br.ReadUInt32();
            p.freeslots   = br.ReadUInt32();
            p.age         = br.ReadUInt32();
            p.port        = br.ReadUInt16();
            return(p);
        }
示例#7
0
        public byte[] toBytes()
        {
            var d = new List <byte>();

            d.AddRange(ConvertUtils.fromStringReverse(product));
            d.AddRange(BitConverter.GetBytes(gameVersion));
            d.AddRange(BitConverter.GetBytes(gameId));
            d.AddRange(BitConverter.GetBytes(entryKey));
            d.AddRange(ConvertUtils.fromStringZ(gameName));
            d.AddRange(ConvertUtils.fromStringZ(passwd));
            d.AddRange(StatString.encode(stats));
            d.Add(00); //string padding
            d.AddRange(BitConverter.GetBytes(slots));
            d.AddRange(BitConverter.GetBytes(gameflags));
            d.AddRange(BitConverter.GetBytes(players));
            d.AddRange(BitConverter.GetBytes(freeslots));
            d.AddRange(BitConverter.GetBytes(age));
            d.AddRange(BitConverter.GetBytes(port));
            return(d.ToArray());
        }
示例#8
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);
                }
            }
        }