Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gr"></param>
        /// <param name="gr2"></param>
        /// <param name="sb"></param>
        /// <param name="swe"></param>
        /// <returns></returns>
        public static bool ParsePartyMemberStatsOpcode(GenericReader gr, GenericReader gr2, StringBuilder sb, StreamWriter swe, byte direction)
        {
            sb.AppendLine("Packet offset " + gr.BaseStream.Position.ToString("X2"));
            sb.AppendLine("Opcode SMSG_PARTY_MEMBER_STATS (0x007E)");

            byte MAX_AURAS = 56;

            ulong guid = gr2.ReadPackedGuid();
            sb.AppendLine("GUID " + guid.ToString("X16"));

            GroupUpdateFlags flags = (GroupUpdateFlags)gr2.ReadUInt32();
            sb.AppendLine("Flags " + flags);

            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_ONLINE) != 0)
            {
                GroupMemberOnlineStatus online = (GroupMemberOnlineStatus)gr2.ReadUInt16(); // flag
                sb.AppendLine("Online state " + online);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_CUR_HP) != 0)
            {
                ushort hp = gr2.ReadUInt16();
                sb.AppendLine("Cur. health " + hp);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_MAX_HP) != 0)
            {
                ushort maxhp = gr2.ReadUInt16();
                sb.AppendLine("Max health " + maxhp);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_POWER_TYPE) != 0)
            {
                Powers power = (Powers)gr2.ReadByte();
                sb.AppendLine("Power type " + power);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_CUR_POWER) != 0)
            {
                ushort curpower = gr2.ReadUInt16();
                sb.AppendLine("Cur. power " + curpower);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_MAX_POWER) != 0)
            {
                ushort maxpower = gr2.ReadUInt16();
                sb.AppendLine("Max power " + maxpower);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_LEVEL) != 0)
            {
                ushort level = gr2.ReadUInt16();
                sb.AppendLine("Level " + level);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_ZONE) != 0)
            {
                ushort zone = gr2.ReadUInt16();
                sb.AppendLine("Zone " + zone);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_POSITION) != 0)
            {
                short x = gr2.ReadInt16();
                short y = gr2.ReadInt16();
                sb.AppendLine("Position: " + x + ", " + y);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_AURAS) != 0)
            {
                ulong mask = gr2.ReadUInt64();
                sb.AppendLine("Auras mask " + mask.ToString("X16"));

                BitArray bitArr = new BitArray(BitConverter.GetBytes(mask));

                for (int i = 0; i < bitArr.Length; i++)
                {
                    if (i >= MAX_AURAS) // we can have only 56 auras
                        break;

                    if (bitArr[i])
                    {
                        ushort spellid = gr2.ReadUInt16();
                        sb.AppendLine("Aura " + i.ToString() + ": " + spellid.ToString());
                        byte unk = gr2.ReadByte();
                        sb.AppendLine("Aura unk " + i.ToString() + ": " + unk.ToString());
                    }
                }
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_PET_GUID) != 0)
            {
                ulong petguid = gr2.ReadUInt64();
                sb.AppendLine("Pet guid " + petguid.ToString("X16"));
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_PET_NAME) != 0)
            {
                string name = gr2.ReadStringNull();
                sb.AppendLine("Pet name " + name);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_PET_MODEL_ID) != 0)
            {
                ushort modelid = gr2.ReadUInt16();
                sb.AppendLine("Pet model id " + modelid);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_PET_CUR_HP) != 0)
            {
                ushort pethp = gr2.ReadUInt16();
                sb.AppendLine("Pet cur. HP " + pethp);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_PET_MAX_HP) != 0)
            {
                ushort petmaxhp = gr2.ReadUInt16();
                sb.AppendLine("Pet max HP " + petmaxhp);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_PET_POWER_TYPE) != 0)
            {
                Powers power = (Powers)gr2.ReadByte();
                sb.AppendLine("Pet power type " + power);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_PET_CUR_POWER) != 0)
            {
                ushort petpower = gr2.ReadUInt16();
                sb.AppendLine("Pet cur. power " + petpower);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_PET_MAX_POWER) != 0)
            {
                ushort petmaxpower = gr2.ReadUInt16();
                sb.AppendLine("Pet max power " + petmaxpower);
            }
            if ((flags & GroupUpdateFlags.GROUP_UPDATE_FLAG_PET_AURAS) != 0)
            {
                ulong mask = gr2.ReadUInt64();
                sb.AppendLine("Pet auras mask " + mask.ToString("X16"));

                BitArray bitArr = new BitArray(BitConverter.GetBytes(mask));
                for (int i = 0; i < bitArr.Length; i++)
                {
                    if (i >= MAX_AURAS) // we can have only 56 auras
                        break;

                    if (bitArr[i])
                    {
                        ushort spellid = gr2.ReadUInt16();
                        sb.AppendLine("Pet aura " + i.ToString() + ": " + spellid.ToString());
                        byte unk = gr2.ReadByte();
                        sb.AppendLine("Pet aura unk " + i.ToString() + ": " + unk.ToString());
                    }
                    i++;
                }
            }

            if (gr2.BaseStream.Position == gr2.BaseStream.Length)
                sb.AppendLine("parsed: ok...");
            else
                sb.AppendLine("parsed: error...");

            return true;
        }