예제 #1
0
        public void Read(StreamHandler Reader)
        {
            Flags = (SpellCastTargetFlags)Reader.ReadUInt32();

            if ((Flags & (
                SpellCastTargetFlags.Unit   | SpellCastTargetFlags.Unk2 |
                SpellCastTargetFlags.Object |
                SpellCastTargetFlags.Corpse | SpellCastTargetFlags.PvPCorpse
                )) != 0)
                TargetUnit = Reader.ReadPackedGuid();

            if ((Flags & (SpellCastTargetFlags.Item | SpellCastTargetFlags.TradeItem)) != 0)
                TargetItem = Reader.ReadPackedGuid();

            if ((Flags & SpellCastTargetFlags.SourceLocation) != 0)
            {
                SourceTransportGuid = Reader.ReadPackedGuid();
                SourceLocation = Reader.ReadVector3();
            }

            if ((Flags & SpellCastTargetFlags.DestLocation) != 0)
            {
                DestTransportGuid = Reader.ReadPackedGuid();
                DestLocation = Reader.ReadVector3();
            }

            if ((Flags & SpellCastTargetFlags.String) != 0)
                StringTarget = Reader.ReadCString();
        }
예제 #2
0
        public MirrorImageData(WowPlayer source, WowGuid destination)
        {
            this.Entity = destination;
            this.Model = source.Model;
            this.Race = source.Race;
            this.Gender = source.Gender;
            this.Class = source.Class;
            this.Skin = source.Skin;
            this.Face = source.Face;
            this.Hair = source.HairStyle;
            this.HairColor = source.HairColor;
            this.FaceFeatures = source.FaceFeatures;
            this.Guild = new WowGuid(source.GetULong(ObjectUpdateFields.OBJECT_FIELD_DATA));

            this.Head = source.GetVisibleItemEntry(InventorySlot.Head);
            this.Shoulders = source.GetVisibleItemEntry(InventorySlot.Shoulders);
            this.Body = source.GetVisibleItemEntry(InventorySlot.Body);
            this.Chest = source.GetVisibleItemEntry(InventorySlot.Chest);
            this.Waist = source.GetVisibleItemEntry(InventorySlot.Waist);
            this.Legs = source.GetVisibleItemEntry(InventorySlot.Legs);
            this.Feet = source.GetVisibleItemEntry(InventorySlot.Feet);
            this.Wrists = source.GetVisibleItemEntry(InventorySlot.Wrists);
            this.Hands = source.GetVisibleItemEntry(InventorySlot.Hands);
            this.Back = source.GetVisibleItemEntry(InventorySlot.Back);
            this.Tabard = source.GetVisibleItemEntry(InventorySlot.Tabard);
        }
예제 #3
0
        public override void Read(StreamHandler reader)
        {
            this.Unit = reader.ReadPackedGuid();
            this.Target = reader.ReadPackedGuid();

            var count = reader.ReadInt32();
            this.ThreatList = new ThreatUpdatePair[count];
            for (int i = 0; i < count; ++i)
                this.ThreatList[i] = new ThreatUpdatePair { Unit = reader.ReadPackedGuid(), Threat = reader.ReadUInt32() };
        }
예제 #4
0
        public override void Read(StreamHandler reader)
        {
            ContainerSlot = (InventorySlot)reader.ReadByte();
            Slot = (InventorySlot)reader.ReadByte();
            CastId = reader.ReadByte();
            SpellId = reader.ReadUInt32();
            ItemGuid = reader.ReadGuid();
            GlyphSlot = reader.ReadUInt32();
            UnkFlags = reader.ReadByte();

            TargetData.Read(reader);
        }
예제 #5
0
        public override void Read(StreamHandler reader)
        {
            Caster = reader.ReadPackedGuid();
            SpellId = reader.ReadUInt32();
            Duration = reader.ReadInt32();

            HaveFlags = reader.ReadBoolean();
            if (HaveFlags)
            {
                TargetFlags1 = reader.ReadUInt32();
                TargetFlags2 = reader.ReadUInt32();
            }

            Unk_HaveData2 = reader.ReadBoolean();
            if (Unk_HaveData2)
            {
                Unk_Guid1 = reader.ReadPackedGuid();
                Unk_UInt3 = reader.ReadUInt32();
                Unk_Byte = reader.ReadByte();
                if (Unk_Byte == 2)
                    Unk_Guid2 = reader.ReadPackedGuid();
            }
        }
예제 #6
0
        public override void Read(StreamHandler Reader)
        {
            Caster = Reader.ReadPackedGuid();
            CastInvoker = Reader.ReadPackedGuid();
            CastId = Reader.ReadByte();
            SpellId = Reader.ReadUInt32();
            Flags = (CastFlags)Reader.ReadUInt32();
            Unk43 = Reader.ReadUInt32();
            CastTime = Reader.ReadUInt32();

            byte hits = Reader.ReadByte();
            Hits.Capacity = hits;
            for (byte i = 0; i < hits; ++i)
                Hits.Add(Reader.ReadGuid());

            byte misses = Reader.ReadByte();
            Misses.Capacity = misses;
            for (byte i = 0; i < misses; ++i)
            {
                var miss = new MissData();
                miss.Read(Reader);
                Misses.Add(miss);
            }

            TargetData.Read(Reader);

            if ((Flags & CastFlags.PredictedPower) != 0)
                PredictedPower = Reader.ReadUInt32();

            if ((Flags & CastFlags.RuneStates) != 0)
            {
                RunesBefore = (RuneStates)Reader.ReadByte();
                RunesAfter = (RuneStates)Reader.ReadByte();
                for (int i = 0; i < RuneCooldowns.Length; ++i)
                    RuneCooldowns[i] = Reader.ReadByte();
            }

            if ((Flags & CastFlags.Unk0x00020000) != 0)
            {
                Unk0x20000_Float = Reader.ReadSingle();
                Unk0x20000_UInt32 = Reader.ReadUInt32();
            }

            if ((Flags & CastFlags.Ammo) != 0)
            {
                ProjectileDisplayId = Reader.ReadUInt32();
                ProjectileInventoryType = (InventorySlotType)Reader.ReadUInt32();
            }

            if ((Flags & CastFlags.Unk0x00080000) != 0)
            {
                Unk0x80000_UInt32_1 = Reader.ReadUInt32();
                Unk0x80000_UInt32_2 = Reader.ReadUInt32();
            }

            if ((TargetData.Flags & SpellCastTargetFlags.DestLocation) != 0)
                DestLocationCounter = Reader.ReadByte();

            if ((TargetData.Flags & SpellCastTargetFlags.Unk4) != 0)
            {
                uint count = Reader.ReadUInt32();
                Unk4_Count = count;
                Unk4_List.Capacity = (int)count;

                for (uint i = 0; i < count; ++i)
                {
                    Vector3 v3 = Reader.ReadVector3();
                    WowGuid guid = Reader.ReadGuid();
                    Unk4_List.Add(new KeyValuePair<WowGuid, Vector3>(guid, v3));
                    if (guid.IsEmpty)
                        break;
                }
            }
        }
예제 #7
0
 public void Read(StreamHandler Reader)
 {
     TargetGuid = Reader.ReadGuid();
     MissCondition = (CastMissReason)Reader.ReadByte();
     if (MissCondition == CastMissReason.Reflect)
         ReflectResult = Reader.ReadByte();
 }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of ChatMessage.
 /// </summary>
 /// <param name="type">Type of the current ChatMessage.</param>
 /// <param name="lang">Language of the current ChatMessage.</param>
 /// <param name="sender">Current ChatMessage's sender's GUID.</param>
 /// <param name="target">Current ChatMessage's target's GUID.</param>
 /// <param name="text">The actual text of the current ChatMessage.</param>
 public ServerChatMessage(ChatMessageType type, Language lang, WowGuid sender, WowGuid target, String text)
 {
     m_type = type;
     m_language = lang;
     m_senderGUID = sender;
     m_targetGUID = target;
     m_text = text;
 }
예제 #9
0
        public unsafe MovementInfo(StreamHandler Reader)
        {
            var guid = new WowGuid();
            this.HaveAttackingTarget = Reader.UnalignedReadBit();
            guid.Bytes[2] = Reader.UnalignedReadTinyInt(1);
            this.HaveVehicleData = Reader.UnalignedReadBit();
            guid.Bytes[1] = Reader.UnalignedReadTinyInt(1);
            guid.Bytes[4] = Reader.UnalignedReadTinyInt(1);
            guid.Bytes[3] = Reader.UnalignedReadTinyInt(1);
            this.HaveTransportTime = Reader.UnalignedReadBit();
            this.HaveGameObjectPosition = Reader.UnalignedReadBit();
            bool field_1C8 = Reader.UnalignedReadBit();
            bool field_1AC = Reader.UnalignedReadBit();
            this.HaveGameObjectRotation = Reader.UnalignedReadBit();
            this.Living = Reader.UnalignedReadBit();
            this.HavePosition = Reader.UnalignedReadBit();
            var arrCounter = Reader.UnalignedReadInt(24);
            guid.Bytes[0] = Reader.UnalignedReadTinyInt(1);

            bool havePFlags = false;
            WowGuid p_guid;
            uint splinePoints = 0;
            bool havePFlags2 = false;
            bool haveOrientation = false;

            if (this.Living)
            {
                this.HaveTransportData = Reader.UnalignedReadBit();
                if (this.HaveTransportData)
                {
                    fixed (byte* bytes = this.TransportGuid.Bytes)
                    {
                        bytes[2] = Reader.UnalignedReadTinyInt(1);
                        bytes[7] = Reader.UnalignedReadTinyInt(1);
                        bytes[5] = Reader.UnalignedReadTinyInt(1);
                        this.HaveTransportTime3 = Reader.UnalignedReadBit();
                        bytes[3] = Reader.UnalignedReadTinyInt(1);
                        bytes[0] = Reader.UnalignedReadTinyInt(1);
                        bytes[4] = Reader.UnalignedReadTinyInt(1);
                        bytes[1] = Reader.UnalignedReadTinyInt(1);
                        this.HaveTransportTime2 = Reader.UnalignedReadBit();
                        bytes[6] = Reader.UnalignedReadTinyInt(1);
                    }
                }

                this.HaveSpline2 = Reader.UnalignedReadBit();
                p_guid.Bytes[7] = Reader.UnalignedReadTinyInt(1);
                p_guid.Bytes[6] = Reader.UnalignedReadTinyInt(1);
                p_guid.Bytes[5] = Reader.UnalignedReadTinyInt(1);
                p_guid.Bytes[2] = Reader.UnalignedReadTinyInt(1);
                p_guid.Bytes[4] = Reader.UnalignedReadTinyInt(1);
                havePFlags = !Reader.UnalignedReadBit();
                p_guid.Bytes[1] = Reader.UnalignedReadTinyInt(1);
                this.SelfTarget = Reader.UnalignedReadBit();
                this.TimeStamp = !Reader.UnalignedReadBit() ? 1U : 0U;
                havePFlags2 = !Reader.UnalignedReadBit();

                if (this.HaveSpline2)
                {
                    this.HaveSpline = Reader.UnalignedReadBit();
                    if (this.HaveSpline)
                    {
                        this.Spline.HaveDurationMultiplier = Reader.UnalignedReadBit();
                        this.Spline.Flags = (SplineFlags)Reader.UnalignedReadInt(25);
                        this.Spline.SplineMode = (SplineMode)Reader.UnalignedReadTinyInt(2);
                        this.Spline.HaveUnknown1 = Reader.UnalignedReadBit();
                        splinePoints = Reader.UnalignedReadInt(22);
                        var type = Reader.UnalignedReadTinyInt(2);
                        switch (type)
                        {
                            case 0:
                                this.Spline.SplineType = SplineType.FacingSpot;
                                break;
                            case 1:
                                this.Spline.SplineType = SplineType.Normal;
                                break;
                            case 2:
                                this.Spline.SplineType = SplineType.FacingTarget;
                                break;
                            case 3:
                                this.Spline.SplineType = SplineType.FacingAngle;
                                break;
                        }
                        if (this.Spline.SplineType == SplineType.FacingTarget)
                        {
                            fixed (byte* bytes = this.Spline.FacingTarget.Bytes)
                            {
                                bytes[7] = Reader.UnalignedReadTinyInt(1);
                                bytes[3] = Reader.UnalignedReadTinyInt(1);
                                bytes[4] = Reader.UnalignedReadTinyInt(1);
                                bytes[2] = Reader.UnalignedReadTinyInt(1);
                                bytes[1] = Reader.UnalignedReadTinyInt(1);
                                bytes[6] = Reader.UnalignedReadTinyInt(1);
                                bytes[0] = Reader.UnalignedReadTinyInt(1);
                                bytes[5] = Reader.UnalignedReadTinyInt(1);
                            }
                        }
                    }
                }

                p_guid.Bytes[3] = Reader.UnalignedReadTinyInt(1);
                if (havePFlags)
                    this.Flags = (MovementFlags)Reader.UnalignedReadInt(30);
                this.HavePitch = !Reader.UnalignedReadBit();
                this.HaveFallData = Reader.UnalignedReadBit();

                if (havePFlags2)
                    this.Flags2 = (MovementFlags2)Reader.UnalignedReadSmallInt(12);

                p_guid.Bytes[0] = Reader.UnalignedReadTinyInt(1);
                haveOrientation = !Reader.UnalignedReadBit();

                if (this.HaveFallData)
                    this.HaveFallDirection = Reader.UnalignedReadBit();

                this.HaveSplineElevation = !Reader.UnalignedReadBit();
            }

            if (this.HaveGameObjectPosition)
            {
                fixed (byte* bytes = this.TransportGuid.Bytes)
                {
                    bytes[1] = Reader.UnalignedReadTinyInt(1);
                    this.HaveTransportTime3 = Reader.UnalignedReadBit();
                    bytes[3] = Reader.UnalignedReadTinyInt(1);
                    bytes[2] = Reader.UnalignedReadTinyInt(1);
                    bytes[6] = Reader.UnalignedReadTinyInt(1);
                    bytes[5] = Reader.UnalignedReadTinyInt(1);
                    bytes[0] = Reader.UnalignedReadTinyInt(1);
                    bytes[4] = Reader.UnalignedReadTinyInt(1);
                    this.HaveTransportTime2 = Reader.UnalignedReadBit();
                    bytes[7] = Reader.UnalignedReadTinyInt(1);
                }
            }

            ushort field_1B2 = 0;
            ushort field_1AE = 0;
            ushort field_1B0 = 0;
            if (field_1AC)
            {
                field_1B2 = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0);
                field_1AE = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0);
                field_1B0 = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0);
            }

            if (this.HaveAttackingTarget)
            {
                fixed (byte* bytes = this.AttackingTarget.Bytes)
                {
                    bytes[3] = Reader.UnalignedReadTinyInt(1);
                    bytes[4] = Reader.UnalignedReadTinyInt(1);
                    bytes[6] = Reader.UnalignedReadTinyInt(1);
                    bytes[0] = Reader.UnalignedReadTinyInt(1);
                    bytes[1] = Reader.UnalignedReadTinyInt(1);
                    bytes[7] = Reader.UnalignedReadTinyInt(1);
                    bytes[5] = Reader.UnalignedReadTinyInt(1);
                    bytes[2] = Reader.UnalignedReadTinyInt(1);
                }
            }

            this.UnkUInt32 = new uint[arrCounter];
            for (uint i = 0; i < arrCounter; ++i)
            {
                this.UnkUInt32[i] = Reader.ReadUInt32();
            }

            if (this.HavePosition)
            {
                Reader
                    .ReadSingle(out this.Position.Z)
                    .ReadSingle(out this.Orientation)
                    .ReadSingle(out this.Position.X)
                    .ReadSingle(out this.Position.Y);
            }

            if (this.HaveVehicleData)
            {
                Reader
                    .ReadUInt32(out this.VehicleId)
                    .ReadSingle(out this.VehicleAimAdjustement);
            }

            if (this.HaveGameObjectPosition)
            {
                fixed (byte* bytes = this.TransportGuid.Bytes)
                {
                    Reader
                        .ReadXorByte(ref bytes[1])
                        .ReadXorByte(ref bytes[4])
                        .ReadSingle(out this.TransportPosition.Z);

                    if (this.HaveTransportTime3)
                        this.TransportTime3 = Reader.ReadUInt32();

                    this.TransportTime = Reader.ReadUInt32();

                    Reader
                        .ReadXorByte(ref bytes[5])
                        .ReadXorByte(ref bytes[6])
                        .ReadSingle(out this.TransportPosition.X)
                        .ReadXorByte(ref bytes[2]);

                    if (this.HaveTransportTime2)
                        this.TransportTime2 = Reader.ReadUInt32();

                    Reader
                        .ReadSByte(out this.TransportSeat)
                        .ReadXorByte(ref bytes[3])
                        .ReadSingle(out this.TransportPosition.Y)
                        .ReadSingle(out this.TransportFacing)
                        .ReadXorByte(ref bytes[7])
                        .ReadXorByte(ref bytes[0]);
                }
            }

            if (this.Living)
            {
                if (this.HaveSpline2)
                {
                    if (this.HaveSpline)
                    {
                        var points = this.Spline.Points;
                        points.Capacity = (int)splinePoints;
                        for (int i = 0; i < splinePoints; i++)
                            points.Add(new Vector3()
                            {
                                Y = Reader.ReadSingle(),
                                X = Reader.ReadSingle(),
                                Z = Reader.ReadSingle()
                            });

                        if (this.Spline.HaveDurationMultiplier)
                        {
                            this.Spline.DurationMultiplier = Reader.ReadSingle();
                        }

                        this.Spline.UnknownFloat2 = Reader.ReadSingle();

                        if (this.Spline.SplineType == SplineType.FacingTarget)
                        {
                            fixed (byte* bytes = this.Spline.FacingTarget.Bytes)
                            {
                                Reader
                                    .ReadXorByte(ref bytes[3])
                                    .ReadXorByte(ref bytes[4])
                                    .ReadXorByte(ref bytes[5])
                                    .ReadXorByte(ref bytes[7])
                                    .ReadXorByte(ref bytes[2])
                                    .ReadXorByte(ref bytes[0])
                                    .ReadXorByte(ref bytes[6])
                                    .ReadXorByte(ref bytes[1]);
                            }
                        }

                        if (this.Spline.HaveUnknown1)
                        {
                            this.Spline.Unknown1 = Reader.ReadUInt32();
                        }

                        this.Spline.UnknownFloat3 = Reader.ReadSingle();
                        this.Spline.Unknown2 = Reader.ReadUInt32();

                        if (this.Spline.SplineType == SplineType.FacingSpot)
                        {
                            Reader
                                .ReadSingle(out this.Spline.FacingSpot.Y)
                                .ReadSingle(out this.Spline.FacingSpot.Z)
                                .ReadSingle(out this.Spline.FacingSpot.X);
                        }

                        this.Spline.CurrentTime = Reader.ReadUInt32();

                        if (this.Spline.SplineType == SplineType.FacingAngle)
                            this.Spline.FacingAngle = Reader.ReadSingle();
                    }

                    Reader
                        .ReadSingle(out this.Spline.EndPoint.Z)
                        .ReadSingle(out this.Spline.EndPoint.Y)
                        .ReadUInt32(out this.Spline.FullTime)
                        .ReadSingle(out this.Spline.EndPoint.X);
                }

                this.Speeds[8] = Reader.ReadSingle();

                // Transport Data
                if (this.HaveTransportData)
                {
                    fixed (byte* bytes = this.TransportGuid.Bytes)
                    {
                        Reader
                            .ReadXorByte(ref bytes[4])
                            .ReadSingle(out this.TransportPosition.Z)
                            .ReadXorByte(ref bytes[7])
                            .ReadXorByte(ref bytes[5])
                            .ReadXorByte(ref bytes[1])
                            .ReadSingle(out this.TransportPosition.X)
                            .ReadXorByte(ref bytes[3])
                            .ReadXorByte(ref bytes[6]);

                        if (this.HaveTransportTime3)
                            this.TransportTime3 = Reader.ReadUInt32();

                        Reader
                            .ReadSingle(out this.TransportPosition.Y)
                            .ReadSByte(out this.TransportSeat)
                            .ReadSingle(out this.TransportFacing);

                        if (this.HaveTransportTime2)
                            this.TransportTime2 = Reader.ReadUInt32();

                        Reader
                            .ReadXorByte(ref bytes[2])
                            .ReadUInt32(out this.TransportTime)
                            .ReadXorByte(ref bytes[0]);
                    }
                }

                Reader
                    .ReadSingle(out this.Speeds[7])
                    .ReadSingle(out this.Position.X);

                if (this.HavePitch)
                    Reader.ReadSingle(out this.Pitch);

                // Fall Data
                if (this.HaveFallData)
                {
                    Reader.ReadUInt32(out this.FallTime);
                    if (this.HaveFallDirection)
                    {
                        Reader
                            .ReadSingle(out this.FallSinAngle)
                            .ReadSingle(out this.FallHorizontalSpeed)
                            .ReadSingle(out this.FallCosAngle);
                    }
                    Reader.ReadSingle(out this.FallVerticalSpeed);
                }

                Reader
                    .ReadXorByte(ref p_guid.Bytes[7])
                    .ReadSingle(out this.Speeds[4])
                    .ReadXorByte(ref p_guid.Bytes[0])
                    .ReadXorByte(ref p_guid.Bytes[5]);

                if (this.TimeStamp != 0)
                    this.TimeStamp = Reader.ReadUInt32();

                Reader
                    .ReadSingle(out this.Position.Z)
                    .ReadSingle(out this.Speeds[6])
                    .ReadXorByte(ref p_guid.Bytes[1])
                    .ReadSingle(out this.Speeds[2])
                    .ReadSingle(out this.Speeds[5])
                    .ReadSingle(out this.Speeds[3])
                    .ReadSingle(out this.Speeds[0])
                    .ReadXorByte(ref p_guid.Bytes[3])
                    .ReadXorByte(ref p_guid.Bytes[4])
                    .ReadXorByte(ref p_guid.Bytes[2])
                    .ReadXorByte(ref p_guid.Bytes[6]);

                if (this.HaveSplineElevation)
                    this.SplineElevation = Reader.ReadSingle();

                this.Position.Y = Reader.ReadSingle();

                if (haveOrientation)
                    this.Orientation = Reader.ReadSingle();

                this.Speeds[1] = Reader.ReadSingle();
            }

            if (field_1C8)
            {
                Console.WriteLine("Error: 16 floats @ 1CC detected !!!");

                Reader.ReadBytes(16 * 4); // 16 floats starting at 1CC
                var field_20C = Reader.ReadByte();
            }

            // transport time
            if (this.HaveTransportTime)
                Reader.ReadUInt32(out this.TransportTime);

            // unk2 ?
            if (field_1AC)
            {
                Console.WriteLine("Error: 3 shorts @ 1AE detected !!!");

                if (field_1B0 != 0)
                    field_1B0 = Reader.ReadUInt16();
                if (field_1B2 != 0)
                    field_1B2 = Reader.ReadUInt16();
                if (field_1AE != 0)
                    field_1AE = Reader.ReadUInt16();
            }

            // go rotation?
            if (this.HaveGameObjectRotation)
                this.GameObjectRotation = Reader.ReadUInt64().UnpackQuaternion();

            // target guid?
            if (this.HaveAttackingTarget)
            {
                fixed (byte* bytes = this.AttackingTarget.Bytes)
                {
                    Reader
                        .ReadXorByte(ref bytes[3])
                        .ReadXorByte(ref bytes[5])
                        .ReadXorByte(ref bytes[0])
                        .ReadXorByte(ref bytes[7])
                        .ReadXorByte(ref bytes[2])
                        .ReadXorByte(ref bytes[4])
                        .ReadXorByte(ref bytes[6])
                        .ReadXorByte(ref bytes[1]);
                }
            }

            this.Guid = guid;
        }
예제 #10
0
 public AuraUpdate(WowGuid unit)
     : this()
 {
     this.Unit = unit;
 }
예제 #11
0
        public static void HandleVendorInventoryList(Packet packet)
        {
            var npcVendor = new NpcVendor();

            var guid = new byte[8];

            packet.ReadByte("Byte18");

            guid[1] = packet.ReadBit();
            guid[5] = packet.ReadBit();
            guid[0] = packet.ReadBit();
            guid[2] = packet.ReadBit();

            var itemCount = packet.ReadBits("itemCount", 18);

            guid[4] = packet.ReadBit();

            var hasExtendedCost = new bool[itemCount];
            var hasCondition    = new bool[itemCount];

            for (int i = 0; i < itemCount; ++i)
            {
                hasExtendedCost[i] = !packet.ReadBit();
                hasCondition[i]    = !packet.ReadBit();
                packet.ReadBit("Unk bit", i);
            }

            guid[3] = packet.ReadBit();
            guid[6] = packet.ReadBit();
            guid[7] = packet.ReadBit();

            npcVendor.VendorItems = new List <VendorItem>((int)itemCount);
            for (int i = 0; i < itemCount; ++i)
            {
                var vendorItem = new VendorItem();

                vendorItem.ItemId = (uint)packet.ReadEntry <Int32>(StoreNameType.Item, "Item ID", i);

                if (hasCondition[i])
                {
                    packet.ReadInt32("Condition ID", i);
                }

                packet.ReadInt32("Price", i);

                if (hasExtendedCost[i])
                {
                    vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i);
                }

                packet.ReadInt32("Display ID", i);
                var buyCount = packet.ReadUInt32("Buy Count", i);
                vendorItem.Slot = packet.ReadUInt32("Item Position", i);
                var maxCount = packet.ReadInt32("Max Count", i);
                vendorItem.Type = packet.ReadUInt32("Type", i); // 1 - item, 2 - currency
                packet.ReadInt32("Item Upgrade ID", i);
                packet.ReadInt32("Max Durability", i);

                npcVendor.VendorItems.Add(vendorItem);
            }

            packet.ParseBitStream(guid, 0, 2, 1, 3, 5, 7, 4, 6);

            packet.WriteGuid("Guid", guid);

            var vendorGUID = new WowGuid(BitConverter.ToUInt64(guid, 0));

            Storage.NpcVendors.Add(vendorGUID.GetEntry(), npcVendor, packet.TimeSpan);
        }
예제 #12
0
        public static void HandleAuraUpdate(Packet packet)
        {
            var guid = new byte[8];

            guid[3] = packet.ReadBit();
            guid[6] = packet.ReadBit();
            guid[0] = packet.ReadBit();
            guid[7] = packet.ReadBit();
            guid[5] = packet.ReadBit();
            guid[4] = packet.ReadBit();

            var bits0 = packet.ReadBits(24);

            var bit10 = packet.ReadBit();

            var hasAura        = new bool[bits0];
            var hasCasterGUID  = new bool[bits0];
            var hasMaxDuration = new bool[bits0];
            var hasDuration    = new bool[bits0];
            var bits48         = new uint[bits0];
            var casterGUID     = new byte[bits0][];
            var effectCount    = new uint[bits0];

            for (var i = 0; i < bits0; ++i)
            {
                hasAura[i] = packet.ReadBit();

                if (hasAura[i])
                {
                    effectCount[i] = packet.ReadBits(22);
                    bits48[i]      = packet.ReadBits(22);

                    hasCasterGUID[i] = packet.ReadBit();
                    if (hasCasterGUID[i])
                    {
                        casterGUID[i] = new byte[8];
                        packet.StartBitStream(casterGUID[i], 7, 4, 2, 5, 6, 1, 3, 0);
                    }

                    hasMaxDuration[i] = packet.ReadBit();
                    hasDuration[i]    = packet.ReadBit();
                }
            }

            guid[1] = packet.ReadBit();
            guid[2] = packet.ReadBit();

            var auras = new List <Aura>();

            for (var i = 0; i < bits0; ++i)
            {
                if (hasAura[i])
                {
                    var aura = new Aura();
                    if (hasCasterGUID[i])
                    {
                        packet.ParseBitStream(casterGUID[i], 0, 3, 7, 1, 2, 5, 4, 6);
                        packet.WriteGuid("Caster GUID", casterGUID[i], i);
                        aura.CasterGuid = new WowGuid(BitConverter.ToUInt64(casterGUID[i], 0));
                    }

                    if (hasDuration[i])
                    {
                        aura.Duration = packet.ReadInt32("Duration", i);
                    }
                    else
                    {
                        aura.Duration = 0;
                    }

                    for (var j = 0; j < bits48[i]; ++j)
                    {
                        packet.ReadSingle("Float3", i, j);
                    }

                    for (var j = 0; j < effectCount[i]; ++j)
                    {
                        packet.ReadSingle("Effect Value", i, j);
                    }

                    aura.Level = packet.ReadUInt16("Caster Level", i);

                    if (hasMaxDuration[i])
                    {
                        aura.MaxDuration = packet.ReadInt32("Max Duration", i);
                    }
                    else
                    {
                        aura.MaxDuration = 0;
                    }

                    aura.Charges   = packet.ReadByte("Charges", i);
                    aura.SpellId   = packet.ReadUInt32("Spell Id", i);
                    aura.AuraFlags = packet.ReadEnum <AuraFlagMoP>("Flags", TypeCode.Byte, i);
                    packet.ReadInt32("Effect Mask", i);

                    auras.Add(aura);
                    packet.AddSniffData(StoreNameType.Spell, (int)aura.SpellId, "AURA_UPDATE");
                }

                packet.ReadByte("Slot", i);
            }

            packet.ParseBitStream(guid, 5, 1, 2, 6, 0, 7, 4, 3);

            packet.WriteGuid("Guid", guid);

            var GUID = new WowGuid(BitConverter.ToUInt64(guid, 0));

            if (Storage.Objects.ContainsKey(GUID))
            {
                var unit = Storage.Objects[GUID].Item1 as Unit;
                if (unit != null)
                {
                    // If this is the first packet that sends auras
                    // (hopefully at spawn time) add it to the "Auras" field,
                    // if not create another row of auras in AddedAuras
                    // (similar to ChangedUpdateFields)

                    if (unit.Auras == null)
                    {
                        unit.Auras = auras;
                    }
                    else
                    {
                        unit.AddedAuras.Add(auras);
                    }
                }
            }
        }
예제 #13
0
        private static MovementInfo ReadMovementUpdateBlock(Packet packet, WowGuid guid, WoWObject obj, object index)
        {
            var moveInfo = new MovementInfo();

            packet.ResetBitReader();

            packet.ReadBit("NoBirthAnim", index);
            packet.ReadBit("EnablePortals", index);
            packet.ReadBit("PlayHoverAnim", index);

            var hasMovementUpdate     = packet.ReadBit("HasMovementUpdate", index);
            var hasMovementTransport  = packet.ReadBit("HasMovementTransport", index);
            var hasStationaryPosition = packet.ReadBit("Stationary", index);
            var hasCombatVictim       = packet.ReadBit("HasCombatVictim", index);
            var hasServerTime         = packet.ReadBit("HasServerTime", index);
            var hasVehicleCreate      = packet.ReadBit("HasVehicleCreate", index);
            var hasAnimKitCreate      = packet.ReadBit("HasAnimKitCreate", index);
            var hasRotation           = packet.ReadBit("HasRotation", index);
            var hasAreaTrigger        = packet.ReadBit("HasAreaTrigger", index);
            var hasGameObject         = packet.ReadBit("HasGameObject", index);
            var hasSmoothPhasing      = packet.ReadBit("HasSmoothPhasing", index);

            packet.ReadBit("ThisIsYou", index);

            var sceneObjCreate   = packet.ReadBit("SceneObjCreate", index);
            var playerCreateData = packet.ReadBit("HasPlayerCreateData", index);

            if (hasMovementUpdate)
            {
                packet.ResetBitReader();
                packet.ReadPackedGuid128("MoverGUID", index);

                packet.ReadUInt32("MoveTime", index);
                moveInfo.Position    = packet.ReadVector3("Position", index);
                moveInfo.Orientation = packet.ReadSingle("Orientation", index);

                packet.ReadSingle("Pitch", index);
                packet.ReadSingle("StepUpStartElevation", index);

                var removeForcesIDsCount = packet.ReadInt32();
                packet.ReadInt32("MoveIndex", index);

                for (var i = 0; i < removeForcesIDsCount; i++)
                {
                    packet.ReadPackedGuid128("RemoveForcesIDs", index, i);
                }

                moveInfo.Flags      = (MovementFlag)packet.ReadBitsE <V6_0_2_19033.Enums.MovementFlag>("Movement Flags", 30, index);
                moveInfo.FlagsExtra = (MovementFlagExtra)packet.ReadBitsE <Enums.MovementFlags2>("Extra Movement Flags", 18, index);

                var hasTransport = packet.ReadBit("Has Transport Data", index);
                var hasFall      = packet.ReadBit("Has Fall Data", index);
                packet.ReadBit("HasSpline", index);
                packet.ReadBit("HeightChangeFailed", index);
                packet.ReadBit("RemoteTimeValid", index);

                if (hasTransport)
                {
                    packet.ResetBitReader();
                    moveInfo.TransportGuid   = packet.ReadPackedGuid128("Transport Guid", index);
                    moveInfo.TransportOffset = packet.ReadVector4("Transport Position", index);
                    var seat = packet.ReadSByte("Transport Seat", index);
                    packet.ReadInt32("Transport Time", index);

                    var hasPrevMoveTime = packet.ReadBit("HasPrevMoveTime", index);
                    var hasVehicleRecID = packet.ReadBit("HasVehicleRecID", index);

                    if (hasPrevMoveTime)
                    {
                        packet.ReadUInt32("PrevMoveTime", index);
                    }

                    if (hasVehicleRecID)
                    {
                        packet.ReadUInt32("VehicleRecID", index);
                    }

                    if (moveInfo.TransportGuid.HasEntry() && moveInfo.TransportGuid.GetHighType() == HighGuidType.Vehicle &&
                        guid.HasEntry() && guid.GetHighType() == HighGuidType.Creature)
                    {
                        VehicleTemplateAccessory vehicleAccessory = new VehicleTemplateAccessory
                        {
                            Entry          = moveInfo.TransportGuid.GetEntry(),
                            AccessoryEntry = guid.GetEntry(),
                            SeatId         = seat
                        };
                        Storage.VehicleTemplateAccessories.Add(vehicleAccessory, packet.TimeSpan);
                    }
                }

                if (hasFall)
                {
                    packet.ResetBitReader();
                    packet.ReadUInt32("Fall Time", index);
                    packet.ReadSingle("JumpVelocity", index);

                    var hasFallDirection = packet.ReadBit("Has Fall Direction", index);
                    if (hasFallDirection)
                    {
                        packet.ReadVector2("Fall", index);
                        packet.ReadSingle("Horizontal Speed", index);
                    }
                }

                moveInfo.WalkSpeed = packet.ReadSingle("WalkSpeed", index) / 2.5f;
                moveInfo.RunSpeed  = packet.ReadSingle("RunSpeed", index) / 7.0f;
                packet.ReadSingle("RunBackSpeed", index);
                packet.ReadSingle("SwimSpeed", index);
                packet.ReadSingle("SwimBackSpeed", index);
                packet.ReadSingle("FlightSpeed", index);
                packet.ReadSingle("FlightBackSpeed", index);
                packet.ReadSingle("TurnRate", index);
                packet.ReadSingle("PitchRate", index);

                var movementForceCount = packet.ReadInt32("MovementForceCount", index);

                packet.ResetBitReader();

                moveInfo.HasSplineData = packet.ReadBit("HasMovementSpline", index);

                for (var i = 0; i < movementForceCount; ++i)
                {
                    packet.ResetBitReader();
                    packet.ReadPackedGuid128("Id", index);
                    packet.ReadVector3("Origin", index);
                    packet.ReadVector3("Direction", index);
                    packet.ReadInt32("TransportID", index);
                    packet.ReadSingle("Magnitude", index);
                    packet.ReadBits("Type", 2, index);
                }

                if (moveInfo.HasSplineData)
                {
                    packet.ResetBitReader();
                    packet.ReadInt32("ID", index);
                    packet.ReadVector3("Destination", index);

                    var hasMovementSplineMove = packet.ReadBit("MovementSplineMove", index);
                    if (hasMovementSplineMove)
                    {
                        packet.ResetBitReader();

                        packet.ReadUInt32E <SplineFlag>("SplineFlags", index);
                        packet.ReadUInt32("Elapsed", index);
                        packet.ReadUInt32("Duration", index);
                        packet.ReadSingle("DurationModifier", index);
                        packet.ReadSingle("NextDurationModifier", index);

                        var face = packet.ReadBits("Face", 2, index);

                        var hasJumpGravity = packet.ReadBit("HasJumpGravity", index);
                        var hasSpecialTime = packet.ReadBit("HasSpecialTime", index);

                        var pointsCount = packet.ReadBits("PointsCount", 16, index);

                        packet.ReadBitsE <SplineMode>("Mode", 2, index);

                        var hasSplineFilterKey      = packet.ReadBit("HasSplineFilterKey", index);
                        var hasSpellEffectExtraData = packet.ReadBit("HasSpellEffectExtraData", index);

                        if (hasSplineFilterKey)
                        {
                            packet.ResetBitReader();
                            var filterKeysCount = packet.ReadUInt32("FilterKeysCount", index);
                            for (var i = 0; i < filterKeysCount; ++i)
                            {
                                packet.ReadSingle("In", index, i);
                                packet.ReadSingle("Out", index, i);
                            }

                            packet.ReadBits("FilterFlags", 2, index);
                        }

                        if (face == 3)
                        {
                            packet.ReadSingle("FaceDirection", index);
                        }

                        if (face == 2)
                        {
                            packet.ReadPackedGuid128("FaceGUID", index);
                        }

                        if (face == 1)
                        {
                            packet.ReadVector3("FaceSpot", index);
                        }

                        if (hasJumpGravity)
                        {
                            packet.ReadSingle("JumpGravity", index);
                        }

                        if (hasSpecialTime)
                        {
                            packet.ReadInt32("SpecialTime", index);
                        }

                        for (var i = 0; i < pointsCount; ++i)
                        {
                            packet.ReadVector3("Points", index, i);
                        }

                        if (hasSpellEffectExtraData)
                        {
                            packet.ReadPackedGuid128("TargetGUID", index);
                            packet.ReadUInt32("SpellVisualID", index);
                            packet.ReadUInt32("ProgressCurveID", index);
                            packet.ReadUInt32("ParabolicCurveID", index);
                        }
                    }
                }
            }

            var pauseTimesCount = packet.ReadUInt32("PauseTimesCount", index);

            if (hasStationaryPosition)
            {
                moveInfo.Position    = packet.ReadVector3();
                moveInfo.Orientation = packet.ReadSingle();

                packet.AddValue("Stationary Position", moveInfo.Position, index);
                packet.AddValue("Stationary Orientation", moveInfo.Orientation, index);
            }

            if (hasCombatVictim)
            {
                packet.ReadPackedGuid128("CombatVictim Guid", index);
            }

            if (hasServerTime)
            {
                packet.ReadUInt32("ServerTime", index);
            }

            if (hasVehicleCreate)
            {
                moveInfo.VehicleId = packet.ReadUInt32("RecID", index);
                packet.ReadSingle("InitialRawFacing", index);
            }

            if (hasAnimKitCreate)
            {
                packet.ReadUInt16("AiID", index);
                packet.ReadUInt16("MovementID", index);
                packet.ReadUInt16("MeleeID", index);
            }

            if (hasRotation)
            {
                moveInfo.Rotation = packet.ReadPackedQuaternion("GameObject Rotation", index);
            }

            for (var i = 0; i < pauseTimesCount; ++i)
            {
                packet.ReadInt32("PauseTimes", index, i);
            }

            if (hasMovementTransport)
            {
                packet.ResetBitReader();
                moveInfo.TransportGuid   = packet.ReadPackedGuid128("TransportGUID", index);
                moveInfo.TransportOffset = packet.ReadVector4("TransportPosition", index);
                var seat = packet.ReadByte("VehicleSeatIndex", index);
                packet.ReadUInt32("MoveTime", index);

                var hasPrevMoveTime = packet.ReadBit("HasPrevMoveTime", index);
                var hasVehicleRecID = packet.ReadBit("HasVehicleRecID", index);

                if (hasPrevMoveTime)
                {
                    packet.ReadUInt32("PrevMoveTime", index);
                }

                if (hasVehicleRecID)
                {
                    packet.ReadInt32("VehicleRecID", index);
                }

                if (moveInfo.TransportGuid.HasEntry() && moveInfo.TransportGuid.GetHighType() == HighGuidType.Vehicle &&
                    guid.HasEntry() && guid.GetHighType() == HighGuidType.Creature)
                {
                    VehicleTemplateAccessory vehicleAccessory = new VehicleTemplateAccessory
                    {
                        Entry          = moveInfo.TransportGuid.GetEntry(),
                        AccessoryEntry = guid.GetEntry(),
                        SeatId         = seat
                    };
                    Storage.VehicleTemplateAccessories.Add(vehicleAccessory, packet.TimeSpan);
                }
            }

            if (hasAreaTrigger && obj is SpellAreaTrigger)
            {
                AreaTriggerTemplate areaTriggerTemplate = new AreaTriggerTemplate
                {
                    Id = guid.GetEntry()
                };

                SpellAreaTrigger spellAreaTrigger = (SpellAreaTrigger)obj;
                spellAreaTrigger.AreaTriggerId = guid.GetEntry();

                packet.ResetBitReader();

                // CliAreaTrigger
                packet.ReadInt32("ElapsedMs", index);

                packet.ReadVector3("RollPitchYaw1", index);

                areaTriggerTemplate.Flags = 0;

                if (packet.ReadBit("HasAbsoluteOrientation", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasAbsoluteOrientation;
                }

                if (packet.ReadBit("HasDynamicShape", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasDynamicShape;
                }

                if (packet.ReadBit("HasAttached", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasAttached;
                }

                if (packet.ReadBit("HasFaceMovementDir", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.FaceMovementDirection;
                }

                if (packet.ReadBit("HasFollowsTerrain", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.FollowsTerrain;
                }

                if (packet.ReadBit("Unk bit WoD62x", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.Unk1;
                }

                if (packet.ReadBit("HasTargetRollPitchYaw", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasTargetRollPitchYaw;
                }

                bool hasScaleCurveID  = packet.ReadBit("HasScaleCurveID", index);
                bool hasMorphCurveID  = packet.ReadBit("HasMorphCurveID", index);
                bool hasFacingCurveID = packet.ReadBit("HasFacingCurveID", index);
                bool hasMoveCurveID   = packet.ReadBit("HasMoveCurveID", index);

                if (packet.ReadBit("HasAnimID", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasAnimId;
                }

                if (packet.ReadBit("unkbit50", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.Unk3;
                }

                if (packet.ReadBit("HasAnimKitID", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasAnimKitId;
                }

                if (packet.ReadBit("HasAreaTriggerSphere", index))
                {
                    areaTriggerTemplate.Type = (byte)AreaTriggerType.Sphere;
                }

                if (packet.ReadBit("HasAreaTriggerBox", index))
                {
                    areaTriggerTemplate.Type = (byte)AreaTriggerType.Box;
                }

                if (packet.ReadBit("HasAreaTriggerPolygon", index))
                {
                    areaTriggerTemplate.Type = (byte)AreaTriggerType.Polygon;
                }

                if (packet.ReadBit("HasAreaTriggerCylinder", index))
                {
                    areaTriggerTemplate.Type = (byte)AreaTriggerType.Cylinder;
                }

                bool hasAreaTriggerSpline = packet.ReadBit("HasAreaTriggerSpline", index);

                if (packet.ReadBit("HasAreaTriggerUnkType", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasCircularMovement;
                }

                if ((areaTriggerTemplate.Flags & (uint)AreaTriggerFlags.Unk3) != 0)
                {
                    packet.ReadBit();
                }

                if (hasAreaTriggerSpline)
                {
                    AreaTriggerHandler.ReadAreaTriggerSpline(packet, index);
                }

                if ((areaTriggerTemplate.Flags & (uint)AreaTriggerFlags.HasTargetRollPitchYaw) != 0)
                {
                    packet.ReadVector3("TargetRollPitchYaw", index);
                }

                if (hasScaleCurveID)
                {
                    spellAreaTrigger.ScaleCurveId = packet.ReadInt32("ScaleCurveID", index);
                }

                if (hasMorphCurveID)
                {
                    spellAreaTrigger.MorphCurveId = packet.ReadInt32("MorphCurveID", index);
                }

                if (hasFacingCurveID)
                {
                    spellAreaTrigger.FacingCurveId = packet.ReadInt32("FacingCurveID", index);
                }

                if (hasMoveCurveID)
                {
                    spellAreaTrigger.MoveCurveId = packet.ReadInt32("MoveCurveID", index);
                }

                if ((areaTriggerTemplate.Flags & (int)AreaTriggerFlags.HasAnimId) != 0)
                {
                    spellAreaTrigger.AnimId = packet.ReadInt32("AnimId", index);
                }

                if ((areaTriggerTemplate.Flags & (int)AreaTriggerFlags.HasAnimKitId) != 0)
                {
                    spellAreaTrigger.AnimKitId = (int)packet.ReadUInt32("AnimKitId", index);
                }

                if (areaTriggerTemplate.Type == (byte)AreaTriggerType.Sphere)
                {
                    areaTriggerTemplate.Data[0] = packet.ReadSingle("Radius", index);
                    areaTriggerTemplate.Data[1] = packet.ReadSingle("RadiusTarget", index);
                }

                if (areaTriggerTemplate.Type == (byte)AreaTriggerType.Box)
                {
                    Vector3 Extents       = packet.ReadVector3("Extents", index);
                    Vector3 ExtentsTarget = packet.ReadVector3("ExtentsTarget", index);

                    areaTriggerTemplate.Data[0] = Extents.X;
                    areaTriggerTemplate.Data[1] = Extents.Y;
                    areaTriggerTemplate.Data[2] = Extents.Z;

                    areaTriggerTemplate.Data[3] = ExtentsTarget.X;
                    areaTriggerTemplate.Data[4] = ExtentsTarget.Y;
                    areaTriggerTemplate.Data[5] = ExtentsTarget.Z;
                }

                if (areaTriggerTemplate.Type == (byte)AreaTriggerType.Polygon)
                {
                    var verticesCount       = packet.ReadInt32("VerticesCount", index);
                    var verticesTargetCount = packet.ReadInt32("VerticesTargetCount", index);

                    List <AreaTriggerTemplateVertices> verticesList = new List <AreaTriggerTemplateVertices>();

                    areaTriggerTemplate.Data[0] = packet.ReadSingle("Height", index);
                    areaTriggerTemplate.Data[1] = packet.ReadSingle("HeightTarget", index);

                    for (uint i = 0; i < verticesCount; ++i)
                    {
                        AreaTriggerTemplateVertices areaTriggerTemplateVertices = new AreaTriggerTemplateVertices
                        {
                            AreaTriggerId = guid.GetEntry(),
                            Idx           = i
                        };

                        Vector2 vertices = packet.ReadVector2("Vertices", index, i);

                        areaTriggerTemplateVertices.VerticeX = vertices.X;
                        areaTriggerTemplateVertices.VerticeY = vertices.Y;

                        verticesList.Add(areaTriggerTemplateVertices);
                    }

                    for (var i = 0; i < verticesTargetCount; ++i)
                    {
                        Vector2 verticesTarget = packet.ReadVector2("VerticesTarget", index, i);

                        verticesList[i].VerticeTargetX = verticesTarget.X;
                        verticesList[i].VerticeTargetY = verticesTarget.Y;
                    }

                    foreach (AreaTriggerTemplateVertices vertice in verticesList)
                    {
                        Storage.AreaTriggerTemplatesVertices.Add(vertice);
                    }
                }

                if (areaTriggerTemplate.Type == (byte)AreaTriggerType.Cylinder)
                {
                    areaTriggerTemplate.Data[0] = packet.ReadSingle("Radius", index);
                    areaTriggerTemplate.Data[1] = packet.ReadSingle("RadiusTarget", index);
                    areaTriggerTemplate.Data[2] = packet.ReadSingle("Height", index);
                    areaTriggerTemplate.Data[3] = packet.ReadSingle("HeightTarget", index);
                    areaTriggerTemplate.Data[4] = packet.ReadSingle("LocationZOffset", index);
                    areaTriggerTemplate.Data[5] = packet.ReadSingle("LocationZOffsetTarget", index);
                }

                if ((areaTriggerTemplate.Flags & (uint)AreaTriggerFlags.HasCircularMovement) != 0)
                {
                    packet.ResetBitReader();
                    var unk1      = packet.ReadBit("AreaTriggerUnk1");
                    var hasCenter = packet.ReadBit("HasCenter", index);
                    packet.ReadBit("Unk bit 703 1", index);
                    packet.ReadBit("Unk bit 703 2", index);

                    packet.ReadUInt32();
                    packet.ReadInt32();
                    packet.ReadUInt32();
                    packet.ReadSingle("Radius", index);
                    packet.ReadSingle("BlendFromRadius", index);
                    packet.ReadSingle("InitialAngel", index);
                    packet.ReadSingle("ZOffset", index);

                    if (unk1)
                    {
                        packet.ReadPackedGuid128("AreaTriggerUnkGUID", index);
                    }

                    if (hasCenter)
                    {
                        packet.ReadVector3("Center", index);
                    }
                }

                Storage.AreaTriggerTemplates.Add(areaTriggerTemplate);
            }

            if (hasGameObject)
            {
                packet.ResetBitReader();
                packet.ReadInt32("WorldEffectID", index);

                var bit8 = packet.ReadBit("bit8", index);
                if (bit8)
                {
                    packet.ReadInt32("Int1", index);
                }
            }

            if (hasSmoothPhasing)
            {
                packet.ResetBitReader();
                packet.ReadBit("ReplaceActive", index);
                var replaceObject = packet.ReadBit();
                if (replaceObject)
                {
                    packet.ReadPackedGuid128("ReplaceObject", index);
                }
            }

            if (sceneObjCreate)
            {
                packet.ResetBitReader();

                var hasSceneLocalScriptData = packet.ReadBit("HasSceneLocalScriptData", index);
                var petBattleFullUpdate     = packet.ReadBit("HasPetBattleFullUpdate", index);

                if (hasSceneLocalScriptData)
                {
                    packet.ResetBitReader();
                    var dataLength = packet.ReadBits(7);
                    packet.ReadWoWString("Data", dataLength, index);
                }

                if (petBattleFullUpdate)
                {
                    V6_0_2_19033.Parsers.BattlePetHandler.ReadPetBattleFullUpdate(packet, index);
                }
            }

            if (playerCreateData)
            {
                packet.ResetBitReader();
                var hasSceneInstanceIDs = packet.ReadBit("ScenePendingInstances", index);
                var hasRuneState        = packet.ReadBit("Runes", index);

                if (hasSceneInstanceIDs)
                {
                    var sceneInstanceIDs = packet.ReadInt32("SceneInstanceIDsCount");
                    for (var i = 0; i < sceneInstanceIDs; ++i)
                    {
                        packet.ReadInt32("SceneInstanceIDs", index, i);
                    }
                }

                if (hasRuneState)
                {
                    packet.ReadByte("RechargingRuneMask", index);
                    packet.ReadByte("UsableRuneMask", index);
                    var runeCount = packet.ReadUInt32();
                    for (var i = 0; i < runeCount; ++i)
                    {
                        packet.ReadByte("RuneCooldown", index, i);
                    }
                }
            }

            return(moveInfo);
        }
예제 #14
0
        public static void HandleNpcGossip(Packet packet)
        {
            PacketGossipMessage packetGossip = packet.Holder.GossipMessage = new();
            var guidBytes = new byte[8];

            guidBytes[7] = packet.ReadBit();
            guidBytes[6] = packet.ReadBit();
            guidBytes[0] = packet.ReadBit();

            int questgossips = (int)packet.ReadBits(19);

            guidBytes[4] = packet.ReadBit();

            var titleLen = new uint[questgossips];

            for (int i = 0; i < questgossips; ++i)
            {
                titleLen[i] = packet.ReadBits(9);
                packet.ReadBit("Change Icon", i);
            }

            guidBytes[3] = packet.ReadBit();
            guidBytes[2] = packet.ReadBit();

            uint amountOfOptions = packet.ReadBits(20);

            var boxTextLen    = new uint[amountOfOptions];
            var optionTextLen = new uint[amountOfOptions];

            for (int i = 0; i < amountOfOptions; ++i)
            {
                boxTextLen[i]    = packet.ReadBits(12);
                optionTextLen[i] = packet.ReadBits(12);
            }

            guidBytes[1] = packet.ReadBit();
            guidBytes[5] = packet.ReadBit();

            packet.ReadXORByte(guidBytes, 2);

            var gossipOptions     = new List <GossipMenuOption>((int)amountOfOptions);
            var gossipOptionBoxes = new List <GossipMenuOptionBox>((int)amountOfOptions);

            for (int i = 0; i < amountOfOptions; ++i)
            {
                GossipMenuOption    gossipOption        = new GossipMenuOption();
                GossipMenuOptionBox gossipMenuOptionBox = new GossipMenuOptionBox();

                gossipMenuOptionBox.BoxText  = packet.ReadWoWString("Box Text", boxTextLen[i], i);
                gossipOption.OptionText      = packet.ReadWoWString("Text", optionTextLen[i], i);
                gossipOption.OptionIndex     = gossipMenuOptionBox.OptionIndex = packet.ReadUInt32("Index", i);
                gossipMenuOptionBox.BoxCoded = packet.ReadBool("Box", i);
                gossipOption.OptionIcon      = packet.ReadByteE <GossipOptionIcon>("Icon", i);
                gossipMenuOptionBox.BoxMoney = packet.ReadUInt32("Required money", i);

                gossipOptions.Add(gossipOption);
                if (!gossipMenuOptionBox.IsEmpty)
                {
                    gossipOptionBoxes.Add(gossipMenuOptionBox);
                }

                packetGossip.Options.Add(new GossipMessageOption()
                {
                    OptionIndex = gossipOption.OptionIndex.Value,
                    OptionIcon  = (int)gossipOption.OptionIcon,
                    BoxCoded    = gossipMenuOptionBox.BoxCoded.Value,
                    BoxCost     = gossipMenuOptionBox.BoxMoney.Value,
                    Text        = gossipOption.OptionText,
                    BoxText     = gossipMenuOptionBox.BoxText
                });
            }

            for (int i = 0; i < questgossips; ++i)
            {
                packet.ReadInt32("Level", i);
                packet.ReadUInt32E <QuestFlags>("Flags", i);
                packet.ReadUInt32("Icon", i);
                var title = packet.ReadWoWString("Title", titleLen[i], i);
                var quest = packet.ReadUInt32 <QuestId>("Quest ID", i);
                packet.ReadUInt32E <QuestFlagsEx>("Flags 2", i);

                packetGossip.Quests.Add(new GossipQuestOption()
                {
                    Title   = title,
                    QuestId = quest
                });
            }

            packet.ReadXORByte(guidBytes, 7);

            packet.ReadUInt32("Friendship Faction");

            packet.ReadXORByte(guidBytes, 3);
            packet.ReadXORByte(guidBytes, 1);

            uint textId = packetGossip.TextId = packet.ReadUInt32("Text Id");

            packet.ReadXORByte(guidBytes, 5);

            uint menuId = packetGossip.MenuId = packet.ReadUInt32("Menu Id");

            packet.ReadXORByte(guidBytes, 6);
            packet.ReadXORByte(guidBytes, 4);
            packet.ReadXORByte(guidBytes, 0);

            GossipMenu gossip = new GossipMenu
            {
                Entry  = menuId,
                TextID = textId
            };

            WowGuid guid = packet.WriteGuid("Guid", guidBytes);

            packetGossip.GossipSource = guid;

            gossip.ObjectType  = guid.GetObjectType();
            gossip.ObjectEntry = guid.GetEntry();

            if (guid.GetObjectType() == ObjectType.Unit)
            {
                if (Storage.Objects.ContainsKey(guid))
                {
                    ((Unit)Storage.Objects[guid].Item1).GossipId = menuId;
                }
            }

            gossipOptions.ForEach(g =>
            {
                g.MenuId = menuId;
                Storage.GossipMenuOptions.Add(g, packet.TimeSpan);
            });
            gossipOptionBoxes.ForEach(gb =>
            {
                gb.MenuId = menuId;
                Storage.GossipMenuOptionBoxes.Add(gb, packet.TimeSpan);
            });

            Storage.Gossips.Add(gossip, packet.TimeSpan);
            var lastGossipOption    = CoreParsers.NpcHandler.LastGossipOption;
            var tempGossipOptionPOI = CoreParsers.NpcHandler.TempGossipOptionPOI;

            if (lastGossipOption.HasSelection)
            {
                if ((packet.TimeSpan - lastGossipOption.TimeSpan).Duration() <= TimeSpan.FromMilliseconds(2500))
                {
                    Storage.GossipMenuOptionActions.Add(new GossipMenuOptionAction {
                        MenuId = lastGossipOption.MenuId, OptionIndex = lastGossipOption.OptionIndex, ActionMenuId = menuId
                    }, packet.TimeSpan);

                    //keep temp data (for case SMSG_GOSSIP_POI is delayed)
                    tempGossipOptionPOI.Guid         = lastGossipOption.Guid;
                    tempGossipOptionPOI.MenuId       = lastGossipOption.MenuId;
                    tempGossipOptionPOI.OptionIndex  = lastGossipOption.OptionIndex;
                    tempGossipOptionPOI.ActionMenuId = gossip.Entry;
                    tempGossipOptionPOI.TimeSpan     = lastGossipOption.TimeSpan;

                    // clear lastgossip so no faulty linkings appear
                    lastGossipOption.Reset();
                }
                else
                {
                    lastGossipOption.Reset();
                    tempGossipOptionPOI.Reset();
                }
            }

            packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));
        }
예제 #15
0
        protected virtual void ReadMovementData()
        {
            this.UnkByte      = Reader.ReadByte();
            m_currentPosition = Reader.ReadVector3();
            m_tickCount       = Reader.ReadUInt32();
            m_splineType      = (SplineType)Reader.ReadByte();

            switch (m_splineType)
            {
            case SplineType.Normal:
                break;

            case SplineType.Stop:
                // client sets following values to:
                // movementFlags = 0x1000;
                // moveTime = 0;
                // splinesCount = 1;
                m_points = new Vector3[0];
                return;

            case SplineType.FacingSpot:
                m_facingSpot = Reader.ReadVector3();
                break;

            case SplineType.FacingTarget:
                m_facingTarget = Reader.ReadGuid();
                break;

            case SplineType.FacingAngle:
                m_facingAngle = Reader.ReadSingle();
                break;

            default:
                throw new Exception("Not updated SplineType switch in MonsterMove (Read)");
            }

            m_splineFlags = (SplineFlags)Reader.ReadUInt32();

            if ((m_splineFlags & SplineFlags.Animation) != 0)
            {
                m_animEmote = Reader.ReadByte();
                m_animTime  = Reader.ReadUInt32();
            }

            m_moveTime = Reader.ReadUInt32();

            if ((m_splineFlags & SplineFlags.Parabolic) != 0)
            {
                m_trajectorySingle = Reader.ReadSingle();
                m_trajectoryUInt32 = Reader.ReadUInt32();
            }

            uint pointCount = Reader.ReadUInt32();

            m_points = new Vector3[pointCount];

            if ((m_splineFlags & (SplineFlags.Flying | SplineFlags.CatMullRom)) != 0)
            {
                for (uint i = 0; i < pointCount; ++i)
                {
                    m_points[i] = Reader.ReadVector3();
                }
            }
            else
            {
                m_points[0] = Reader.ReadVector3();

                var packedAgainst = new Vector3();
                packedAgainst.X = (m_currentPosition.X + m_points[0].X) * 0.5f;
                packedAgainst.Y = (m_currentPosition.Y + m_points[0].Y) * 0.5f;
                packedAgainst.Z = (m_currentPosition.Z + m_points[0].Z) * 0.5f;

                for (uint i = 1; i < pointCount; ++i)
                {
                    m_points[i] = Reader.ReadUInt32().UnpackAgainst(ref packedAgainst);
                }
            }
        }
예제 #16
0
 public override void Read(StreamHandler reader)
 {
     this.Unit = reader.ReadPackedGuid();
 }
예제 #17
0
 public ThreatClear(WowGuid guid)
 {
     this.Unit = guid;
 }
        private static MovementInfo ReadMovementUpdateBlock(Packet packet, WowGuid guid, object index)
        {
            var moveInfo = new MovementInfo();

            var guid1               = new byte[8];
            var transportGuid       = new byte[8];
            var goTransportGuid     = new byte[8];
            var attackingTargetGuid = new byte[8];
            var guid5               = new byte[8];
            var guid6               = new byte[8];
            var guid7               = new byte[8];

            var hasAnimKit1                   = false;
            var hasAnimKit2                   = false;
            var hasAnimKit3                   = false;
            var hasFullSpline                 = false;
            var hasSplineStartTime            = false;
            var hasSplineVerticalAcceleration = false;
            var hasGOTransportTime2           = false;
            var hasGOTransportTime3           = false;
            var hasSplineElevation            = false;
            var hasMovementFlags              = false;
            var hasMoveFlagsExtra             = false;
            var hasTimestamp                  = false;
            var hasOrientation                = false;
            var hasTransportData              = false;
            var hasTransportTime3             = false;
            var hasTransportTime2             = false;
            var hasPitch         = false;
            var hasFallData      = false;
            var hasFallDirection = false;

            var bit95  = false;
            var bit94  = false;
            var bit134 = false;
            var bitA8  = false;
            var bit228 = false;
            var bit270 = false;
            var bit21C = false;
            var bit244 = false;

            var bits168     = 0u;
            var splineCount = 0u;
            var bits138     = 0u;
            var bits98      = 0u;
            var bits248     = 0u;
            var bits258     = 0u;
            var bits274     = 0u;
            var bits3F4     = 0u;
            var bits28F     = 0u;
            var splineType  = SplineType.Stop;

            packet.ReadBit();
            var transportFrames       = packet.ReadBits(22);
            var hasVehicleData        = packet.ReadBit("Has Vehicle Data", index);
            var bit3F0                = packet.ReadBit();
            var hasGameObjectPosition = packet.ReadBit("Has GameObject Position", index);

            packet.ReadBit(); // fake bit
            var isSceneObject         = packet.ReadBit("Scene Object", index);
            var transport             = packet.ReadBit("On transport", index);
            var bit284                = packet.ReadBit();
            var bit208                = packet.ReadBit();
            var hasGameObjectRotation = packet.ReadBit("Has GameObject Rotation", index);
            var hasAttackingTarget    = packet.ReadBit("Has Attacking Target", index);

            packet.ReadBit();                             // fake bit
            packet.ReadBit();                             // fake bit
            packet.ReadBit("Self", index);
            packet.ReadBit();                             // fake bit
            var living                = packet.ReadBit("Living", index);
            var bit3E8                = packet.ReadBit(); // something with scene object
            var bit28E                = packet.ReadBit();
            var hasAnimKits           = packet.ReadBit("Has AnimKits", index);
            var hasStationaryPosition = packet.ReadBit("Has Stationary Position", index);

            if (living)
            {
                guid1[0]           = packet.ReadBit();
                hasSplineElevation = !packet.ReadBit();
                packet.StartBitStream(guid1, 4, 7);
                hasMoveFlagsExtra = !packet.ReadBit();
                packet.StartBitStream(guid1, 5, 2);
                moveInfo.HasSplineData = packet.ReadBit("Has spline data", index);
                hasMovementFlags       = !packet.ReadBit();
                hasTimestamp           = !packet.ReadBit("Lacks timestamp", index);
                bit95          = packet.ReadBit();
                bit94          = packet.ReadBit();
                hasOrientation = !packet.ReadBit();
                if (hasMovementFlags)
                {
                    moveInfo.Flags = packet.ReadBitsE <MovementFlag>("Movement Flags", 30, index);
                }

                hasTransportData = packet.ReadBit("Has Transport Data", index);
                if (hasTransportData)
                {
                    packet.StartBitStream(transportGuid, 1, 0, 6);
                    hasTransportTime3 = packet.ReadBit();
                    packet.StartBitStream(transportGuid, 2, 7, 4, 3);
                    hasTransportTime2 = packet.ReadBit();
                    transportGuid[5]  = packet.ReadBit();
                }

                hasPitch = !packet.ReadBit("Lacks pitch", index);
                guid1[6] = packet.ReadBit();
                bits168  = packet.ReadBits(19);
                for (var i = 0; i < bits168; ++i)
                {
                    packet.ReadBits("bits168", 2, index);
                }

                guid1[1] = packet.ReadBit();
                if (moveInfo.HasSplineData)
                {
                    hasFullSpline = packet.ReadBit();
                    if (hasFullSpline)
                    {
                        hasSplineStartTime = packet.ReadBit();
                        bit134             = packet.ReadBit();
                        packet.ReadBitsE <SplineMode>("Spline Mode", 2, index);
                        splineCount = packet.ReadBits("SplineWaypointsCount", 20, index);
                        hasSplineVerticalAcceleration = packet.ReadBit("Has Spline Vertical Acceleration", index);
                        if (bit134)
                        {
                            bits138 = packet.ReadBits(21);
                            packet.ReadBits("bits148", 2, index);
                        }
                        packet.ReadBitsE <SplineFlag434>("Spline flags", 25, index);
                    }
                }

                bitA8    = !packet.ReadBit();
                guid1[3] = packet.ReadBit();
                bits98   = packet.ReadBits(22);
                if (hasMoveFlagsExtra)
                {
                    moveInfo.FlagsExtra = packet.ReadBitsE <MovementFlagExtra>("Extra Movement Flags", 13, index);
                }

                hasFallData = packet.ReadBit("Has Fall Data", index);
                if (hasFallData)
                {
                    hasFallDirection = packet.ReadBit("Has Fall Direction", index);
                }

                packet.ReadBit("bitAC", index);
            }

            if (hasGameObjectPosition)
            {
                packet.StartBitStream(goTransportGuid, 7, 3);
                hasGOTransportTime2 = packet.ReadBit();
                packet.StartBitStream(goTransportGuid, 1, 4, 0, 2, 6);
                hasGOTransportTime3 = packet.ReadBit();
                goTransportGuid[5]  = packet.ReadBit();
            }

            if (hasAnimKits)
            {
                hasAnimKit2 = !packet.ReadBit();
                hasAnimKit3 = !packet.ReadBit();
                hasAnimKit1 = !packet.ReadBit();
            }

            if (hasAttackingTarget)
            {
                attackingTargetGuid = packet.StartBitStream(7, 3, 6, 1, 5, 4, 0, 2);
            }

            if (bit208)
            {
                packet.ReadBit("bit21A", index);
                bit228 = packet.ReadBit();
                bit270 = packet.ReadBit();
                packet.ReadBit("bit219", index);
                packet.ReadBit("bit218", index);
                bit21C = packet.ReadBit();
                bit244 = packet.ReadBit();

                if (bit244)
                {
                    bits248 = packet.ReadBits(21);
                    bits258 = packet.ReadBits(21);
                }

                if (bit270)
                {
                    bits274 = packet.ReadBits(20);
                }

                packet.ReadBit("bit21B", index);
            }

            // Sceneobject data
            var CreatorGUID = new byte[8];

            byte[][]   guid310        = null;
            byte[][][] guid34C_4      = null;
            uint[]     bits34C_0      = null;
            uint[][]   bits34C_4_84   = null;
            uint[][]   bits34C_4_94   = null;
            uint[][]   bits34C_4_31   = null;
            uint[][]   bits34C_4_74   = null;
            byte[][][] bit34C_4_78_9  = null;
            byte[][][] bit34C_4_88_10 = null;
            bool[][][] bit34C_4_88_C  = null;
            bool[][][] bit34C_4_88_8  = null;
            bool[][]   bit34C_4_2E    = null;
            bool[][]   bit34C_4_30    = null;
            bool[]     bit34C_4       = null;
            bool[]     bit34C_8       = null;

            var bit318 = false;
            var bit31A = false;
            var bit329 = false;
            var bit320 = false;
            var bit328 = false;
            var bit324 = false;

            uint[]   bits388     = null;
            uint[]   bits388_10  = null;
            byte[][] bit388_1_10 = null;
            bool[][] bit388_1_C  = null;
            bool[][] bit388_1_8  = null;

            if (isSceneObject)
            {
                guid310        = new byte[2][];
                guid34C_4      = new byte[2][][];
                bits34C_0      = new uint[2];
                bits34C_4_84   = new uint[2][];
                bits34C_4_94   = new uint[2][];
                bits34C_4_31   = new uint[2][];
                bits34C_4_74   = new uint[2][];
                bit34C_4_78_9  = new byte[2][][];
                bit34C_4_88_10 = new byte[2][][];
                bit34C_4_88_C  = new bool[2][][];
                bit34C_4_88_8  = new bool[2][][];
                bit34C_4_2E    = new bool[2][];
                bit34C_4_30    = new bool[2][];
                bit34C_4       = new bool[2];
                bit34C_8       = new bool[2];

                for (var i = 0; i < 2; ++i)
                {
                    guid310[i] = new byte[8];
                    packet.StartBitStream(guid310[i], 7, 6);
                    bits34C_0[i] = packet.ReadBits(2);

                    guid34C_4[i]      = new byte[bits34C_0[i]][];
                    bits34C_4_84[i]   = new uint[bits34C_0[i]];
                    bits34C_4_94[i]   = new uint[bits34C_0[i]];
                    bits34C_4_31[i]   = new uint[bits34C_0[i]];
                    bits34C_4_74[i]   = new uint[bits34C_0[i]];
                    bit34C_4_78_9[i]  = new byte[bits34C_0[i]][];
                    bit34C_4_88_10[i] = new byte[bits34C_0[i]][];
                    bit34C_4_88_C[i]  = new bool[bits34C_0[i]][];
                    bit34C_4_88_8[i]  = new bool[bits34C_0[i]][];
                    bit34C_4_2E[i]    = new bool[bits34C_0[i]];
                    bit34C_4_30[i]    = new bool[bits34C_0[i]];

                    for (var j = 0; j < bits34C_0[i]; ++j)
                    {
                        guid34C_4[i][j]   = new byte[8];
                        bit34C_4_2E[i][j] = !packet.ReadBit();
                        packet.StartBitStream(guid34C_4[i][j], 7, 0, 6, 3);

                        bits34C_4_84[i][j]   = packet.ReadBits(21);
                        bit34C_4_88_8[i][j]  = new bool[bits34C_4_84[i][j]];
                        bit34C_4_88_C[i][j]  = new bool[bits34C_4_84[i][j]];
                        bit34C_4_88_10[i][j] = new byte[bits34C_4_84[i][j]];

                        for (var k = 0; k < bits34C_4_84[i][j]; ++k)
                        {
                            bit34C_4_88_10[i][j][k] = (byte)(10 - packet.ReadBit());
                            bit34C_4_88_C[i][j][k]  = !packet.ReadBit();
                            bit34C_4_88_8[i][j][k]  = !packet.ReadBit();
                        }

                        bits34C_4_94[i][j] = packet.ReadBits(21);
                        packet.StartBitStream(guid34C_4[i][j], 2);
                        bit34C_4_30[i][j] = packet.ReadBit();
                        packet.StartBitStream(guid34C_4[i][j], 5, 4, 1);

                        bits34C_4_74[i][j]  = packet.ReadBits(20);
                        bit34C_4_78_9[i][j] = new byte[bits34C_4_74[i][j]];

                        for (var k = 0; k < bits34C_4_74[i][j]; ++k)
                        {
                            bit34C_4_78_9[i][j][k] = (byte)(10 - packet.ReadBit());
                        }

                        bits34C_4_31[i][j] = packet.ReadBits(7);
                    }

                    bit34C_8[i] = !packet.ReadBit();
                    packet.StartBitStream(guid310[i], 3, 5, 2);
                    bit34C_4[i] = packet.ReadBit();
                    packet.StartBitStream(guid310[i], 1, 0, 4);
                }

                bits388     = new uint[3];
                bits388_10  = new uint[3];
                bit388_1_10 = new byte[3][];
                bit388_1_C  = new bool[3][];
                bit388_1_8  = new bool[3][];

                for (var i = 0; i < 3; ++i)
                {
                    bits388[i]     = packet.ReadBits(21);
                    bit388_1_10[i] = new byte[bits388[i]];
                    bit388_1_C[i]  = new bool[bits388[i]];
                    bit388_1_8[i]  = new bool[bits388[i]];

                    for (var j = 0; j < bits388[i]; ++j)
                    {
                        bit388_1_10[i][j] = (byte)(10 - packet.ReadBit());
                        bit388_1_C[i][j]  = packet.ReadBit();
                        bit388_1_8[i][j]  = packet.ReadBit();
                    }

                    bits388_10[i] = packet.ReadBits(21);
                }

                bit31A = !packet.ReadBit();
                bit329 = !packet.ReadBit();
                bit320 = !packet.ReadBit();
                bit328 = !packet.ReadBit();
                packet.ReadBit(); // fake bit
                packet.StartBitStream(CreatorGUID, 7, 1, 0, 2, 3, 6, 4, 5);
                bit324 = !packet.ReadBit();
                bit318 = !packet.ReadBit();
            }

            if (bit3F0)
            {
                bits3F4 = packet.ReadBits(22);
            }

            if (bit28E)
            {
                bits28F = packet.ReadBits(7);
            }

            packet.ResetBitReader();

            for (var i = 0; i < transportFrames; ++i)
            {
                packet.ReadInt32("Transport frame", i, index);
            }

            if (living)
            {
                if (hasTimestamp)
                {
                    packet.ReadUInt32("Time", index);
                }

                for (var i = 0; i < bits168; ++i)
                {
                    packet.ReadSingle("Float16C+5", index);
                    packet.ReadInt32("Int16C+4", index);
                    packet.ReadSingle("Float16C+1", index);
                    packet.ReadInt32("Int16C+0", index);
                    packet.ReadSingle("Float16C+2", index);
                    packet.ReadSingle("Float16C+3", index);
                }

                if (moveInfo.HasSplineData)
                {
                    if (hasFullSpline)
                    {
                        if (hasSplineStartTime)
                        {
                            packet.ReadInt32("Spline Start Time", index);
                        }

                        packet.ReadSingle("Spline Duration Multiplier", index);
                        if (hasSplineVerticalAcceleration)
                        {
                            packet.ReadSingle("Spline Vertical Acceleration", index);
                        }

                        packet.ReadInt32("Spline Time", index);
                        for (var i = 0u; i < splineCount; ++i)
                        {
                            var wp = new Vector3
                            {
                                Z = packet.ReadSingle(),
                                Y = packet.ReadSingle(),
                                X = packet.ReadSingle()
                            };

                            packet.AddValue("Spline Waypoint", wp, index, i);
                        }

                        if (bit134)
                        {
                            for (var i = 0; i < bits138; ++i)
                            {
                                packet.ReadSingle("Float13C+1", index, i);
                                packet.ReadSingle("Float13C+0", index, i);
                            }
                        }

                        packet.ReadSingle("Spline Duration Multiplier Next", index);
                        var type = packet.ReadByte();
                        switch (type)
                        {
                        case 1:
                            splineType = SplineType.Normal;
                            break;

                        case 2:
                            splineType = SplineType.FacingSpot;
                            break;

                        case 3:
                            splineType = SplineType.FacingTarget;
                            break;

                        case 4:
                            splineType = SplineType.FacingAngle;
                            break;
                        }

                        if (splineType == SplineType.FacingAngle)
                        {
                            packet.ReadSingle("Facing Angle", index);
                        }

                        if (splineType == SplineType.FacingSpot)
                        {
                            var point = new Vector3
                            {
                                X = packet.ReadSingle(),
                                Z = packet.ReadSingle(),
                                Y = packet.ReadSingle()
                            };

                            packet.AddValue("Facing Spot", point, index);
                        }

                        packet.ReadInt32("Spline Full Time", index);
                    }

                    moveInfo.Position.Y = packet.ReadSingle();
                    moveInfo.Position.Z = packet.ReadSingle();
                    packet.ReadInt32("Spline Id", index);
                    moveInfo.Position.X = packet.ReadSingle();
                }

                if (hasTransportData)
                {
                    packet.ReadXORByte(transportGuid, 4);
                    moveInfo.TransportOffset.Z = packet.ReadSingle();
                    moveInfo.TransportOffset.Y = packet.ReadSingle();
                    packet.ReadUInt32("Transport Time", index);
                    var seat = packet.ReadByte("Transport Seat", index);
                    packet.ReadXORBytes(transportGuid, 3, 1, 6);
                    if (hasTransportTime2)
                    {
                        packet.ReadUInt32("Transport Time 2", index);
                    }

                    packet.ReadXORByte(transportGuid, 5);
                    moveInfo.TransportOffset.O = packet.ReadSingle();
                    moveInfo.TransportOffset.X = packet.ReadSingle();
                    packet.ReadXORBytes(transportGuid, 2, 0, 7);
                    if (hasTransportTime3)
                    {
                        packet.ReadUInt32("Transport Time 3", index);
                    }

                    moveInfo.TransportGuid = new WowGuid64(BitConverter.ToUInt64(transportGuid, 0));
                    packet.AddValue("Transport GUID", moveInfo.TransportGuid, index);
                    packet.AddValue("Transport Position", moveInfo.TransportOffset, index);

                    if (moveInfo.TransportGuid.HasEntry() && moveInfo.TransportGuid.GetHighType() == HighGuidType.Vehicle &&
                        guid.HasEntry() && guid.GetHighType() == HighGuidType.Creature)
                    {
                        VehicleTemplateAccessory vehicleAccessory = new VehicleTemplateAccessory
                        {
                            Entry          = moveInfo.TransportGuid.GetEntry(),
                            AccessoryEntry = guid.GetEntry(),
                            SeatId         = seat
                        };
                        Storage.VehicleTemplateAccessories.Add(vehicleAccessory, packet.TimeSpan);
                    }
                }

                packet.ReadXORBytes(guid1, 2, 1);
                packet.ReadSingle("RunBack Speed", index);
                packet.ReadSingle("Fly Speed", index);
                packet.ReadXORBytes(guid1, 0, 3);
                packet.ReadSingle("SwimBack Speed", index);
                if (hasFallData)
                {
                    if (hasFallDirection)
                    {
                        packet.ReadSingle("Jump Sin", index);
                        packet.ReadSingle("Jump Velocity", index);
                        packet.ReadSingle("Jump Cos", index);
                    }
                    packet.ReadSingle("Fall Start Velocity", index);
                    packet.ReadUInt32("Time Fallen", index);
                }

                packet.ReadSingle("Turn Speed", index);
                packet.ReadXORByte(guid1, 5);
                moveInfo.Position.Z = packet.ReadSingle();
                if (hasOrientation)
                {
                    moveInfo.Orientation = packet.ReadSingle();
                }

                packet.ReadXORByte(guid1, 6);
                if (hasSplineElevation)
                {
                    packet.ReadSingle("Spline Elevation", index);
                }

                packet.ReadSingle("Pitch Speed", index);
                if (hasPitch)
                {
                    packet.ReadSingle("Pitch", index);
                }

                for (var i = 0; i < bits98; ++i)
                {
                    packet.ReadInt32("Int9C", index, i);
                }

                moveInfo.WalkSpeed = packet.ReadSingle("Walk Speed", index) / 2.5f;
                if (bitA8)
                {
                    packet.ReadInt32("IntA8", index);
                }

                moveInfo.Position.Y = packet.ReadSingle();
                packet.ReadSingle("Swim Speed", index);
                packet.ReadSingle("FlyBack Speed", index);
                packet.ReadXORByte(guid1, 7);
                moveInfo.RunSpeed   = packet.ReadSingle("Run Speed", index) / 7.0f;
                moveInfo.Position.X = packet.ReadSingle();
                packet.ReadXORByte(guid1, 4);

                packet.WriteGuid("GUID1", guid1, index);
                packet.AddValue("Position", moveInfo.Position, index);
                packet.AddValue("Orientation", moveInfo.Orientation, index);
            }

            if (isSceneObject)
            {
                if (bit318)
                {
                    packet.ReadInt16("Short318", index);
                }

                for (var i = 0; i < 2; ++i)
                {
                    for (var j = 0; j < bits34C_0[i]; ++j)
                    {
                        packet.ReadXORBytes(guid34C_4[i][j], 0, 2);
                        packet.ReadInt32("Int34C+4+8", index, i, j);
                        packet.ReadXORBytes(guid34C_4[i][j], 5, 7);
                        packet.ReadInt32("Int34C+4+18", index, i, j);

                        for (var k = 0; k < bits34C_4_84[i][j]; ++k)
                        {
                            if (bit34C_4_88_C[i][j][k])
                            {
                                packet.ReadInt32("int34C+4+88+C", index, i, j, k);
                            }

                            if (bit34C_4_88_8[i][j][k])
                            {
                                packet.ReadInt32("int34C+4+88+8", index, i, j, k);
                            }

                            if (bit34C_4_88_10[i][j][k] != 9)
                            {
                                packet.ReadByte("byte34C+4+88+10", index, i, j, k);
                            }

                            packet.ReadInt32("int34C+4+88+0", index, i, j, k);
                            packet.ReadInt32("int34C+4+88+4", index, i, j, k);
                        }

                        packet.ReadInt32("int34C+4+28", index, i, j);

                        for (var k = 0; k < bits34C_4_94[i][j]; ++k)
                        {
                            packet.ReadInt32("int34C+4+98+0", index, i, j, k);
                            packet.ReadInt32("int34C+4+98+4", index, i, j, k);
                        }

                        packet.ReadBytes("Bytes34C+4+31", (int)bits34C_4_31[i][j], index, i, j);
                        packet.ReadXORByte(guid34C_4[i][j], 6);

                        for (var k = 0; k < bits34C_4_74[i][j]; ++k)
                        {
                            packet.ReadInt32("int34C+4+78+0", index, i, j, k);
                            packet.ReadByte("byte34C+4+78+8", index, i, j, k);
                            packet.ReadInt16("short34C+4+78+3", index, i, j, k);
                            packet.ReadInt16("short34C+4+78+2", index, i, j, k);
                            if (bit34C_4_78_9[i][j][k] != 9)
                            {
                                packet.ReadByte("byte34C+4+78+9", index, i, j, k);
                            }
                        }

                        if (bit34C_4_2E[i][j])
                        {
                            packet.ReadInt16("short34C+4+2E", index, i, j);
                        }

                        packet.ReadXORByte(guid34C_4[i][j], 4);
                        packet.ReadInt32("int34C+4+24", index, i, j);
                        packet.ReadXORBytes(guid34C_4[i][j], 1, 3);
                        packet.ReadInt16("short34C+4+16", index, i, j);
                        packet.ReadInt32("int34C+4+C", index, i, j);
                        packet.ReadInt32("int34C+4+10", index, i, j);

                        if (!bit34C_4_30[i][j])
                        {
                            packet.ReadByte("byte34C+4+30", index, i, j);
                        }

                        packet.ReadInt32("int34C+4+20", index, i, j);
                        packet.ReadInt32("int34C+4+1C", index, i, j);
                        packet.ReadInt16("short34C+4+14", index, i, j);
                        packet.ReadInt16("short34C+4+2C", index, i, j);
                        packet.WriteGuid("Guid 34C_4", guid34C_4[i][j]);
                    }

                    if (!bit34C_4[i])
                    {
                        packet.ReadByte("byte34C-4", index, i);
                    }

                    packet.ReadXORBytes(guid310[i], 6, 3, 7);
                    packet.ReadInt32("int34C-12", index, i);
                    packet.ReadXORBytes(guid310[i], 5, 1, 4, 0);
                    packet.ReadByte("byte34C+16", index, i);

                    if (bit34C_8[i])
                    {
                        packet.ReadInt32("int34C-8", index, i);
                    }

                    packet.ReadXORByte(guid310[i], 2);
                    packet.WriteGuid("Guid34C-20", guid310[i], index, i);
                }

                packet.ParseBitStream(CreatorGUID, 2, 5, 4, 7, 3, 1, 0, 6);
                packet.WriteGuid("Creator GUID", CreatorGUID);

                if (bit329)
                {
                    packet.ReadByte("byte329", index);
                }

                for (var i = 0; i < 3; ++i)
                {
                    for (var j = 0; j < bits388_10[i]; ++j)
                    {
                        packet.ReadByte("byte388+4+4", index, i, j);
                        packet.ReadByte("byte388+4+0", index, i, j);
                    }

                    for (var j = 0; j < bits388[i]; ++j)
                    {
                        if (bit388_1_10[i][j] != 9)
                        {
                            packet.ReadByte("byte388+1+10", index, i, j);
                        }

                        if (bit388_1_C[i][j])
                        {
                            packet.ReadInt32("int388+1+C", index, i, j);
                        }

                        packet.ReadInt32("int388+1+4", index, i, j);
                        packet.ReadInt32("int388+1+0", index, i, j);

                        if (bit388_1_8[i][j])
                        {
                            packet.ReadInt32("int388+1+8", index, i, j);
                        }
                    }
                }

                if (bit320)
                {
                    packet.ReadInt32("int320", index);
                }
                if (bit31A)
                {
                    packet.ReadInt16("short31A", index);
                }

                packet.ReadInt32("int31C", index);
                if (bit324)
                {
                    packet.ReadInt32("int324", index);
                }
                if (bit328)
                {
                    packet.ReadByte("byte328", index);
                }
            }

            if (hasGameObjectPosition)
            {
                packet.ReadUInt32("GO Transport Time", index);
                packet.ReadXORByte(goTransportGuid, 7);
                moveInfo.TransportOffset.Y = packet.ReadSingle();
                packet.ReadXORByte(goTransportGuid, 0);
                if (hasGOTransportTime3)
                {
                    packet.ReadUInt32("GO Transport Time 3", index);
                }

                packet.ReadXORByte(goTransportGuid, 3);
                packet.ReadSByte("GO Transport Seat", index);
                packet.ReadXORByte(goTransportGuid, 1);
                moveInfo.TransportOffset.Z = packet.ReadSingle();
                moveInfo.TransportOffset.O = packet.ReadSingle();
                if (hasGOTransportTime2)
                {
                    packet.ReadUInt32("GO Transport Time 2", index);
                }

                moveInfo.TransportOffset.X = packet.ReadSingle();
                packet.ReadXORBytes(goTransportGuid, 2, 4, 5, 6);

                moveInfo.TransportGuid = new WowGuid64(BitConverter.ToUInt64(goTransportGuid, 0));
                packet.AddValue("GO Transport GUID", moveInfo.TransportGuid, index);
                packet.AddValue("GO Transport Position", moveInfo.TransportOffset, index);
            }

            if (bit208)
            {
                if (bit21C)
                {
                    packet.ReadSingle("Float224", index);
                    packet.ReadSingle("Float220", index);
                }

                packet.ReadSingle("Float210", index);
                if (bit244)
                {
                    for (var i = 0; i < bits258; ++i)
                    {
                        packet.ReadSingle("Float25C+1", index);
                        packet.ReadSingle("Float25C+0", index);
                    }

                    for (var i = 0; i < bits248; ++i)
                    {
                        packet.ReadSingle("Float24C+0", index);
                        packet.ReadSingle("Float24C+1", index);
                    }

                    packet.ReadSingle("Float26C", index);
                    packet.ReadSingle("Float268", index);
                }

                if (bit228)
                {
                    packet.ReadSingle("Float22C", index);
                    packet.ReadSingle("Float230", index);
                    packet.ReadSingle("Float23C", index);
                    packet.ReadSingle("Float234", index);
                    packet.ReadSingle("Float238", index);
                    packet.ReadSingle("Float240", index);
                }

                if (bit270)
                {
                    for (var i = 0; i < bits274; ++i)
                    {
                        packet.ReadSingle("Float277+1", index);
                        packet.ReadSingle("Float277+0", index);
                        packet.ReadSingle("Float277+2", index);
                    }
                }

                packet.ReadSingle("Float214", index);
                packet.ReadInt32("Int20C", index);
            }

            if (hasVehicleData)
            {
                packet.ReadSingle("Vehicle Orientation", index);
                moveInfo.VehicleId = packet.ReadUInt32("Vehicle Id", index);
            }

            if (hasAttackingTarget)
            {
                packet.ParseBitStream(attackingTargetGuid, 7, 1, 4, 6, 0, 2, 5, 3);
                packet.WriteGuid("Attacking GUID", attackingTargetGuid, index);
            }

            if (hasGameObjectRotation)
            {
                moveInfo.Rotation = packet.ReadPackedQuaternion("GameObject Rotation", index);
            }

            if (hasAnimKits)
            {
                if (hasAnimKit2)
                {
                    packet.ReadUInt16("Anim Kit 2", index);
                }
                if (hasAnimKit1)
                {
                    packet.ReadUInt16("Anim Kit 1", index);
                }
                if (hasAnimKit3)
                {
                    packet.ReadUInt16("Anim Kit 3", index);
                }
            }

            if (bit28E)
            {
                packet.ReadBytes("Bytes", (int)bits28F, index);
            }

            if (hasStationaryPosition)
            {
                moveInfo.Position.X  = packet.ReadSingle();
                moveInfo.Position.Z  = packet.ReadSingle();
                moveInfo.Orientation = packet.ReadSingle("Stationary Orientation", index);
                moveInfo.Position.Y  = packet.ReadSingle();
                packet.AddValue("Stationary Position", moveInfo.Position, index);
            }

            if (transport)
            {
                packet.ReadInt32("Transport path timer", index);
            }

            if (bit3F0)
            {
                for (var i = 0; i < bits3F4; ++i)
                {
                    packet.ReadInt32("Int3F8", index, i);
                }
            }

            if (bit284)
            {
                packet.ReadInt32("Int288", index);
            }

            if (bit3E8)
            {
                packet.ReadInt32("Int3EC", index);
            }

            if (living && moveInfo.HasSplineData && hasFullSpline && splineType == SplineType.FacingTarget)
            {
                var facingTargetGuid = new byte[8];
                facingTargetGuid = packet.StartBitStream(2, 4, 6, 3, 1, 5, 7, 0);
                packet.ParseBitStream(facingTargetGuid, 1, 3, 6, 7, 2, 4, 5, 0);
                packet.WriteGuid("Facing Target GUID", facingTargetGuid, index);
            }

            return(moveInfo);
        }
예제 #19
0
        private static MovementInfo ReadMovementUpdateBlock(Packet packet, WowGuid guid, object index)
        {
            var moveInfo = new MovementInfo();

            var guid1               = new byte[8];
            var transportGuid       = new byte[8];
            var goTransportGuid     = new byte[8];
            var attackingTargetGuid = new byte[8];
            var guid5               = new byte[8];
            var guid6               = new byte[8];
            var guid7               = new byte[8];

            var hasAnimKit1                   = false;
            var hasAnimKit2                   = false;
            var hasAnimKit3                   = false;
            var hasFullSpline                 = false;
            var hasSplineStartTime            = false;
            var hasSplineVerticalAcceleration = false;
            var hasMovementFlags              = false;
            var hasMoveFlagsExtra             = false;
            var hasTimestamp                  = false;
            var hasOrientation                = false;
            var hasTransportData              = false;
            var hasTransportTime2             = false;
            var hasTransportTime3             = false;
            var hasGOTransportTime2           = false;
            var hasGOTransportTime3           = false;
            var hasPitch           = false;
            var hasFallData        = false;
            var hasFallDirection   = false;
            var hasSplineElevation = false;

            var bit134 = false;
            var bitA8  = false;
            var bit23C = false;
            var bit298 = false;
            var bit230 = false;
            var bit284 = false;
            var bit228 = false;
            var bit258 = false;
            var bit218 = false;
            var bit220 = false;

            var bits168     = 0u;
            var splineCount = 0u;
            var bits138     = 0u;
            var bits98      = 0u;
            var bits25C     = 0u;
            var bits26C     = 0u;
            var bits288     = 0u;
            var bits418     = 0u;
            var bits2AA     = 0u;
            var splineType  = SplineType.Stop;

            var bit2A4                = packet.ReadBit();                                 // 676
            var hasVehicleData        = packet.ReadBit("Has Vehicle Data", index);        // 488
            var bit414                = packet.ReadBit();                                 // 1044
            var hasGameObjectRotation = packet.ReadBit("Has GameObject Rotation", index); // 512

            packet.ReadBit();                                                             // fake 0
            var isLiving           = packet.ReadBit("Is Living", index);                  // 368
            var hasSceneObjectData = packet.ReadBit("Has Scene Object Data", index);      // 1032

            packet.ReadBit();                                                             // fake 2
            var bit29C = packet.ReadBit();                                                // 668
            var bit2A8 = packet.ReadBit();                                                // 680
            var bit2A9 = packet.ReadBit();                                                // 681

            packet.ReadBit();                                                             // fake 1
            var hasTransportPosition = packet.ReadBit("Has Transport Position", index);   // 424
            var bit1DC                = packet.ReadBit();                                 // 476
            var hasAnimKits           = packet.ReadBit("Has Anim Kits", index);           // 498
            var hasStationaryPosition = packet.ReadBit("Has Stationary Position", index); // 448
            var hasAttackingTarget    = packet.ReadBit("Has Attacking Target", index);    // 464

            packet.ReadBit();                                                             // fake 3
            var transportFrames = packet.ReadBits("Transport Frames Count", 22, index);   // 1068
            var bit32A          = packet.ReadBit();                                       // 810
            var bit428          = packet.ReadBit();                                       // 1064

            if (bit428)
            {
                bits418 = packet.ReadBits(22);
            }

            if (hasTransportPosition)
            {
                packet.StartBitStream(goTransportGuid, 3, 5, 2, 1, 4);
                hasGOTransportTime3 = packet.ReadBit();
                hasGOTransportTime2 = packet.ReadBit();
                packet.StartBitStream(goTransportGuid, 0, 6, 7);
            }

            if (isLiving)
            {
                hasTransportData = packet.ReadBit("Has Transport Data", index);
                if (hasTransportData)
                {
                    transportGuid[4]  = packet.ReadBit();
                    transportGuid[0]  = packet.ReadBit();
                    transportGuid[5]  = packet.ReadBit();
                    transportGuid[2]  = packet.ReadBit();
                    transportGuid[3]  = packet.ReadBit();
                    hasTransportTime2 = packet.ReadBit();
                    transportGuid[7]  = packet.ReadBit();
                    transportGuid[6]  = packet.ReadBit();
                    transportGuid[1]  = packet.ReadBit();
                    hasTransportTime3 = packet.ReadBit();
                }

                hasPitch = !packet.ReadBit("Has Pitch", index);
                packet.ReadBit();
                bits168           = packet.ReadBits(19);
                guid1[1]          = packet.ReadBit();
                hasMoveFlagsExtra = !packet.ReadBit();
                packet.ReadBit();
                hasSplineElevation = !packet.ReadBit("Has SplineElevation", index);

                if (hasMoveFlagsExtra)
                {
                    moveInfo.FlagsExtra = packet.ReadBitsE <MovementFlagExtra>("Extra Movement Flags", 13, index);
                }

                hasOrientation   = !packet.ReadBit();
                hasTimestamp     = !packet.ReadBit();
                hasMovementFlags = !packet.ReadBit();
                bitA8            = !packet.ReadBit("bitA8", index);
                guid1[2]         = packet.ReadBit();
                guid1[6]         = packet.ReadBit();
                hasFallData      = packet.ReadBit();
                guid1[5]         = packet.ReadBit();
                guid1[4]         = packet.ReadBit();
                guid1[0]         = packet.ReadBit();

                if (hasMovementFlags)
                {
                    moveInfo.Flags = packet.ReadBitsE <MovementFlag>("Movement Flags", 30, index);
                }
                packet.ReadBit();
                if (hasFallData)
                {
                    hasFallDirection = packet.ReadBit();
                }
                bits98 = packet.ReadBits("bits98", 22, index);

                guid1[7] = packet.ReadBit();
                moveInfo.HasSplineData = packet.ReadBit();
                guid1[3] = packet.ReadBit();


                if (moveInfo.HasSplineData)
                {
                    hasFullSpline = packet.ReadBit();
                    if (hasFullSpline)
                    {
                        hasSplineVerticalAcceleration = packet.ReadBit();
                        packet.ReadBitsE <SplineMode>("Spline Mode", 2, index);
                        splineCount = packet.ReadBits(20);
                        packet.ReadBitsE <SplineFlag434>("Spline flags", 25, index);

                        hasSplineStartTime = packet.ReadBit();
                        bit134             = packet.ReadBit();
                        if (bit134)
                        {
                            bits138 = packet.ReadBits(21);
                            packet.ReadBits(2);
                        }
                    }
                }
            }

            if (bit29C)
            {
                bit230 = packet.ReadBit();
                bit258 = packet.ReadBit();
                packet.ReadBit("bit20E", index);
                packet.ReadBit("bit20F", index);
                bit228 = packet.ReadBit();
                packet.ReadBit("bit20C", index);
                bit218 = packet.ReadBit();
                packet.ReadBit("bit20D", index);
                bit284 = packet.ReadBit();

                if (bit284)
                {
                    bits25C = packet.ReadBits(21);
                    bits26C = packet.ReadBits(21);
                }

                bit298 = packet.ReadBit();

                if (bit298)
                {
                    bits288 = packet.ReadBits(20);
                }

                bit23C = packet.ReadBit();
                packet.ReadBit("bit210", index);
                bit220 = packet.ReadBit();
            }

            if (hasAttackingTarget)
            {
                attackingTargetGuid = packet.StartBitStream(4, 6, 3, 5, 0, 2, 7, 1);
            }

            if (hasAnimKits)
            {
                hasAnimKit1 = !packet.ReadBit();
                hasAnimKit2 = !packet.ReadBit();
                hasAnimKit3 = !packet.ReadBit();
            }

            if (bit32A)
            {
                bits2AA = packet.ReadBits(7);
            }

            packet.ResetBitReader();

            for (var i = 0; i < transportFrames; ++i)
            {
                packet.ReadInt32("Transport frame", index, i);
            }

            if (bit29C)
            {
                if (bit23C)
                {
                    packet.ReadSingle("Float234", index);
                    packet.ReadSingle("Float238", index);
                }

                if (bit284)
                {
                    for (var i = 0; i < bits26C; ++i)
                    {
                        packet.ReadSingle("Float270+0", index, i);
                        packet.ReadSingle("Float270+1", index, i);
                    }

                    packet.ReadSingle("Float27C", index);

                    for (var i = 0; i < bits25C; ++i)
                    {
                        packet.ReadSingle("Float260+0", index, i);
                        packet.ReadSingle("Float260+1", index, i);
                    }

                    packet.ReadSingle("Float280", index);
                }

                if (bit258)
                {
                    packet.ReadSingle("Float244", index);
                    packet.ReadSingle("Float250", index);
                    packet.ReadSingle("Float254", index);
                    packet.ReadSingle("Float248", index);
                    packet.ReadSingle("Float240", index);
                    packet.ReadSingle("Float24C", index);
                }

                packet.ReadInt32("Int208", index);

                if (bit298)
                {
                    for (var i = 0; i < bits288; ++i)
                    {
                        packet.ReadSingle("Float28C+0", index, i);
                        packet.ReadSingle("Float28C+1", index, i);
                        packet.ReadSingle("Float28C+2", index, i);
                    }
                }

                if (bit220)
                {
                    packet.ReadInt32("int21C", index);
                }

                if (bit218)
                {
                    packet.ReadInt32("int214", index);
                }

                if (bit230)
                {
                    packet.ReadInt32("int22C", index);
                }

                if (bit228)
                {
                    packet.ReadInt32("int224", index);
                }
            }

            if (isLiving)
            {
                if (hasFallData)
                {
                    if (hasFallDirection)
                    {
                        packet.ReadSingle("Jump Sin Angle", index);
                        packet.ReadSingle("Jump Cos Angle", index);
                        packet.ReadSingle("Jump XY Speed", index);
                    }

                    packet.ReadSingle("Jump Z Speed", index);
                    packet.ReadUInt32("Jump Fall Time", index);
                }

                if (moveInfo.HasSplineData)
                {
                    if (hasFullSpline)
                    {
                        packet.ReadSingle("Duration Mod Next", index);
                        for (uint i = 0; i < splineCount; i++)
                        {
                            Vector3 v = new Vector3();
                            v.Z = packet.ReadSingle();
                            v.Y = packet.ReadSingle();
                            v.X = packet.ReadSingle();

                            packet.AddValue("Spline", v, index);
                        }

                        var type = packet.ReadByte();
                        switch (type)
                        {
                        case 1:
                            splineType = SplineType.Normal;
                            break;

                        case 2:
                            splineType = SplineType.FacingSpot;
                            break;

                        case 3:
                            splineType = SplineType.FacingTarget;
                            break;

                        case 4:
                            splineType = SplineType.FacingAngle;
                            break;
                        }

                        packet.ReadSingle("Duration Mod", index);

                        //    NYI block here

                        if (splineType == SplineType.FacingSpot)
                        {
                            packet.ReadVector3("Facing spot", index);
                        }

                        if (hasSplineVerticalAcceleration)
                        {
                            packet.ReadSingle("Spline Vertical Acceleration", index);
                        }

                        if (splineType == SplineType.FacingAngle)
                        {
                            packet.ReadSingle("Facing Angle", index);
                        }

                        packet.ReadUInt32("Spline FULL Time", index);
                        if (hasSplineStartTime)
                        {
                            packet.ReadUInt32("Spline Start time", index);
                        }

                        packet.ReadUInt32("Spline Time", index);
                    }

                    packet.ReadUInt32("Spline ID", index);
                    packet.ReadVector3("Spline Endpoint", index);
                }

                /*for (var i = 0; i < 10; ++i)
                 *  packet.ReadSingle("unk float");
                 * if (bits98 > 0)
                 *  packet.ReadBits((int)bits98);*/
                //for (var i = 0; i < bits98; ++i)
                //    packet.ReadInt32("Int9C", index, i);


                moveInfo.Position.Z = packet.ReadSingle();
                moveInfo.Position.Y = packet.ReadSingle();
                packet.ReadSingle("Fly Speed", index);
                packet.ReadXORByte(guid1, 6);
                packet.ReadSingle("Fly Back Speed", index);

                if (hasTransportData)
                {
                    packet.ReadXORByte(transportGuid, 7);
                    packet.ReadXORByte(transportGuid, 4);

                    if (hasTransportTime3)
                    {
                        packet.ReadUInt32("Transport Time 3", index);
                    }

                    packet.ReadUInt32("Transport Time", index);

                    if (hasTransportTime2)
                    {
                        packet.ReadUInt32("Transport Time 2", index);
                    }

                    moveInfo.TransportOffset.O = packet.ReadSingle();
                    moveInfo.TransportOffset.X = packet.ReadSingle();
                    packet.ReadXORByte(transportGuid, 6);
                    packet.ReadXORByte(transportGuid, 3);
                    packet.ReadXORByte(transportGuid, 2);
                    moveInfo.TransportOffset.Z = packet.ReadSingle();
                    moveInfo.TransportOffset.Y = packet.ReadSingle();
                    var seat = packet.ReadSByte("Transport Seat", index);
                    packet.ReadXORByte(transportGuid, 1);
                    packet.ReadXORByte(transportGuid, 0);
                    packet.ReadXORByte(transportGuid, 5);

                    moveInfo.TransportGuid = new WowGuid64(BitConverter.ToUInt64(transportGuid, 0));
                    packet.AddValue("Transport GUID", moveInfo.TransportGuid, index);
                    packet.AddValue("Transport Position", moveInfo.TransportOffset, index);

                    if (moveInfo.TransportGuid.HasEntry() && moveInfo.TransportGuid.GetHighType() == HighGuidType.Vehicle &&
                        guid.HasEntry() && guid.GetHighType() == HighGuidType.Creature)
                    {
                        VehicleTemplateAccessory vehicleAccessory = new VehicleTemplateAccessory
                        {
                            Entry          = moveInfo.TransportGuid.GetEntry(),
                            AccessoryEntry = guid.GetEntry(),
                            SeatId         = seat
                        };

                        Storage.VehicleTemplateAccessories.Add(vehicleAccessory, packet.TimeSpan);
                    }
                }

                moveInfo.Position.X = packet.ReadSingle();
                packet.AddValue("Position", moveInfo.Position, index);
                packet.ReadXORByte(guid1, 2);

                if (hasPitch)
                {
                    packet.ReadSingle("Pitch", index);
                }

                packet.ReadSingle("Swim Speed", index);
                packet.ReadXORByte(guid1, 1);
                packet.ReadSingle("Run Back Speed", index);
                packet.ReadSingle("Swim Back Speed", index);
                packet.ReadXORByte(guid1, 5);

                if (hasSplineElevation)
                {
                    packet.ReadSingle("Spline Elevation", index);
                }

                if (bitA8)
                {
                    packet.ReadInt32("IntA8", index);
                }

                packet.ReadSingle("Turn Speed", index);
                packet.ReadXORByte(guid1, 3);
                moveInfo.RunSpeed = packet.ReadSingle("Run Speed", index) / 7.0f;
                packet.ReadXORByte(guid1, 7);
                moveInfo.WalkSpeed = packet.ReadSingle("Walk Speed", index) / 2.5f;
                packet.ReadSingle("Pitch Speed", index);

                if (hasTimestamp)
                {
                    packet.ReadUInt32("Time?", index);
                }

                packet.ReadXORByte(guid1, 4);
                packet.ReadXORByte(guid1, 0);
                packet.WriteGuid("GUID2", guid1);

                if (hasOrientation)
                {
                    moveInfo.Orientation = packet.ReadSingle("Orientation", index);
                }
            }

            if (hasAttackingTarget)
            {
                packet.ParseBitStream(attackingTargetGuid, 5, 1, 2, 0, 3, 4, 6, 7);
                packet.WriteGuid("Attacking Target GUID", attackingTargetGuid, index);
            }

            if (hasStationaryPosition)
            {
                moveInfo.Orientation = packet.ReadSingle("Stationary Orientation", index);
                moveInfo.Position    = packet.ReadVector3("Stationary Position", index);
            }

            if (hasTransportPosition)
            {
                packet.ReadSByte("Transport Seat", index);
                moveInfo.TransportOffset.X = packet.ReadSingle();
                packet.ReadXORBytes(goTransportGuid, 1, 0, 2, 6, 5, 4);

                if (hasGOTransportTime2)
                {
                    packet.ReadUInt32("Transport Time 3", index);
                }

                packet.ReadXORByte(goTransportGuid, 7);
                moveInfo.TransportOffset.O = packet.ReadSingle();
                moveInfo.TransportOffset.Z = packet.ReadSingle();
                moveInfo.TransportOffset.Y = packet.ReadSingle();

                if (hasGOTransportTime3)
                {
                    packet.ReadUInt32("Transport Time 2", index);
                }

                packet.ReadXORByte(goTransportGuid, 3);
                packet.ReadUInt32("Transport Time", index);

                moveInfo.TransportGuid = new WowGuid64(BitConverter.ToUInt64(goTransportGuid, 0));
                packet.AddValue("Transport GUID", moveInfo.TransportGuid, index);
                packet.AddValue("Transport Position", moveInfo.TransportOffset, index);
            }

            if (bit1DC)
            {
                packet.ReadInt32("int1D8", index);
            }

            if (bit2A4)
            {
                packet.ReadInt32("int2A0", index);
            }

            if (bit32A)
            {
                packet.ReadBytes("Bytes", (int)bits2AA);
            }

            if (hasGameObjectRotation)
            {
                moveInfo.Rotation = packet.ReadPackedQuaternion("GameObject Rotation", index);
            }

            if (hasVehicleData)
            {
                moveInfo.VehicleId = packet.ReadUInt32("Vehicle Id", index);
                packet.ReadSingle("Vehicle Orientation", index);
            }

            if (bit414)
            {
                packet.ReadInt32("int410", index);
            }

            if (hasAnimKits)
            {
                if (hasAnimKit1)
                {
                    packet.ReadUInt16("Anim Kit 1", index);
                }
                if (hasAnimKit2)
                {
                    packet.ReadUInt16("Anim Kit 2", index);
                }
                if (hasAnimKit3)
                {
                    packet.ReadUInt16("Anim Kit 3", index);
                }
            }

            if (bit428)
            {
                for (var i = 0; i < bits418; ++i)
                {
                    packet.ReadInt32("Int3F8", index, i);
                }
            }

            if (isLiving && moveInfo.HasSplineData && hasFullSpline && splineType == SplineType.FacingTarget)
            {
                var facingTargetGuid = new byte[8];
                packet.StartBitStream(facingTargetGuid, 6, 7, 3, 0, 5, 1, 4, 2);
                packet.ParseBitStream(facingTargetGuid, 4, 2, 5, 6, 0, 7, 1, 3);
                packet.WriteGuid("Facing Target GUID", facingTargetGuid, index);
            }

            return(moveInfo);
        }
예제 #20
0
 public MovementInfo(WowGuid guid)
 {
     this.Guid = guid;
 }
예제 #21
0
        public static void HandleCharEnum(Packet packet)
        {
            //var unkCounter = packet.ReadBits("Unk Counter", 21);
            packet.ReadBit("Unk bit");
            var count = packet.ReadBits("Char count", 16);

            var charGuids   = new byte[count][];
            var guildGuids  = new byte[count][];
            var firstLogins = new bool[count];
            var nameLenghts = new uint[count];

            for (int c = 0; c < count; ++c)
            {
                charGuids[c]  = new byte[8];
                guildGuids[c] = new byte[8];

                charGuids[c][1]  = packet.ReadBit();
                guildGuids[c][5] = packet.ReadBit();
                guildGuids[c][7] = packet.ReadBit();
                guildGuids[c][6] = packet.ReadBit();
                charGuids[c][5]  = packet.ReadBit();
                guildGuids[c][3] = packet.ReadBit();
                charGuids[c][2]  = packet.ReadBit();
                guildGuids[c][4] = packet.ReadBit();
                charGuids[c][7]  = packet.ReadBit();
                nameLenghts[c]   = packet.ReadBits(6);
                firstLogins[c]   = packet.ReadBit();
                guildGuids[c][1] = packet.ReadBit();
                charGuids[c][4]  = packet.ReadBit();
                guildGuids[c][2] = packet.ReadBit();
                guildGuids[c][0] = packet.ReadBit();
                charGuids[c][6]  = packet.ReadBit();
                charGuids[c][3]  = packet.ReadBit();
                charGuids[c][0]  = packet.ReadBit();
            }

            packet.ReadBits("RIDBIT21", 21);
            packet.ResetBitReader();

            for (int c = 0; c < count; ++c)
            {
                packet.ReadXORByte(charGuids[c], 4);
                var race = packet.ReadEnum <Race>("Race", TypeCode.Byte, c);
                packet.ReadXORByte(charGuids[c], 6);
                packet.ReadXORByte(guildGuids[c], 1);
                packet.ReadByte("List Order", c);
                packet.ReadByte("Hair Style", c);
                packet.ReadXORByte(guildGuids[c], 6);
                packet.ReadXORByte(charGuids[c], 3);
                var x = packet.ReadSingle("Position X", c);
                packet.ReadEnum <CharacterFlag>("CharacterFlag", TypeCode.Int32, c);
                packet.ReadXORByte(guildGuids[c], 0);
                packet.ReadInt32("Pet Level", c);
                var mapId = packet.ReadEntry <Int32>(StoreNameType.Map, "Map Id", c);
                packet.ReadXORByte(guildGuids[c], 7);
                packet.ReadEnum <CustomizationFlag>("CustomizationFlag", TypeCode.UInt32, c);
                packet.ReadXORByte(guildGuids[c], 4);
                packet.ReadXORByte(charGuids[c], 2);
                packet.ReadXORByte(charGuids[c], 5);
                var y = packet.ReadSingle("Position Y", c);
                packet.ReadInt32("Pet Family", c);
                var name = packet.ReadWoWString("Name", (int)nameLenghts[c], c);
                packet.ReadInt32("Pet Display ID", c);
                packet.ReadXORByte(guildGuids[c], 3);
                packet.ReadXORByte(charGuids[c], 7);
                var level = packet.ReadByte("Level", c);
                packet.ReadXORByte(charGuids[c], 1);
                packet.ReadXORByte(guildGuids[c], 2);

                for (int j = 0; j < 23; ++j)
                {
                    packet.ReadInt32("Item EnchantID", c, j);
                    packet.ReadInt32("Item DisplayID", c, j);
                    packet.ReadEnum <InventoryType>("Item InventoryType", TypeCode.Byte, c, j);
                }

                var z    = packet.ReadSingle("Position Z", c);
                var zone = packet.ReadEntry <UInt32>(StoreNameType.Zone, "Zone Id", c);
                packet.ReadByte("Facial Hair", c);
                var clss = packet.ReadEnum <Class>("Class", TypeCode.Byte, c);
                packet.ReadXORByte(guildGuids[c], 5);
                packet.ReadByte("Skin", c);
                packet.ReadEnum <Gender>("Gender", TypeCode.Byte, c);
                packet.ReadByte("Face", c);
                packet.ReadXORByte(charGuids[c], 0);
                packet.ReadByte("Hair Color", c);

                var playerGuid = new WowGuid(BitConverter.ToUInt64(charGuids[c], 0));

                packet.WriteGuid("Character GUID", charGuids[c], c);
                packet.WriteGuid("Guild GUID", guildGuids[c], c);

                if (firstLogins[c])
                {
                    var startPos = new StartPosition {
                        Map = mapId, Position = new Vector3(x, y, z), Zone = (int)zone
                    };

                    Storage.StartPositions.Add(new Tuple <Race, Class>(race, clss), startPos, packet.TimeSpan);
                }

                var playerInfo = new Player {
                    Race = race, Class = clss, Name = name, FirstLogin = firstLogins[c], Level = level
                };
                if (Storage.Objects.ContainsKey(playerGuid))
                {
                    Storage.Objects[playerGuid] = new Tuple <WoWObject, TimeSpan?>(playerInfo, packet.TimeSpan);
                }
                else
                {
                    Storage.Objects.Add(playerGuid, playerInfo, packet.TimeSpan);
                }

                StoreGetters.AddName(playerGuid, name);
            }
        }
예제 #22
0
 protected override void PackedRead(StreamHandler reader)
 {
     this.Guid = reader.ReadGuid();
 }
예제 #23
0
        private static MovementInfo ReadMovementUpdateBlock(ref Packet packet, WowGuid guid, object index)
        {
            var moveInfo = new MovementInfo();

            var guid1               = new byte[8];
            var transportGuid       = new byte[8];
            var goTransportGuid     = new byte[8];
            var attackingTargetGuid = new byte[8];

            var hasAnimKit1                   = false;
            var hasAnimKit2                   = false;
            var hasAnimKit3                   = false;
            var hasFullSpline                 = false;
            var hasSplineStartTime            = false;
            var hasSplineVerticalAcceleration = false;
            var hasGOTransportTime2           = false;
            var hasGOTransportTime3           = false;
            var hasSplineElevation            = false;
            var hasMovementFlags              = false;
            var hasMoveFlagsExtra             = false;
            var hasTimestamp                  = false;
            var hasOrientation                = false;
            var hasTransportData              = false;
            var hasTransportTime3             = false;
            var hasTransportTime2             = false;
            var hasPitch         = false;
            var hasFallData      = false;
            var hasFallDirection = false;

            var bit130 = false;
            var bit98  = false;
            var bit23C = false;
            var bit298 = false;
            var bit230 = false;
            var bit284 = false;
            var bit228 = false;
            var bit258 = false;
            var bit218 = false;
            var bit220 = false;

            var        bits160     = 0u;
            var        splineCount = 0u;
            var        bits11C     = 0u;
            var        bits88      = 0u;
            var        bits25C     = 0u;
            var        bits26C     = 0u;
            var        bits288     = 0u;
            var        bits418     = 0u;
            var        bits2AA     = 0u;
            SplineType splineType  = SplineType.Stop;

            var bit29C             = packet.ReadBit();
            var hasSceneObjectData = packet.ReadBit("Has Scene Object Data", index);
            var bit2A4             = packet.ReadBit();
            var bit1DC             = packet.ReadBit();
            var bit32A             = packet.ReadBit();
            var hasAnimKits        = packet.ReadBit("Has Anim Kits", index);
            var bit2A8             = packet.ReadBit();
            var bit414             = packet.ReadBit();
            var transportFrames    = packet.ReadBits("Transport Frames Count", 22, index);

            packet.ReadBit(); // fake 2
            packet.ReadBit(); // fake 1
            var isLiving = packet.ReadBit("Is Living", index);
            var hasStationaryPosition = packet.ReadBit("Has Stationary Position", index);
            var hasGameObjectPosition = packet.ReadBit("Has GameObject Position", index);
            var hasGameObjectRotation = packet.ReadBit("Has GameObject Rotation", index);
            var hasAttackingTarget    = packet.ReadBit("Has Attacking Target", index);
            var bit428 = packet.ReadBit();

            packet.ReadBit(); // fake 3
            packet.ReadBit(); // fake 0
            var bit2A9         = packet.ReadBit();
            var hasVehicleData = packet.ReadBit("Has Vehicle Data", index);

            if (hasGameObjectPosition)
            {
                packet.StartBitStream(goTransportGuid, 5, 0, 6);
                hasGOTransportTime2 = packet.ReadBit();
                packet.StartBitStream(goTransportGuid, 7, 3, 2);
                hasGOTransportTime3 = packet.ReadBit();
                packet.StartBitStream(goTransportGuid, 4, 1);
            }

            // Sceneobject data
            var CreatorGUID = new byte[8];

            byte[][]   guid358        = null;
            byte[][][] guid358_6      = null;
            uint[]     bits358_5      = null;
            uint[][]   bits358_6_84   = null;
            uint[][]   bits358_6_94   = null;
            uint[][]   bits358_6_31   = null;
            uint[][]   bits358_6_74   = null;
            byte[][][] bit358_6_78_9  = null;
            byte[][][] bit358_6_88_10 = null;
            bool[][][] bit358_6_88_C  = null;
            bool[][][] bit358_6_88_8  = null;
            bool[][]   bit358_6_2E    = null;
            bool[][]   bit358_6_30    = null;
            bool[]     bit358_10      = null;
            bool[]     bit358_C       = null;
            bool[]     bit358_24      = null;

            var bit338 = false;
            var bit330 = false;
            var bit341 = false;
            var bit340 = false;
            var bit332 = false;
            var bit33C = false;

            uint[]   bits388     = null;
            uint[]   bits388_10  = null;
            byte[][] bit388_1_10 = null;
            bool[][] bit388_1_C  = null;
            bool[][] bit388_1_8  = null;

            if (hasSceneObjectData)
            {
                guid358        = new byte[2][];
                guid358_6      = new byte[2][][];
                bits358_5      = new uint[2];
                bits358_6_84   = new uint[2][];
                bits358_6_94   = new uint[2][];
                bits358_6_31   = new uint[2][];
                bits358_6_74   = new uint[2][];
                bit358_6_78_9  = new byte[2][][];
                bit358_6_88_10 = new byte[2][][];
                bit358_6_88_C  = new bool[2][][];
                bit358_6_88_8  = new bool[2][][];
                bit358_6_2E    = new bool[2][];
                bit358_6_30    = new bool[2][];
                bit358_10      = new bool[2];
                bit358_C       = new bool[2];
                bit358_24      = new bool[2];

                for (var i = 0; i < 2; ++i)
                {
                    guid358[i] = new byte[8];
                    packet.StartBitStream(guid358[i], 2, 0, 4);
                    bit358_10[i]  = !packet.ReadBit();
                    guid358[i][7] = packet.ReadBit();
                    bits358_5[i]  = packet.ReadBits(2);

                    guid358_6[i]      = new byte[bits358_5[i]][];
                    bits358_6_84[i]   = new uint[bits358_5[i]];
                    bits358_6_94[i]   = new uint[bits358_5[i]];
                    bits358_6_31[i]   = new uint[bits358_5[i]];
                    bits358_6_74[i]   = new uint[bits358_5[i]];
                    bit358_6_78_9[i]  = new byte[bits358_5[i]][];
                    bit358_6_88_10[i] = new byte[bits358_5[i]][];
                    bit358_6_88_C[i]  = new bool[bits358_5[i]][];
                    bit358_6_88_8[i]  = new bool[bits358_5[i]][];
                    bit358_6_2E[i]    = new bool[bits358_5[i]];
                    bit358_6_30[i]    = new bool[bits358_5[i]];

                    for (var j = 0; j < bits358_5[i]; ++j)
                    {
                        guid358_6[i][j]    = new byte[8];
                        bits358_6_31[i][j] = packet.ReadBits(7);
                        guid358_6[i][j][3] = packet.ReadBit();
                        bit358_6_2E[i][j]  = !packet.ReadBit();
                        packet.StartBitStream(guid358_6[i][j], 2, 6, 4);
                        bits358_6_84[i][j] = packet.ReadBits(21);
                        guid358_6[i][j][1] = packet.ReadBit();

                        bit358_6_88_8[i][j]  = new bool[bits358_6_84[i][j]];
                        bit358_6_88_C[i][j]  = new bool[bits358_6_84[i][j]];
                        bit358_6_88_10[i][j] = new byte[bits358_6_84[i][j]];
                        for (var k = 0; k < bits358_6_84[i][j]; ++k)
                        {
                            bit358_6_88_8[i][j][k]  = !packet.ReadBit();
                            bit358_6_88_C[i][j][k]  = !packet.ReadBit();
                            bit358_6_88_10[i][j][k] = (byte)(10 - packet.ReadBit());
                        }

                        guid358_6[i][j][5] = packet.ReadBit();
                        bits358_6_74[i][j] = packet.ReadBits(20);
                        packet.StartBitStream(guid358_6[i][j], 7, 0);

                        bit358_6_78_9[i][j] = new byte[bits358_6_74[i][j]];
                        for (var k = 0; k < bits358_6_74[i][j]; ++k)
                        {
                            bit358_6_78_9[i][j][k] = (byte)(10 - packet.ReadBit());
                        }

                        bit358_6_30[i][j]  = packet.ReadBit();
                        bits358_6_94[i][j] = packet.ReadBits(21);
                    }

                    packet.StartBitStream(guid358[i], 6, 1, 5, 3);
                    bit358_C[i]  = !packet.ReadBit();
                    bit358_24[i] = packet.ReadBit();
                }

                bit338 = !packet.ReadBit();
                bit33C = !packet.ReadBit();

                bits388     = new uint[3];
                bits388_10  = new uint[3];
                bit388_1_10 = new byte[3][];
                bit388_1_C  = new bool[3][];
                bit388_1_8  = new bool[3][];

                for (var i = 0; i < 3; ++i)
                {
                    bits388_10[i]  = packet.ReadBits(21);
                    bits388[i]     = packet.ReadBits(21);
                    bit388_1_10[i] = new byte[bits388[i]];
                    bit388_1_C[i]  = new bool[bits388[i]];
                    bit388_1_8[i]  = new bool[bits388[i]];

                    for (var j = 0; j < bits388[i]; ++j)
                    {
                        bit388_1_C[i][j]  = !packet.ReadBit();
                        bit388_1_10[i][j] = (byte)(10 - packet.ReadBit());
                        bit388_1_8[i][j]  = !packet.ReadBit();
                    }
                }

                packet.ReadBit(); // fake bit
                packet.StartBitStream(CreatorGUID, 5, 1, 6, 4, 3, 7, 0, 2);
                bit330 = !packet.ReadBit();
                packet.ReadBit("bit351", index);
                packet.ReadBit("bit350", index);
                bit341 = !packet.ReadBit();
                bit340 = !packet.ReadBit();
                bit332 = !packet.ReadBit();
            }

            if (bit29C)
            {
                bit23C = packet.ReadBit();
                bit230 = packet.ReadBit();
                bit298 = packet.ReadBit();
                packet.ReadBit("bit20C", index);
                if (bit298)
                {
                    bits288 = packet.ReadBits(20);
                }

                bit284 = packet.ReadBit();
                bit228 = packet.ReadBit();
                bit258 = packet.ReadBit();
                packet.ReadBit("bit20F", index);
                if (bit284)
                {
                    bits26C = packet.ReadBits(21);
                    bits25C = packet.ReadBits(21);
                }

                packet.ReadBit("bit20D", index);
                packet.ReadBit("bit20E", index);
                packet.ReadBit("bit210", index);
                bit218 = packet.ReadBit();
                bit220 = packet.ReadBit();
            }

            if (isLiving)
            {
                guid1[5] = packet.ReadBit();
                moveInfo.HasSplineData = packet.ReadBit();
                packet.ReadBit("bit9C", index);
                packet.StartBitStream(guid1, 1, 3);
                hasOrientation = !packet.ReadBit();
                packet.ReadBit("bit85", index);
                if (moveInfo.HasSplineData)
                {
                    hasFullSpline = packet.ReadBit();
                    if (hasFullSpline)
                    {
                        hasSplineStartTime = packet.ReadBit("Has Spline Start Time", index);
                        packet.ReadEnum <SplineMode>("Spline Mode", 2, index);
                        packet.ReadEnum <SplineFlag434>("Spline flags", 25, index);
                        bit130 = packet.ReadBit();
                        if (bit130)
                        {
                            bits11C = packet.ReadBits(21);
                            packet.ReadBits("bits12C", 2, index);
                        }
                        splineCount = packet.ReadBits("SplineWaypointsCount", 20, index);
                        hasSplineVerticalAcceleration = packet.ReadBit("has Spline Vertical Acceleration", index);
                    }
                }
                bits88 = packet.ReadBits(22);
                packet.StartBitStream(guid1, 6, 7);
                hasTransportData   = packet.ReadBit();
                hasSplineElevation = !packet.ReadBit();
                if (hasTransportData)
                {
                    hasTransportTime3 = packet.ReadBit();
                    packet.StartBitStream(transportGuid, 6, 2, 1, 0, 5);
                    hasTransportTime2 = packet.ReadBit();
                    packet.StartBitStream(transportGuid, 3, 7, 4);
                }

                bits160 = packet.ReadBits(19);
                for (var i = 0; i < bits160; ++i)
                {
                    packet.ReadBits("bits164", 2, index, i);
                }
                hasMoveFlagsExtra = !packet.ReadBit();
                guid1[2]          = packet.ReadBit();
                hasMovementFlags  = !packet.ReadBit();
                hasTimestamp      = !packet.ReadBit();
                if (hasMovementFlags)
                {
                    moveInfo.Flags = packet.ReadEnum <MovementFlag>("Movement Flags", 30, index);
                }

                hasFallData = packet.ReadBit();
                if (hasMoveFlagsExtra)
                {
                    moveInfo.FlagsExtra = packet.ReadEnum <MovementFlagExtra>("Extra Movement Flags", 13, index);
                }
                guid1[4] = packet.ReadBit();
                if (hasFallData)
                {
                    hasFallDirection = packet.ReadBit();
                }
                guid1[0] = packet.ReadBit();
                packet.ReadBit("bit84", index);
                hasPitch = !packet.ReadBit();
                bit98    = !packet.ReadBit();
            }

            if (hasAttackingTarget)
            {
                packet.StartBitStream(attackingTargetGuid, 6, 4, 5, 2, 3, 7, 0, 1);
            }

            if (bit32A)
            {
                bits2AA = packet.ReadBits(7);
            }

            if (hasAnimKits)
            {
                hasAnimKit2 = !packet.ReadBit();
                hasAnimKit3 = !packet.ReadBit();
                hasAnimKit1 = !packet.ReadBit();
            }

            if (bit428)
            {
                bits418 = packet.ReadBits(22);
            }

            packet.ResetBitReader();

            for (var i = 0; i < transportFrames; ++i)
            {
                packet.ReadInt32("Transport frame", index, i);
            }

            if (bit29C)
            {
                if (bit258)
                {
                    packet.ReadSingle("Float24C", index);
                    packet.ReadSingle("Float248", index);
                    packet.ReadSingle("Float250", index);
                    packet.ReadSingle("Float244", index);
                    packet.ReadSingle("Float254", index);
                    packet.ReadSingle("Float240", index);
                }

                if (bit284)
                {
                    for (var i = 0; i < bits25C; ++i)
                    {
                        packet.ReadSingle("Float260+1", index, i);
                        packet.ReadSingle("Float260+0", index, i);
                    }

                    packet.ReadSingle("Float280", index);
                    for (var i = 0; i < bits26C; ++i)
                    {
                        packet.ReadSingle("Float270+1", index, i);
                        packet.ReadSingle("Float270+0", index, i);
                    }

                    packet.ReadSingle("Float27C", index);
                }

                if (bit228)
                {
                    packet.ReadInt32("int224", index);
                }
                if (bit218)
                {
                    packet.ReadInt32("int214", index);
                }

                packet.ReadInt32("Int208", index);

                if (bit298)
                {
                    for (var i = 0; i < bits288; ++i)
                    {
                        packet.ReadSingle("Float28C+0", index, i);
                        packet.ReadSingle("Float28C+2", index, i);
                        packet.ReadSingle("Float28C+1", index, i);
                    }
                }

                if (bit230)
                {
                    packet.ReadInt32("int22C", index);
                }
                if (bit220)
                {
                    packet.ReadInt32("int21C", index);
                }

                if (bit23C)
                {
                    packet.ReadSingle("Float234", index);
                    packet.ReadSingle("Float238", index);
                }
            }

            if (isLiving)
            {
                if (moveInfo.HasSplineData)
                {
                    if (hasFullSpline)
                    {
                        var type = packet.ReadByte();
                        switch (type)
                        {
                        case 1:
                            splineType = SplineType.Normal;
                            break;

                        case 2:
                            splineType = SplineType.FacingSpot;
                            break;

                        case 3:
                            splineType = SplineType.FacingTarget;
                            break;

                        case 4:
                            splineType = SplineType.FacingAngle;
                            break;
                        }

                        packet.ReadSingle("Spline Duration Multiplier", index); // if need swap with "Spline Duration Multiplier Next"
                        for (var i = 0u; i < splineCount; ++i)
                        {
                            var wp = new Vector3
                            {
                                Z = packet.ReadSingle(),
                                X = packet.ReadSingle(),
                                Y = packet.ReadSingle(),
                            };

                            packet.AddValue("Spline Waypoint", wp, index, i);
                        }

                        if (bit130)
                        {
                            for (var i = 0; i < bits11C; ++i)
                            {
                                packet.ReadSingle("Float13C+0", index, i);
                                packet.ReadSingle("Float13C+1", index, i);
                            }
                        }

                        packet.ReadSingle("Spline Duration Multiplier Next", index);
                        if (splineType == SplineType.FacingSpot)
                        {
                            var point = new Vector3
                            {
                                Z = packet.ReadSingle(),
                                Y = packet.ReadSingle(),
                                X = packet.ReadSingle(),
                            };

                            packet.AddValue("Facing Spot", point, index);
                        }

                        if (splineType == SplineType.FacingAngle)
                        {
                            packet.ReadSingle("Facing Angle", index);
                        }

                        if (hasSplineVerticalAcceleration)
                        {
                            packet.ReadSingle("Spline Vertical Acceleration", index);
                        }

                        if (hasSplineStartTime)
                        {
                            packet.ReadInt32("Spline Start Time", index);
                        }

                        packet.ReadInt32("Spline Time", index); // if need swap with "Spline Full Time"
                        packet.ReadInt32("Spline Full Time", index);
                    }

                    packet.ReadInt32("Spline Id", index);
                    moveInfo.Position.Z = packet.ReadSingle();
                    moveInfo.Position.X = packet.ReadSingle();
                    moveInfo.Position.Y = packet.ReadSingle();
                }

                if (hasTransportData)
                {
                    moveInfo.TransportOffset.X = packet.ReadSingle();
                    if (hasTransportTime2)
                    {
                        packet.ReadUInt32("Transport Time 2", index);
                    }

                    packet.ReadUInt32("Transport Time", index);
                    moveInfo.TransportOffset.Z = packet.ReadSingle();
                    packet.ReadXORBytes(transportGuid, 4, 3);
                    var seat = packet.ReadByte("Transport Seat", index);
                    moveInfo.TransportOffset.Y = packet.ReadSingle();
                    moveInfo.TransportOffset.O = packet.ReadSingle();
                    packet.ReadXORBytes(transportGuid, 0, 7, 6, 5, 1, 2);
                    if (hasTransportTime3)
                    {
                        packet.ReadUInt32("Transport Time 3", index);
                    }

                    moveInfo.TransportGuid = new WowGuid64(BitConverter.ToUInt64(transportGuid, 0));
                    packet.AddValue("Transport GUID", moveInfo.TransportGuid, index);
                    packet.AddValue("Transport Position", moveInfo.TransportOffset, index);

                    if (moveInfo.TransportGuid.HasEntry() && moveInfo.TransportGuid.GetHighType() == HighGuidType.Vehicle &&
                        guid.HasEntry() && guid.GetHighType() == HighGuidType.Creature)
                    {
                        var vehicleAccessory = new VehicleTemplateAccessory();
                        vehicleAccessory.AccessoryEntry = guid.GetEntry();
                        vehicleAccessory.SeatId         = seat;
                        Storage.VehicleTemplateAccessorys.Add(moveInfo.TransportGuid.GetEntry(), vehicleAccessory, packet.TimeSpan);
                    }
                }

                for (var i = 0; i < bits160; ++i)
                {
                    packet.ReadSingle("Float16C+1", index, i);
                    packet.ReadInt32("Int16C+4", index, i);
                    packet.ReadInt32("Int16C+0", index, i);
                    packet.ReadSingle("Float16C+3", index, i);
                    packet.ReadSingle("Float16C+5", index, i);
                    packet.ReadSingle("Float16C+2", index, i);
                }

                packet.ReadXORBytes(guid1, 2, 6, 0);

                if (hasFallData)
                {
                    if (hasFallDirection)
                    {
                        packet.ReadSingle("Jump Sin", index);
                        packet.ReadSingle("Jump Cos", index);
                        packet.ReadSingle("Jump Velocity", index);
                    }
                    packet.ReadSingle("Fall Start Velocity", index);
                    packet.ReadUInt32("Time Fallen", index);
                }

                if (hasPitch)
                {
                    packet.ReadSingle("Pitch", index);
                }

                moveInfo.Position.Y = packet.ReadSingle();

                if (hasTimestamp)
                {
                    packet.ReadUInt32("Time", index);
                }

                packet.ReadSingle("FloatC8", index);
                packet.ReadXORByte(guid1, 7);
                for (var i = 0; i < bits88; ++i)
                {
                    packet.ReadInt32("Int8C", index, i);
                }

                if (hasOrientation)
                {
                    moveInfo.Orientation = packet.ReadSingle();
                }

                packet.ReadSingle("FloatC0", index);
                packet.ReadSingle("FloatB4", index);
                packet.ReadXORByte(guid1, 1);
                moveInfo.Position.Z = packet.ReadSingle();
                if (hasSplineElevation)
                {
                    packet.ReadSingle("Spline Elevation", index);
                }
                packet.ReadXORByte(guid1, 4);
                packet.ReadSingle("FloatBC", index);
                packet.ReadSingle("FloatAC", index);
                packet.ReadSingle("FloatB8", index);
                packet.ReadSingle("FloatC4", index);
                packet.ReadSingle("FloatB0", index);
                moveInfo.Position.X = packet.ReadSingle();
                packet.ReadXORBytes(guid1, 5, 3);
                if (bit98)
                {
                    packet.ReadInt32("Int98", index);
                }

                packet.ReadSingle("FloatA8", index);

                packet.WriteGuid("GUID1", guid1, index);
                packet.AddValue("Position", moveInfo.Position, index);
                packet.AddValue("Orientation", moveInfo.Orientation, index);
            }

            if (hasSceneObjectData)
            {
                packet.ReadInt32("int334", index);
                if (bit340)
                {
                    packet.ReadByte("byte340", index);
                }

                for (var i = 0; i < 2; ++i)
                {
                    packet.ReadXORByte(guid358[i], 3);
                    for (var j = 0; j < bits358_5[i]; ++j)
                    {
                        if (bit358_6_2E[i][j])
                        {
                            packet.ReadInt16("short358+6+2E", index, i, j);
                        }

                        packet.ReadXORByte(guid358_6[i][j], 3);
                        for (var k = 0; k < bits358_6_74[i][j]; ++k)
                        {
                            packet.ReadByte("byte358+6+78+8", index, i, j, k);
                            if (bit358_6_78_9[i][j][k] != 9)
                            {
                                packet.ReadByte("byte358+6+78+9", index, i, j, k);
                            }

                            packet.ReadInt16("short358+6+78+2", index, i, j, k);
                            packet.ReadInt32("int358+6+78+0", index, i, j, k);
                            packet.ReadInt16("short358+6+78+3", index, i, j, k);
                        }

                        packet.ReadXORByte(guid358_6[i][j], 6);
                        for (var k = 0; k < bits358_6_84[i][j]; ++k)
                        {
                            packet.ReadInt32("int358+6+88+0", index, i, j, k);
                            if (bit358_6_88_C[i][j][k])
                            {
                                packet.ReadInt32("int358+6+88+C", index, i, j, k);
                            }

                            if (bit358_6_88_8[i][j][k])
                            {
                                packet.ReadInt32("int358+6+88+8", index, i, j, k);
                            }

                            if (bit358_6_88_10[i][j][k] != 9)
                            {
                                packet.ReadByte("byte358+6+88+10", index, i, j, k);
                            }

                            packet.ReadInt32("int358+6+88+4", index, i, j, k);
                        }

                        packet.ReadInt32("int358+6+28", index, i, j);
                        packet.ReadWoWString("String358+6+31", (int)bits358_6_31[i][j], index, i, j);

                        if (!bit358_6_30[i][j])
                        {
                            packet.ReadByte("byte358+6+30", index, i, j);
                        }

                        packet.ReadInt32("int358+6+24", index, i, j);
                        packet.ReadXORByte(guid358_6[i][j], 5);
                        packet.ReadInt32("int358+6+C", index, i, j);
                        for (var k = 0; k < bits358_6_94[i][j]; ++k)
                        {
                            packet.ReadInt32("int358+6+98+0", index, i, j, k);
                            packet.ReadInt32("int358+6+98+4", index, i, j, k);
                        }

                        packet.ReadXORByte(guid358_6[i][j], 7);
                        packet.ReadInt32("int358+6+18", index, i, j);
                        packet.ReadInt16("short358+6+2C", index, i, j);
                        packet.ReadInt32("int358+6+20", index, i, j);
                        packet.ReadInt32("int358+6+1C", index, i, j);
                        packet.ReadInt32("int358+6+10", index, i, j);
                        packet.ReadXORByte(guid358_6[i][j], 4);
                        packet.ReadInt16("short358+6+16", index, i, j);
                        packet.ReadXORByte(guid358_6[i][j], 2);
                        packet.ReadInt32("Int358+6+8", index, i, j);
                        packet.ReadXORByte(guid358_6[i][j], 1);
                        packet.ReadInt16("short358+6+14", index, i, j);
                        packet.ReadXORByte(guid358_6[i][j], 0);
                        packet.WriteGuid("Guid 358_6", guid358_6[i][j], index, i, j);
                    }

                    packet.ReadXORBytes(guid358[i], 5, 4, 0);
                    packet.ReadInt32("int358+8", index, i);
                    packet.ReadXORBytes(guid358[i], 7);
                    if (!bit358_24[i])
                    {
                        packet.ReadByte("byte358+24", index, i);
                    }

                    if (bit358_10[i])
                    {
                        packet.ReadInt16("Short358+10", index, i);
                    }

                    packet.ReadXORBytes(guid358[i], 6);
                    if (bit358_C[i])
                    {
                        packet.ReadInt32("int358+C", index, i);
                    }

                    packet.ReadByte("byte358+37", index, i);
                    packet.ReadXORBytes(guid358[i], 1, 2);
                    packet.WriteGuid("Guid358", guid358[i], index, i);
                }

                for (var i = 0; i < 3; ++i)
                {
                    for (var j = 0; j < bits388_10[i]; ++j)
                    {
                        packet.ReadInt32("int388+6+4", index, i, j);
                        packet.ReadInt32("int388+6+0", index, i, j);
                    }

                    for (var j = 0; j < bits388[i]; ++j)
                    {
                        if (bit388_1_C[i][j])
                        {
                            packet.ReadInt32("int388+1+C", index, i, j);
                        }

                        packet.ReadInt32("int388+1+0", index, i, j);

                        if (bit388_1_10[i][j] != 9)
                        {
                            packet.ReadByte("byte388+1+10", index, i, j);
                        }

                        packet.ReadInt32("int388+1+4", index, i, j);

                        if (bit388_1_8[i][j])
                        {
                            packet.ReadInt32("int388+1+8", index, i, j);
                        }
                    }
                }

                packet.ParseBitStream(CreatorGUID, 7, 0, 6, 2, 5, 1, 3, 4);
                if (bit332)
                {
                    packet.ReadInt16("short332", index);
                }
                if (bit338)
                {
                    packet.ReadInt32("int338", index);
                }
                if (bit341)
                {
                    packet.ReadByte("byte341", index);
                }
                if (bit33C)
                {
                    packet.ReadInt32("int33C", index);
                }
                if (bit330)
                {
                    packet.ReadInt16("Short318", index);
                }

                packet.WriteGuid("Creator GUID", CreatorGUID, index);
            }

            if (hasGameObjectPosition)
            {
                packet.ReadUInt32("GO Transport Time", index);
                moveInfo.TransportOffset.Y = packet.ReadSingle();
                packet.ReadXORBytes(goTransportGuid, 0, 5);
                if (hasGOTransportTime3)
                {
                    packet.ReadUInt32("GO Transport Time 3", index);
                }

                packet.ReadXORBytes(goTransportGuid, 7, 4);
                moveInfo.TransportOffset.O = packet.ReadSingle();
                moveInfo.TransportOffset.Z = packet.ReadSingle();
                packet.ReadXORBytes(goTransportGuid, 1, 3, 6);
                packet.ReadSByte("GO Transport Seat", index);
                if (hasGOTransportTime2)
                {
                    packet.ReadUInt32("GO Transport Time 2", index);
                }

                packet.ReadXORByte(goTransportGuid, 2);
                moveInfo.TransportOffset.X = packet.ReadSingle();
                moveInfo.TransportGuid     = new WowGuid64(BitConverter.ToUInt64(goTransportGuid, 0));
                packet.AddValue("GO Transport GUID", moveInfo.TransportGuid, index);
                packet.AddValue("GO Transport Position", moveInfo.TransportOffset, index);
            }

            if (hasStationaryPosition)
            {
                moveInfo.Orientation = packet.ReadSingle("Stationary Orientation", index);
                moveInfo.Position.Z  = packet.ReadSingle();
                moveInfo.Position.X  = packet.ReadSingle();
                moveInfo.Position.Y  = packet.ReadSingle();

                packet.AddValue("Stationary Position", moveInfo.Position, index);
            }

            if (hasAttackingTarget)
            {
                packet.ParseBitStream(attackingTargetGuid, 1, 5, 4, 7, 6, 2, 0, 3);
                packet.WriteGuid("Attacking GUID", attackingTargetGuid, index);
            }

            if (bit1DC)
            {
                packet.ReadInt32("int1D8", index);
            }
            if (bit2A4)
            {
                packet.ReadInt32("int2A0", index);
            }
            if (hasGameObjectRotation)
            {
                packet.ReadPackedQuaternion("GameObject Rotation", index);
            }

            if (hasVehicleData)
            {
                packet.ReadSingle("Vehicle Orientation", index);
                moveInfo.VehicleId = packet.ReadUInt32("Vehicle Id", index);
            }

            if (hasAnimKits)
            {
                if (hasAnimKit2)
                {
                    packet.ReadUInt16("Anim Kit 2", index);
                }
                if (hasAnimKit1)
                {
                    packet.ReadUInt16("Anim Kit 1", index);
                }
                if (hasAnimKit3)
                {
                    packet.ReadUInt16("Anim Kit 3", index);
                }
            }

            if (bit428)
            {
                for (var i = 0; i < bits418; ++i)
                {
                    packet.ReadInt32("Int3F8", index, i);
                }
            }

            if (bit414)
            {
                packet.ReadInt32("int410", index);
            }

            if (bit32A)
            {
                packet.ReadBytes("Bytes", (int)bits2AA);
            }

            if (isLiving && moveInfo.HasSplineData && hasFullSpline && splineType == SplineType.FacingTarget)
            {
                var facingTargetGuid = new byte[8];
                facingTargetGuid = packet.StartBitStream(3, 1, 0, 7, 6, 4, 5, 2);
                packet.ParseBitStream(facingTargetGuid, 3, 0, 4, 6, 1, 5, 2, 7);
                packet.WriteGuid("Facing Target GUID", facingTargetGuid, index);
            }

            return(moveInfo);
        }
예제 #24
0
        protected unsafe override void InternalParse()
        {
            var reader = this.Reader;

            uint nCharacters = reader.UnalignedReadInt(17);

            var guids = new Tuple<byte[], byte[]>[nCharacters];
            var firstLogin = new bool[nCharacters];
            var nameLengths = new uint[nCharacters];
            for (byte i = 0; i < nCharacters; ++i)
            {
                var guid1 = new byte[8];
                var guid2 = new byte[8];
                guids[i] = new Tuple<byte[], byte[]>(guid1, guid2);

                guid2[2] = reader.UnalignedReadTinyInt(1);
                guid1[2] = reader.UnalignedReadTinyInt(1);
                guid1[6] = reader.UnalignedReadTinyInt(1);
                guid1[5] = reader.UnalignedReadTinyInt(1);
                guid1[4] = reader.UnalignedReadTinyInt(1);
                guid2[4] = reader.UnalignedReadTinyInt(1);
                guid2[3] = reader.UnalignedReadTinyInt(1);
                guid2[7] = reader.UnalignedReadTinyInt(1);
                nameLengths[i] = reader.UnalignedReadInt(7);
                guid2[0] = reader.UnalignedReadTinyInt(1);
                guid1[0] = reader.UnalignedReadTinyInt(1);
                guid1[3] = reader.UnalignedReadTinyInt(1);
                guid1[1] = reader.UnalignedReadTinyInt(1);
                firstLogin[i] = reader.UnalignedReadBit();
                guid2[5] = reader.UnalignedReadTinyInt(1);
                guid1[7] = reader.UnalignedReadTinyInt(1);
                guid2[6] = reader.UnalignedReadTinyInt(1);
                guid2[1] = reader.UnalignedReadTinyInt(1);
            }

            uint counter = reader.UnalignedReadInt(23);
            Output
                .Append("Not drop character info: ").AppendLine(reader.UnalignedReadBit().ToString())
                .Append("Total Characters: ").AppendLine(nCharacters.ToString());

            for (byte i = 0; i < nCharacters; ++i)
            {
                var chrguids = guids[i];
                var guid1 = new WowGuid(chrguids.Item1);
                var guid2 = new WowGuid(chrguids.Item2);

                reader.Skip(23 * (4 + 4 + 1)); // item data

                Vector3 position;
                reader.ReadXorByte(ref guid2.Bytes[0]);
                reader.ReadXorByte(ref guid2.Bytes[1]);
                var face = reader.ReadByte();
                var petDisplayId = reader.ReadUInt32();
                reader.ReadXorByte(ref guid2.Bytes[7]);
                var gender = (Genders)reader.ReadByte();
                var level = reader.ReadByte();
                var petLevel = reader.ReadUInt32();
                var zone = (Zones)reader.ReadUInt32();
                position.Y = reader.ReadSingle();
                var petFamily = (CreatureFamilies)reader.ReadUInt32();
                var hairStyle = reader.ReadByte();
                reader.ReadXorByte(ref guid1.Bytes[1]);
                var name = reader.ReadString((int)nameLengths[i]);
                reader.ReadXorByte(ref guid1.Bytes[0]);
                var race = (Races)reader.ReadByte();
                var order = reader.ReadByte();
                reader.ReadXorByte(ref guid1.Bytes[7]);
                position.Z = reader.ReadSingle();
                var map = (Maps)reader.ReadUInt32();
                reader.ReadXorByte(ref guid2.Bytes[4]);
                var hairColor = reader.ReadByte();
                reader.ReadXorByte(ref guid1.Bytes[3]);
                var charFlags = (CharacterFlags)reader.ReadUInt32();
                var skin = reader.ReadByte();
                reader.ReadXorByte(ref guid1.Bytes[4]);
                reader.ReadXorByte(ref guid1.Bytes[5]);
                reader.ReadXorByte(ref guid2.Bytes[5]);
                var customizeFlags = (CharacterCustomizeFlags)reader.ReadUInt32();
                position.X = reader.ReadSingle();
                var facialHair = reader.ReadByte();
                reader.ReadXorByte(ref guid1.Bytes[6]);
                reader.ReadXorByte(ref guid2.Bytes[3]);
                reader.ReadXorByte(ref guid1.Bytes[2]);
                var classs = (Classes)reader.ReadByte();
                reader.ReadXorByte(ref guid2.Bytes[6]);
                reader.ReadXorByte(ref guid2.Bytes[2]);

                this.Output
                    .AppendLine("___________________________________________________________")
                    .AppendLine("GUID: " + guid1)
                    // Charname - Female Undead Warrior
                    .AppendFormatLine("{0} - {3} {1} {2} (#{4})", name, race.GetLocalizedName(), classs.GetLocalizedName(), gender.GetLocalizedName(), order)
                    .AppendFormatLine("Skin: {0} Face: {1} Hair Style: {2} Hair Color: {3} Facial Hair: {4}",
                    skin, face, hairStyle, hairColor, facialHair)
                    .AppendFormatLine("Character level: {0} Zone: {1} ({1:D}) Map: {2} ({2:D})", level, zone, map.GetLocalizedName())
                    .AppendLine("Position: " + position)
                    .AppendLine("Guild: " + guid2)
                    .AppendLine("Char Flags: " + charFlags)
                    .AppendLine("Customize Flags: " + customizeFlags)
                    .AppendLine("First login: "******"Pet: DisplayId {0}, Level {1}, Family {2} ({2:D})", petDisplayId, petLevel, petFamily);
            }

            Output
                .AppendLine()
                .AppendLine()
                .AppendLine("Unk Counter: " + counter);

            for (uint i = 0; i < counter; ++i)
            {
                Output.AppendFormatLine("   Unk: {0}, {1}", reader.ReadUInt32(), reader.ReadByte());
            }
        }
예제 #25
0
        private static void ReadCreateObjectBlock(Packet packet, CreateObject createObject, WowGuid guid, uint map, object index)
        {
            ObjectType objType = ObjectTypeConverter.Convert(packet.ReadByteE <ObjectType801>("Object Type", index));

            if (ClientVersion.RemovedInVersion(ClientVersionBuild.V8_1_0_28724))
            {
                packet.ReadInt32("HeirFlags", index);
            }
            WoWObject obj;

            switch (objType)
            {
            case ObjectType.Unit:
                obj = new Unit();
                break;

            case ObjectType.GameObject:
                obj = new GameObject();
                break;

            case ObjectType.Player:
                obj = new Player();
                break;

            case ObjectType.AreaTrigger:
                obj = new SpellAreaTrigger();
                break;

            case ObjectType.Conversation:
                obj = new ConversationTemplate();
                break;

            default:
                obj = new WoWObject();
                break;
            }

            var moves = ReadMovementUpdateBlock(packet, createObject, guid, obj, index);

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_1_0_28724))
            {
                var updatefieldSize = packet.ReadUInt32();
                using (var fieldsData = new Packet(packet.ReadBytes((int)updatefieldSize), packet.Opcode, packet.Time, packet.Direction, packet.Number, packet.Writer, packet.FileName))
                {
                    var flags   = fieldsData.ReadByteE <UpdateFieldFlag>("FieldFlags", index);
                    var handler = CoreFields.UpdateFields.GetHandler();
                    obj.ObjectData = handler.ReadCreateObjectData(fieldsData, flags, index);
                    switch (objType)
                    {
                    case ObjectType.Item:
                        handler.ReadCreateItemData(fieldsData, flags, index);
                        break;

                    case ObjectType.Container:
                        handler.ReadCreateItemData(fieldsData, flags, index);
                        handler.ReadCreateContainerData(fieldsData, flags, index);
                        break;

                    case ObjectType.AzeriteEmpoweredItem:
                        handler.ReadCreateItemData(fieldsData, flags, index);
                        handler.ReadCreateAzeriteEmpoweredItemData(fieldsData, flags, index);
                        break;

                    case ObjectType.AzeriteItem:
                        handler.ReadCreateItemData(fieldsData, flags, index);
                        handler.ReadCreateAzeriteItemData(fieldsData, flags, index);
                        break;

                    case ObjectType.Unit:
                        (obj as Unit).UnitData = handler.ReadCreateUnitData(fieldsData, flags, index);
                        break;

                    case ObjectType.Player:
                        handler.ReadCreateUnitData(fieldsData, flags, index);
                        handler.ReadCreatePlayerData(fieldsData, flags, index);
                        break;

                    case ObjectType.ActivePlayer:
                        handler.ReadCreateUnitData(fieldsData, flags, index);
                        handler.ReadCreatePlayerData(fieldsData, flags, index);
                        handler.ReadCreateActivePlayerData(fieldsData, flags, index);
                        break;

                    case ObjectType.GameObject:
                        (obj as GameObject).GameObjectData = handler.ReadCreateGameObjectData(fieldsData, flags, index);
                        break;

                    case ObjectType.DynamicObject:
                        handler.ReadCreateDynamicObjectData(fieldsData, flags, index);
                        break;

                    case ObjectType.Corpse:
                        handler.ReadCreateCorpseData(fieldsData, flags, index);
                        break;

                    case ObjectType.AreaTrigger:
                        (obj as SpellAreaTrigger).AreaTriggerData = handler.ReadCreateAreaTriggerData(fieldsData, flags, index);
                        break;

                    case ObjectType.SceneObject:
                        handler.ReadCreateSceneObjectData(fieldsData, flags, index);
                        break;

                    case ObjectType.Conversation:
                        (obj as ConversationTemplate).ConversationData = handler.ReadCreateConversationData(fieldsData, flags, index);
                        break;
                    }
                }
            }
            else
            {
                var updates        = CoreParsers.UpdateHandler.ReadValuesUpdateBlockOnCreate(packet, createObject.Values, objType, index);
                var dynamicUpdates = CoreParsers.UpdateHandler.ReadDynamicValuesUpdateBlockOnCreate(packet, objType, index);

                obj.UpdateFields        = updates;
                obj.DynamicUpdateFields = dynamicUpdates;
            }

            obj.Type         = objType;
            obj.Movement     = moves;
            obj.Map          = map;
            obj.Area         = CoreParsers.WorldStateHandler.CurrentAreaId;
            obj.Zone         = CoreParsers.WorldStateHandler.CurrentZoneId;
            obj.PhaseMask    = (uint)CoreParsers.MovementHandler.CurrentPhaseMask;
            obj.Phases       = new HashSet <ushort>(CoreParsers.MovementHandler.ActivePhases.Keys);
            obj.DifficultyID = CoreParsers.MovementHandler.CurrentDifficultyID;

            // If this is the second time we see the same object (same guid,
            // same position) update its phasemask
            if (Storage.Objects.ContainsKey(guid))
            {
                var existObj = Storage.Objects[guid].Item1;
                CoreParsers.UpdateHandler.ProcessExistingObject(ref existObj, obj, guid); // can't do "ref Storage.Objects[guid].Item1 directly
            }
            else
            {
                Storage.Objects.Add(guid, obj, packet.TimeSpan);
            }

            if (guid.HasEntry() && (objType == ObjectType.Unit || objType == ObjectType.GameObject))
            {
                packet.AddSniffData(Utilities.ObjectTypeToStore(objType), (int)guid.GetEntry(), "SPAWN");
            }
        }
예제 #26
0
        private void ReadFromStreamHandler(StreamHandler Reader, WowOpcodes opcode)
        {
            GameMasterMessage = (opcode == WowOpcodes.SMSG_GM_MESSAGECHAT);

            m_type = (ChatMessageType)Reader.ReadByte();
            if (m_type == ChatMessageType.Addon2)
                m_type = ChatMessageType.Addon;

            m_language = (Language)Reader.ReadUInt32();
            m_senderGUID = Reader.ReadGuid();
            m_unknownUInt32 = Reader.ReadUInt32();

            switch (m_type)
            {
                case ChatMessageType.MonsterSay:
                case ChatMessageType.MonsterParty:
                case ChatMessageType.MonsterYell:
                case ChatMessageType.MonsterWhisper:
                case ChatMessageType.MonsterEmote:
                case ChatMessageType.BattleNet:
                case ChatMessageType.RaidBossEmote:
                case ChatMessageType.RaidBossWhisper:
                    Reader.Skip(4);
                    m_senderName = Reader.ReadCString();
                    m_targetGUID = Reader.ReadGuid();
                    if (!m_targetGUID.IsEmpty
                        && !m_targetGUID.IsPlayer
                        && !m_targetGUID.IsPet)
                    {
                        Reader.Skip(4);
                        m_targetName = Reader.ReadCString();
                    }
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    if (m_type == ChatMessageType.RaidBossEmote || m_type == ChatMessageType.RaidBossWhisper)
                    {
                        m_displayTime = Reader.ReadSingle();
                        m_suspendEvent = Reader.ReadBoolean();
                    }
                    break;
                case ChatMessageType.BGSystemNeutral:
                case ChatMessageType.BGSystemAlliance:
                case ChatMessageType.BGSystemHorde:
                    m_targetGUID = Reader.ReadGuid();
                    if (!m_targetGUID.IsEmpty
                        && !m_targetGUID.IsPlayer)
                    {
                        Reader.Skip(4);
                        m_targetName = Reader.ReadCString();
                    }
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    break;
                case ChatMessageType.Achievement:
                case ChatMessageType.GuildAchievement:
                    m_targetGUID = Reader.ReadGuid();
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    m_achievementId = Reader.ReadUInt32();
                    break;
                case ChatMessageType.WhisperForeign:
                    Reader.Skip(4);
                    m_senderName = Reader.ReadCString();
                    m_targetGUID = Reader.ReadGuid();
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    break;
                default:
                    if (GameMasterMessage)
                    {
                        Reader.Skip(4);
                        m_senderName = Reader.ReadCString();
                    }
                    if (m_type == ChatMessageType.Channel)
                        m_channel = Reader.ReadCString();
                    m_targetGUID = Reader.ReadGuid();
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    break;
            }
        }
예제 #27
0
 public ThreatRemove(WowGuid guid, WowGuid victim)
 {
     this.Unit = guid;
     this.Victim = victim;
 }
예제 #28
0
        private static MovementInfo ReadMovementUpdateBlock(Packet packet, CreateObject createObject, WowGuid guid, WoWObject obj, object index)
        {
            var moveInfo = new MovementInfo();

            packet.ResetBitReader();

            packet.ReadBit("NoBirthAnim", index);
            packet.ReadBit("EnablePortals", index);
            packet.ReadBit("PlayHoverAnim", index);

            var hasMovementUpdate     = packet.ReadBit("HasMovementUpdate", index);
            var hasMovementTransport  = packet.ReadBit("HasMovementTransport", index);
            var hasStationaryPosition = packet.ReadBit("Stationary", index);
            var hasCombatVictim       = packet.ReadBit("HasCombatVictim", index);
            var hasServerTime         = packet.ReadBit("HasServerTime", index);
            var hasVehicleCreate      = packet.ReadBit("HasVehicleCreate", index);
            var hasAnimKitCreate      = packet.ReadBit("HasAnimKitCreate", index);
            var hasRotation           = packet.ReadBit("HasRotation", index);
            var hasAreaTrigger        = packet.ReadBit("HasAreaTrigger", index);
            var hasGameObject         = packet.ReadBit("HasGameObject", index);
            var hasSmoothPhasing      = packet.ReadBit("HasSmoothPhasing", index);

            packet.ReadBit("ThisIsYou", index);

            var sceneObjCreate   = packet.ReadBit("SceneObjCreate", index);
            var playerCreateData = packet.ReadBit("HasPlayerCreateData", index);
            var hasConversation  = packet.ReadBit("HasConversation", index);

            if (hasMovementUpdate)
            {
                var movementUpdate = createObject.Movement = new();
                packet.ResetBitReader();
                movementUpdate.Mover = packet.ReadPackedGuid128("MoverGUID", index);

                movementUpdate.MoveTime    = packet.ReadUInt32("MoveTime", index);
                movementUpdate.Position    = moveInfo.Position = packet.ReadVector3("Position", index);
                movementUpdate.Orientation = moveInfo.Orientation = packet.ReadSingle("Orientation", index);

                movementUpdate.Pitch = packet.ReadSingle("Pitch", index);
                movementUpdate.StepUpStartElevation = packet.ReadSingle("StepUpStartElevation", index);

                var removeForcesIDsCount = packet.ReadInt32();
                movementUpdate.MoveIndex = packet.ReadInt32("MoveIndex", index);

                for (var i = 0; i < removeForcesIDsCount; i++)
                {
                    packet.ReadPackedGuid128("RemoveForcesIDs", index, i);
                }

                moveInfo.Flags  = (uint)packet.ReadBitsE <MovementFlag>("Movement Flags", 30, index);
                moveInfo.Flags2 = (uint)packet.ReadBitsE <MovementFlag2>("Extra Movement Flags", 18, index);

                var hasTransport = packet.ReadBit("Has Transport Data", index);
                var hasFall      = packet.ReadBit("Has Fall Data", index);
                packet.ReadBit("HasSpline", index);
                packet.ReadBit("HeightChangeFailed", index);
                packet.ReadBit("RemoteTimeValid", index);

                if (hasTransport)
                {
                    movementUpdate.Transport = V8_0_1_27101.Parsers.UpdateHandler.ReadTransportData(moveInfo, guid, packet, index);
                }

                if (hasFall)
                {
                    packet.ResetBitReader();
                    movementUpdate.FallTime     = packet.ReadUInt32("Fall Time", index);
                    movementUpdate.JumpVelocity = packet.ReadSingle("JumpVelocity", index);

                    var hasFallDirection = packet.ReadBit("Has Fall Direction", index);
                    if (hasFallDirection)
                    {
                        packet.ReadVector2("Fall", index);
                        packet.ReadSingle("Horizontal Speed", index);
                    }
                }

                movementUpdate.WalkSpeed = moveInfo.WalkSpeed = packet.ReadSingle("WalkSpeed", index) / 2.5f;
                movementUpdate.RunSpeed  = moveInfo.RunSpeed = packet.ReadSingle("RunSpeed", index) / 7.0f;
                packet.ReadSingle("RunBackSpeed", index);
                packet.ReadSingle("SwimSpeed", index);
                packet.ReadSingle("SwimBackSpeed", index);
                packet.ReadSingle("FlightSpeed", index);
                packet.ReadSingle("FlightBackSpeed", index);
                packet.ReadSingle("TurnRate", index);
                packet.ReadSingle("PitchRate", index);

                var movementForceCount = packet.ReadInt32("MovementForceCount", index);

                packet.ResetBitReader();

                moveInfo.HasSplineData = packet.ReadBit("HasMovementSpline", index);

                for (var i = 0; i < movementForceCount; ++i)
                {
                    packet.ResetBitReader();
                    packet.ReadPackedGuid128("Id", index);
                    packet.ReadVector3("Origin", index);
                    packet.ReadVector3("Direction", index);
                    packet.ReadInt32("TransportID", index);
                    packet.ReadSingle("Magnitude", index);
                    packet.ReadBits("Type", 2, index);
                }

                if (moveInfo.HasSplineData)
                {
                    var splineData = movementUpdate.SplineData = new();
                    packet.ResetBitReader();
                    splineData.Id          = packet.ReadInt32("ID", index);
                    splineData.Destination = packet.ReadVector3("Destination", index);

                    var hasMovementSplineMove = packet.ReadBit("MovementSplineMove", index);
                    if (hasMovementSplineMove)
                    {
                        var splineMove = splineData.MoveData = new();
                        packet.ResetBitReader();

                        splineMove.Flags                = packet.ReadUInt32E <SplineFlag>("SplineFlags", index).ToUniversal();
                        splineMove.Elapsed              = packet.ReadInt32("Elapsed", index);
                        splineMove.Duration             = packet.ReadUInt32("Duration", index);
                        splineMove.DurationModifier     = packet.ReadSingle("DurationModifier", index);
                        splineMove.NextDurationModifier = packet.ReadSingle("NextDurationModifier", index);

                        var face           = packet.ReadBits("Face", 2, index);
                        var hasSpecialTime = packet.ReadBit("HasSpecialTime", index);

                        var pointsCount = packet.ReadBits("PointsCount", 16, index);

                        packet.ReadBitsE <SplineMode>("Mode", 2, index);

                        var hasSplineFilterKey      = packet.ReadBit("HasSplineFilterKey", index);
                        var hasSpellEffectExtraData = packet.ReadBit("HasSpellEffectExtraData", index);
                        var hasJumpExtraData        = packet.ReadBit("HasJumpExtraData", index);

                        if (hasSplineFilterKey)
                        {
                            packet.ResetBitReader();
                            var filterKeysCount = packet.ReadUInt32("FilterKeysCount", index);
                            for (var i = 0; i < filterKeysCount; ++i)
                            {
                                packet.ReadSingle("In", index, i);
                                packet.ReadSingle("Out", index, i);
                            }

                            packet.ReadBits("FilterFlags", 2, index);
                        }

                        switch (face)
                        {
                        case 1:
                            splineMove.LookPosition = packet.ReadVector3("FaceSpot", index);
                            break;

                        case 2:
                            splineMove.LookTarget = new() { Target = packet.ReadPackedGuid128("FaceGUID", index) };
                            break;

                        case 3:
                            splineMove.LookOrientation = packet.ReadSingle("FaceDirection", index);
                            break;

                        default:
                            break;
                        }

                        if (hasSpecialTime)
                        {
                            packet.ReadUInt32("SpecialTime", index);
                        }

                        for (var i = 0; i < pointsCount; ++i)
                        {
                            splineMove.Points.Add(packet.ReadVector3("Points", index, i));
                        }

                        if (hasSpellEffectExtraData)
                        {
                            V8_0_1_27101.Parsers.MovementHandler.ReadMonsterSplineSpellEffectExtraData(packet, index);
                        }

                        if (hasJumpExtraData)
                        {
                            splineMove.Jump = V8_0_1_27101.Parsers.MovementHandler.ReadMonsterSplineJumpExtraData(packet, index);
                        }
                    }
                }
            }

            var pauseTimesCount = packet.ReadUInt32("PauseTimesCount", index);

            if (hasStationaryPosition)
            {
                moveInfo.Position    = packet.ReadVector3();
                moveInfo.Orientation = packet.ReadSingle();

                packet.AddValue("Stationary Position", moveInfo.Position, index);
                packet.AddValue("Stationary Orientation", moveInfo.Orientation, index);
                createObject.Stationary = new() { Position = moveInfo.Position, Orientation = moveInfo.Orientation };
            }

            if (hasCombatVictim)
            {
                packet.ReadPackedGuid128("CombatVictim Guid", index);
            }

            if (hasServerTime)
            {
                packet.ReadUInt32("ServerTime", index);
            }

            if (hasVehicleCreate)
            {
                var vehicle = createObject.Vehicle = new();
                moveInfo.VehicleId       = packet.ReadUInt32("RecID", index);
                vehicle.VehicleId        = (int)moveInfo.VehicleId;
                vehicle.InitialRawFacing = packet.ReadSingle("InitialRawFacing", index);
            }

            if (hasAnimKitCreate)
            {
                packet.ReadUInt16("AiID", index);
                packet.ReadUInt16("MovementID", index);
                packet.ReadUInt16("MeleeID", index);
            }

            if (hasRotation)
            {
                createObject.Rotation = moveInfo.Rotation = packet.ReadPackedQuaternion("GameObject Rotation", index);
            }

            for (var i = 0; i < pauseTimesCount; ++i)
            {
                packet.ReadInt32("PauseTimes", index, i);
            }

            if (hasMovementTransport)
            {
                moveInfo.Transport = new MovementInfo.TransportInfo();
                var transport = createObject.Transport = new();
                packet.ResetBitReader();
                transport.TransportGuid = moveInfo.Transport.Guid = packet.ReadPackedGuid128("TransportGUID", index);
                transport.Position      = moveInfo.Transport.Offset = packet.ReadVector4("TransportPosition", index);
                var seat = packet.ReadByte("VehicleSeatIndex", index);
                transport.Seat     = seat;
                transport.MoveTime = packet.ReadUInt32("MoveTime", index);

                var hasPrevMoveTime = packet.ReadBit("HasPrevMoveTime", index);
                var hasVehicleRecID = packet.ReadBit("HasVehicleRecID", index);

                if (hasPrevMoveTime)
                {
                    transport.PrevMoveTime = packet.ReadUInt32("PrevMoveTime", index);
                }

                if (hasVehicleRecID)
                {
                    transport.VehicleId = packet.ReadInt32("VehicleRecID", index);
                }

                if (moveInfo.Transport.Guid.HasEntry() && moveInfo.Transport.Guid.GetHighType() == HighGuidType.Vehicle &&
                    guid.HasEntry() && guid.GetHighType() == HighGuidType.Creature)
                {
                    VehicleTemplateAccessory vehicleAccessory = new VehicleTemplateAccessory
                    {
                        Entry          = moveInfo.Transport.Guid.GetEntry(),
                        AccessoryEntry = guid.GetEntry(),
                        SeatId         = seat
                    };
                    Storage.VehicleTemplateAccessories.Add(vehicleAccessory, packet.TimeSpan);
                }
            }

            if (hasAreaTrigger && obj is AreaTriggerCreateProperties)
            {
                AreaTriggerTemplate areaTriggerTemplate = new AreaTriggerTemplate
                {
                    Id = guid.GetEntry()
                };

                AreaTriggerCreateProperties spellAreaTrigger = (AreaTriggerCreateProperties)obj;
                spellAreaTrigger.AreaTriggerId = guid.GetEntry();

                packet.ResetBitReader();

                // CliAreaTrigger
                packet.ReadUInt32("ElapsedMs", index);

                packet.ReadVector3("RollPitchYaw", index);

                areaTriggerTemplate.Flags = 0;

                if (packet.ReadBit("HasAbsoluteOrientation", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasAbsoluteOrientation;
                }

                if (packet.ReadBit("HasDynamicShape", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasDynamicShape;
                }

                if (packet.ReadBit("HasAttached", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasAttached;
                }

                if (packet.ReadBit("HasFaceMovementDir", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.FaceMovementDirection;
                }

                if (packet.ReadBit("HasFollowsTerrain", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.FollowsTerrain;
                }

                if (packet.ReadBit("Unk bit WoD62x", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.Unk1;
                }

                if (packet.ReadBit("HasTargetRollPitchYaw", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasTargetRollPitchYaw;
                }

                bool hasScaleCurveID  = packet.ReadBit("HasScaleCurveID", index);
                bool hasMorphCurveID  = packet.ReadBit("HasMorphCurveID", index);
                bool hasFacingCurveID = packet.ReadBit("HasFacingCurveID", index);
                bool hasMoveCurveID   = packet.ReadBit("HasMoveCurveID", index);

                if (packet.ReadBit("HasAnimID", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasAnimId;
                }

                if (packet.ReadBit("HasAnimKitID", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasAnimKitId;
                }

                if (packet.ReadBit("unkbit50", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.Unk3;
                }

                bool hasAnimProgress = packet.ReadBit("HasAnimProgress", index);

                if (packet.ReadBit("HasAreaTriggerSphere", index))
                {
                    areaTriggerTemplate.Type = (byte)AreaTriggerType.Sphere;
                }

                if (packet.ReadBit("HasAreaTriggerBox", index))
                {
                    areaTriggerTemplate.Type = (byte)AreaTriggerType.Box;
                }

                if (packet.ReadBit("HasAreaTriggerPolygon", index))
                {
                    areaTriggerTemplate.Type = (byte)AreaTriggerType.Polygon;
                }

                if (packet.ReadBit("HasAreaTriggerCylinder", index))
                {
                    areaTriggerTemplate.Type = (byte)AreaTriggerType.Cylinder;
                }

                bool hasAreaTriggerSpline = packet.ReadBit("HasAreaTriggerSpline", index);

                if (packet.ReadBit("HasAreaTriggerOrbit", index))
                {
                    areaTriggerTemplate.Flags |= (uint)AreaTriggerFlags.HasOrbit;
                }

                if ((areaTriggerTemplate.Flags & (uint)AreaTriggerFlags.Unk3) != 0)
                {
                    packet.ReadBit();
                }

                if (hasAreaTriggerSpline)
                {
                    foreach (var splinePoint in V7_0_3_22248.Parsers.AreaTriggerHandler.ReadAreaTriggerSpline((AreaTriggerCreateProperties)obj, packet, index, "AreaTriggerSpline"))
                    {
                        Storage.AreaTriggerCreatePropertiesSplinePoints.Add(splinePoint);
                    }
                }

                if ((areaTriggerTemplate.Flags & (uint)AreaTriggerFlags.HasTargetRollPitchYaw) != 0)
                {
                    packet.ReadVector3("TargetRollPitchYaw", index);
                }

                if (hasScaleCurveID)
                {
                    spellAreaTrigger.ScaleCurveId = (int)packet.ReadUInt32("ScaleCurveID", index);
                }

                if (hasMorphCurveID)
                {
                    spellAreaTrigger.MorphCurveId = (int)packet.ReadUInt32("MorphCurveID", index);
                }

                if (hasFacingCurveID)
                {
                    spellAreaTrigger.FacingCurveId = (int)packet.ReadUInt32("FacingCurveID", index);
                }

                if (hasMoveCurveID)
                {
                    spellAreaTrigger.MoveCurveId = (int)packet.ReadUInt32("MoveCurveID", index);
                }

                if ((areaTriggerTemplate.Flags & (int)AreaTriggerFlags.HasAnimId) != 0)
                {
                    spellAreaTrigger.AnimId = packet.ReadInt32("AnimId", index);
                }

                if ((areaTriggerTemplate.Flags & (int)AreaTriggerFlags.HasAnimKitId) != 0)
                {
                    spellAreaTrigger.AnimKitId = packet.ReadInt32("AnimKitId", index);
                }

                if (hasAnimProgress)
                {
                    packet.ReadUInt32("AnimProgress", index);
                }

                if (areaTriggerTemplate.Type == (byte)AreaTriggerType.Sphere)
                {
                    areaTriggerTemplate.Data[0] = packet.ReadSingle("Radius", index);
                    areaTriggerTemplate.Data[1] = packet.ReadSingle("RadiusTarget", index);
                }

                if (areaTriggerTemplate.Type == (byte)AreaTriggerType.Box)
                {
                    Vector3 Extents       = packet.ReadVector3("Extents", index);
                    Vector3 ExtentsTarget = packet.ReadVector3("ExtentsTarget", index);

                    areaTriggerTemplate.Data[0] = Extents.X;
                    areaTriggerTemplate.Data[1] = Extents.Y;
                    areaTriggerTemplate.Data[2] = Extents.Z;

                    areaTriggerTemplate.Data[3] = ExtentsTarget.X;
                    areaTriggerTemplate.Data[4] = ExtentsTarget.Y;
                    areaTriggerTemplate.Data[5] = ExtentsTarget.Z;
                }

                if (areaTriggerTemplate.Type == (byte)AreaTriggerType.Polygon)
                {
                    var verticesCount       = packet.ReadUInt32("VerticesCount", index);
                    var verticesTargetCount = packet.ReadUInt32("VerticesTargetCount", index);

                    List <AreaTriggerCreatePropertiesPolygonVertex> verticesList = new List <AreaTriggerCreatePropertiesPolygonVertex>();

                    areaTriggerTemplate.Data[0] = packet.ReadSingle("Height", index);
                    areaTriggerTemplate.Data[1] = packet.ReadSingle("HeightTarget", index);

                    for (uint i = 0; i < verticesCount; ++i)
                    {
                        AreaTriggerCreatePropertiesPolygonVertex spellAreatriggerVertices = new AreaTriggerCreatePropertiesPolygonVertex
                        {
                            areatriggerGuid = guid,
                            Idx             = i
                        };

                        Vector2 vertices = packet.ReadVector2("Vertices", index, i);

                        spellAreatriggerVertices.VerticeX = vertices.X;
                        spellAreatriggerVertices.VerticeY = vertices.Y;

                        verticesList.Add(spellAreatriggerVertices);
                    }

                    for (var i = 0; i < verticesTargetCount; ++i)
                    {
                        Vector2 verticesTarget = packet.ReadVector2("VerticesTarget", index, i);

                        verticesList[i].VerticeTargetX = verticesTarget.X;
                        verticesList[i].VerticeTargetY = verticesTarget.Y;
                    }

                    foreach (AreaTriggerCreatePropertiesPolygonVertex vertice in verticesList)
                    {
                        Storage.AreaTriggerCreatePropertiesPolygonVertices.Add(vertice);
                    }
                }

                if (areaTriggerTemplate.Type == (byte)AreaTriggerType.Cylinder)
                {
                    areaTriggerTemplate.Data[0] = packet.ReadSingle("Radius", index);
                    areaTriggerTemplate.Data[1] = packet.ReadSingle("RadiusTarget", index);
                    areaTriggerTemplate.Data[2] = packet.ReadSingle("Height", index);
                    areaTriggerTemplate.Data[3] = packet.ReadSingle("HeightTarget", index);
                    areaTriggerTemplate.Data[4] = packet.ReadSingle("LocationZOffset", index);
                    areaTriggerTemplate.Data[5] = packet.ReadSingle("LocationZOffsetTarget", index);
                }

                if ((areaTriggerTemplate.Flags & (uint)AreaTriggerFlags.HasOrbit) != 0)
                {
                    Storage.AreaTriggerCreatePropertiesOrbits.Add(V7_0_3_22248.Parsers.AreaTriggerHandler.ReadAreaTriggerOrbit(guid, packet, index, "AreaTriggerOrbit"));
                }

                spellAreaTrigger.Shape = areaTriggerTemplate.Type;
                Array.Copy(areaTriggerTemplate.Data, spellAreaTrigger.ShapeData, Math.Min(areaTriggerTemplate.Data.Length, spellAreaTrigger.ShapeData.Length));

                Storage.AreaTriggerTemplates.Add(areaTriggerTemplate);
            }

            if (hasGameObject)
            {
                packet.ResetBitReader();
                packet.ReadInt32("WorldEffectID", index);

                var bit8 = packet.ReadBit("bit8", index);
                if (bit8)
                {
                    packet.ReadInt32("Int1", index);
                }
            }

            if (hasSmoothPhasing)
            {
                packet.ResetBitReader();
                packet.ReadBit("ReplaceActive", index);
                var replaceObject = packet.ReadBit();
                if (replaceObject)
                {
                    packet.ReadPackedGuid128("ReplaceObject", index);
                }
            }

            if (sceneObjCreate)
            {
                packet.ResetBitReader();

                var hasSceneLocalScriptData = packet.ReadBit("HasSceneLocalScriptData", index);
                var petBattleFullUpdate     = packet.ReadBit("HasPetBattleFullUpdate", index);

                if (hasSceneLocalScriptData)
                {
                    packet.ResetBitReader();
                    var dataLength = packet.ReadBits(7);
                    packet.ReadWoWString("Data", dataLength, index);
                }

                if (petBattleFullUpdate)
                {
                    V6_0_2_19033.Parsers.BattlePetHandler.ReadPetBattleFullUpdate(packet, index);
                }
            }

            if (playerCreateData)
            {
                packet.ResetBitReader();
                var hasSceneInstanceIDs = packet.ReadBit("ScenePendingInstances", index);
                var hasRuneState        = packet.ReadBit("Runes", index);
                var hasActionButtons    = packet.ReadBit("Unk1132", index);

                if (hasSceneInstanceIDs)
                {
                    var sceneInstanceIDs = packet.ReadInt32("SceneInstanceIDsCount");
                    for (var i = 0; i < sceneInstanceIDs; ++i)
                    {
                        packet.ReadInt32("SceneInstanceIDs", index, i);
                    }
                }

                if (hasRuneState)
                {
                    packet.ReadByte("RechargingRuneMask", index);
                    packet.ReadByte("UsableRuneMask", index);
                    var runeCount = packet.ReadUInt32();
                    for (var i = 0; i < runeCount; ++i)
                    {
                        packet.ReadByte("RuneCooldown", index, i);
                    }
                }

                if (hasActionButtons)
                {
                    for (int i = 0; i < 132; i++)
                    {
                        packet.ReadInt32("Action", index, i);
                    }
                }
            }

            if (hasConversation)
            {
                packet.ResetBitReader();
                if (packet.ReadBit("HasTextureKitID", index))
                {
                    (obj as ConversationTemplate).TextureKitId = packet.ReadUInt32("TextureKitID", index);
                }
            }
            return(moveInfo);
        }
    }
예제 #29
0
 public ThreatClear(WowGuid guid)
 {
     this.Unit = guid;
 }
예제 #30
0
 /// <summary>
 /// Initializes a new instance of SpellGo class.
 /// </summary>
 /// <param name="caster">
 /// Guid of the caster unit.
 /// </param>
 /// <param name="spellId">
 /// The spell id to use.
 /// </param>
 public SpellGo(WowGuid caster, uint spellId)
 {
     Caster = caster;
     CastInvoker = caster;
     CastId = 1;
     SpellId = spellId;
     Flags = CastFlags.None;
     CastTime = (uint)Environment.TickCount;
 }
예제 #31
0
        public static void ReadSpellTargetData(Packet packet, ref TargetFlag targetFlags, WowGuid targetGUID, params object[] idx)
        {
            targetFlags = packet.ReadInt32E <TargetFlag>("Flags", idx);

            if (targetFlags.HasAnyFlag(TargetFlag.Unit | TargetFlag.CorpseEnemy | TargetFlag.GameObject | TargetFlag.CorpseAlly | TargetFlag.UnitMinipet))
            {
                targetGUID = packet.ReadPackedGuid("Unit", idx);
            }

            if (targetFlags.HasAnyFlag(TargetFlag.Item | TargetFlag.TradeItem))
            {
                packet.ReadPackedGuid("Item", idx);
            }

            if (targetFlags.HasAnyFlag(TargetFlag.SourceLocation))
            {
                ReadLocation(packet, "SrcLocation");
            }

            if (targetFlags.HasAnyFlag(TargetFlag.DestinationLocation))
            {
                ReadLocation(packet, "DstLocation");
            }

            if (targetFlags.HasAnyFlag(TargetFlag.NameString))
            {
                packet.ReadCString("Name", idx);
            }
        }
예제 #32
0
        public override void Read(StreamHandler Reader)
        {
            Caster = Reader.ReadPackedGuid();
            CastInvoker = Reader.ReadPackedGuid();
            CastId = Reader.ReadByte();
            SpellId = Reader.ReadUInt32();
            Flags = (CastFlags)Reader.ReadUInt32();
            Unk43 = Reader.ReadUInt32();
            Unk43_2 = Reader.ReadUInt32();

            TargetData.Read(Reader);

            if ((Flags & CastFlags.PredictedPower) != 0)
                PredictedPower = Reader.ReadUInt32();

            if ((Flags & CastFlags.RuneStates) != 0)
            {
                RunesBefore = (RuneStates)Reader.ReadByte();
                RunesAfter = (RuneStates)Reader.ReadByte();
                for (int i = 0; i < RuneCooldowns.Length; ++i)
                    RuneCooldowns[i] = Reader.ReadByte();
            }

            if ((Flags & CastFlags.Ammo) != 0)
            {
                ProjectileDisplayId = Reader.ReadUInt32();
                ProjectileInventoryType = (InventorySlotType)Reader.ReadUInt32();
            }

            if ((Flags & CastFlags.Unk0x04000000) != 0)
            {
                Unk0x04000000_UInt32_1 = Reader.ReadUInt32();
                Unk0x04000000_UInt32_2 = Reader.ReadUInt32();
            }
        }
예제 #33
0
        protected override void ReadMovementData()
        {
            m_transportGuid = Reader.ReadPackedGuid();
            m_transportSeat = Reader.ReadSByte();

            base.ReadMovementData();
        }
예제 #34
0
        protected virtual void ReadMovementData()
        {
            this.UnkByte = Reader.ReadByte();
            m_currentPosition = Reader.ReadVector3();
            m_tickCount = Reader.ReadUInt32();
            m_splineType = (SplineType)Reader.ReadByte();

            switch (m_splineType)
            {
                case SplineType.Normal:
                    break;
                case SplineType.Stop:
                    // client sets following values to:
                    // movementFlags = 0x1000;
                    // moveTime = 0;
                    // splinesCount = 1;
                    m_points = new Vector3[0];
                    return;
                case SplineType.FacingSpot:
                    m_facingSpot = Reader.ReadVector3();
                    break;
                case SplineType.FacingTarget:
                    m_facingTarget = Reader.ReadGuid();
                    break;
                case SplineType.FacingAngle:
                    m_facingAngle = Reader.ReadSingle();
                    break;
                default:
                    throw new Exception("Not updated SplineType switch in MonsterMove (Read)");
            }

            m_splineFlags = (SplineFlags)Reader.ReadUInt32();

            if ((m_splineFlags & SplineFlags.Animation) != 0)
            {
                m_animEmote = Reader.ReadByte();
                m_animTime = Reader.ReadUInt32();
            }

            m_moveTime = Reader.ReadUInt32();

            if ((m_splineFlags & SplineFlags.Parabolic) != 0)
            {
                m_trajectorySingle = Reader.ReadSingle();
                m_trajectoryUInt32 = Reader.ReadUInt32();
            }

            uint pointCount = Reader.ReadUInt32();
            m_points = new Vector3[pointCount];

            if ((m_splineFlags & (SplineFlags.Flying | SplineFlags.CatMullRom)) != 0)
            {
                for (uint i = 0; i < pointCount; ++i)
                    m_points[i] = Reader.ReadVector3();
            }
            else
            {
                m_points[0] = Reader.ReadVector3();

                var packedAgainst = new Vector3();
                packedAgainst.X = (m_currentPosition.X + m_points[0].X) * 0.5f;
                packedAgainst.Y = (m_currentPosition.Y + m_points[0].Y) * 0.5f;
                packedAgainst.Z = (m_currentPosition.Z + m_points[0].Z) * 0.5f;

                for (uint i = 1; i < pointCount; ++i)
                    m_points[i] = Reader.ReadUInt32().UnpackAgainst(ref packedAgainst);
            }
        }
예제 #35
0
        private static MovementInfo ReadMovementUpdateBlock(Packet packet, WowGuid guid, object index)
        {
            var moveInfo = new MovementInfo();

            packet.ResetBitReader();

            packet.ReadBit("NoBirthAnim", index);
            packet.ReadBit("EnablePortals", index);
            packet.ReadBit("PlayHoverAnim", index);
            packet.ReadBit("IsSuppressingGreetings", index);

            var hasMovementUpdate     = packet.ReadBit("HasMovementUpdate", index);
            var hasMovementTransport  = packet.ReadBit("HasMovementTransport", index);
            var hasStationaryPosition = packet.ReadBit("Stationary", index);
            var hasCombatVictim       = packet.ReadBit("HasCombatVictim", index);
            var hasServerTime         = packet.ReadBit("HasServerTime", index);
            var hasVehicleCreate      = packet.ReadBit("HasVehicleCreate", index);
            var hasAnimKitCreate      = packet.ReadBit("HasAnimKitCreate", index);
            var hasRotation           = packet.ReadBit("HasRotation", index);
            var hasAreaTrigger        = packet.ReadBit("HasAreaTrigger", index);
            var hasGameObject         = packet.ReadBit("HasGameObject", index);

            packet.ReadBit("ThisIsYou", index);
            packet.ReadBit("ReplaceActive", index);

            var sceneObjCreate        = packet.ReadBit("SceneObjCreate", index);
            var scenePendingInstances = packet.ReadBit("ScenePendingInstances", index);

            var pauseTimesCount = packet.ReadUInt32("PauseTimesCount", index);

            if (hasMovementUpdate) // 392
            {
                moveInfo = ReadMovementStatusData(packet, index);

                moveInfo.WalkSpeed = packet.ReadSingle("WalkSpeed", index) / 2.5f;
                moveInfo.RunSpeed  = packet.ReadSingle("RunSpeed", index) / 7.0f;
                packet.ReadSingle("RunBackSpeed", index);
                packet.ReadSingle("SwimSpeed", index);
                packet.ReadSingle("SwimBackSpeed", index);
                packet.ReadSingle("FlightSpeed", index);
                packet.ReadSingle("FlightBackSpeed", index);
                packet.ReadSingle("TurnRate", index);
                packet.ReadSingle("PitchRate", index);

                var movementForceCount = packet.ReadInt32("MovementForceCount", index);

                for (var i = 0; i < movementForceCount; ++i)
                {
                    packet.ReadPackedGuid128("Id", index);
                    packet.ReadVector3("Direction", index);
                    if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_1_2_19802)) // correct?
                    {
                        packet.ReadVector3("TransportPosition", index);
                    }
                    packet.ReadInt32("TransportID", index);
                    packet.ReadSingle("Magnitude", index);
                    packet.ReadByte("Type", index);
                }

                packet.ResetBitReader();

                moveInfo.HasSplineData = packet.ReadBit("HasMovementSpline", index);

                if (moveInfo.HasSplineData)
                {
                    packet.ReadInt32("ID", index);
                    packet.ReadVector3("Destination", index);

                    packet.ResetBitReader();

                    var hasMovementSplineMove = packet.ReadBit("MovementSplineMove", index);
                    if (hasMovementSplineMove)
                    {
                        packet.ResetBitReader();

                        packet.ReadBitsE <SplineFlag434>("SplineFlags", ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_0_20173) ? 28 : 25, index);
                        var face = packet.ReadBits("Face", 2, index);

                        var hasJumpGravity = packet.ReadBit("HasJumpGravity", index);
                        var hasSpecialTime = packet.ReadBit("HasSpecialTime", index);

                        packet.ReadBitsE <SplineMode>("Mode", 2, index);

                        var hasSplineFilterKey = packet.ReadBit("HasSplineFilterKey", index);

                        packet.ReadUInt32("Elapsed", index);
                        packet.ReadUInt32("Duration", index);

                        packet.ReadSingle("DurationModifier", index);
                        packet.ReadSingle("NextDurationModifier", index);

                        var pointsCount = packet.ReadUInt32("PointsCount", index);

                        if (face == 3) // FaceDirection
                        {
                            packet.ReadSingle("FaceDirection", index);
                        }

                        if (face == 2) // FaceGUID
                        {
                            packet.ReadPackedGuid128("FaceGUID", index);
                        }

                        if (face == 1) // FaceSpot
                        {
                            packet.ReadVector3("FaceSpot", index);
                        }

                        if (hasJumpGravity)
                        {
                            packet.ReadSingle("JumpGravity", index);
                        }

                        if (hasSpecialTime)
                        {
                            packet.ReadInt32("SpecialTime", index);
                        }

                        if (hasSplineFilterKey)
                        {
                            var filterKeysCount = packet.ReadUInt32("FilterKeysCount", index);
                            for (var i = 0; i < filterKeysCount; ++i)
                            {
                                packet.ReadSingle("In", index, i);
                                packet.ReadSingle("Out", index, i);
                            }

                            if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_0_20173))
                            {
                                packet.ResetBitReader();
                            }

                            packet.ReadBits("FilterFlags", 2, index);
                        }

                        for (var i = 0; i < pointsCount; ++i)
                        {
                            packet.ReadVector3("Points", index, i);
                        }
                    }
                }
            }

            if (hasMovementTransport) // 456
            {
                moveInfo.TransportGuid   = packet.ReadPackedGuid128("TransportGUID", index);
                moveInfo.TransportOffset = packet.ReadVector4("TransportPosition", index);
                var seat = packet.ReadByte("VehicleSeatIndex", index);
                packet.ReadUInt32("MoveTime", index);

                packet.ResetBitReader();

                var hasPrevMoveTime = packet.ReadBit("HasPrevMoveTime", index);
                var hasVehicleRecID = packet.ReadBit("HasVehicleRecID", index);

                if (hasPrevMoveTime)
                {
                    packet.ReadUInt32("PrevMoveTime", index);
                }

                if (hasVehicleRecID)
                {
                    packet.ReadInt32("VehicleRecID", index);
                }

                if (moveInfo.TransportGuid.HasEntry() && moveInfo.TransportGuid.GetHighType() == HighGuidType.Vehicle &&
                    guid.HasEntry() && guid.GetHighType() == HighGuidType.Creature)
                {
                    VehicleTemplateAccessory vehicleAccessory = new VehicleTemplateAccessory
                    {
                        Entry          = moveInfo.TransportGuid.GetEntry(),
                        AccessoryEntry = guid.GetEntry(),
                        SeatId         = seat
                    };
                    Storage.VehicleTemplateAccessories.Add(vehicleAccessory, packet.TimeSpan);
                }
            }

            if (hasStationaryPosition) // 480
            {
                moveInfo.Position    = packet.ReadVector3();
                moveInfo.Orientation = packet.ReadSingle();

                packet.AddValue("Stationary Position", moveInfo.Position, index);
                packet.AddValue("Stationary Orientation", moveInfo.Orientation, index);
            }

            if (hasCombatVictim) // 504
            {
                packet.ReadPackedGuid128("CombatVictim Guid", index);
            }

            if (hasServerTime) // 516
            {
                packet.ReadUInt32("ServerTime", index);
            }

            if (hasVehicleCreate) // 528
            {
                moveInfo.VehicleId = packet.ReadUInt32("RecID", index);
                packet.ReadSingle("InitialRawFacing", index);
            }

            if (hasAnimKitCreate) // 538
            {
                packet.ReadUInt16("AiID", index);
                packet.ReadUInt16("MovementID", index);
                packet.ReadUInt16("MeleeID", index);
            }

            if (hasRotation) // 552
            {
                moveInfo.Rotation = packet.ReadPackedQuaternion("GameObject Rotation", index);
            }

            if (hasAreaTrigger) // 772
            {
                // CliAreaTrigger
                packet.ReadInt32("ElapsedMs", index);

                packet.ReadVector3("RollPitchYaw1", index);

                packet.ResetBitReader();

                packet.ReadBit("HasAbsoluteOrientation", index);
                packet.ReadBit("HasDynamicShape", index);
                packet.ReadBit("HasAttached", index);
                packet.ReadBit("HasFaceMovementDir", index);
                packet.ReadBit("HasFollowsTerrain", index);

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_0_20173))
                {
                    packet.ReadBit("Unk bit WoD62x", index);
                }

                var hasTargetRollPitchYaw  = packet.ReadBit("HasTargetRollPitchYaw", index);
                var hasScaleCurveID        = packet.ReadBit("HasScaleCurveID", index);
                var hasMorphCurveID        = packet.ReadBit("HasMorphCurveID", index);
                var hasFacingCurveID       = packet.ReadBit("HasFacingCurveID", index);
                var hasMoveCurveID         = packet.ReadBit("HasMoveCurveID", index);
                var hasAreaTriggerSphere   = packet.ReadBit("HasAreaTriggerSphere", index);
                var hasAreaTriggerBox      = packet.ReadBit("HasAreaTriggerBox", index);
                var hasAreaTriggerPolygon  = packet.ReadBit("HasAreaTriggerPolygon", index);
                var hasAreaTriggerCylinder = packet.ReadBit("HasAreaTriggerCylinder", index);
                var hasAreaTriggerSpline   = packet.ReadBit("HasAreaTriggerSpline", index);

                if (hasTargetRollPitchYaw)
                {
                    packet.ReadVector3("TargetRollPitchYaw", index);
                }

                if (hasScaleCurveID)
                {
                    packet.ReadInt32("ScaleCurveID, index");
                }

                if (hasMorphCurveID)
                {
                    packet.ReadInt32("MorphCurveID", index);
                }

                if (hasFacingCurveID)
                {
                    packet.ReadInt32("FacingCurveID", index);
                }

                if (hasMoveCurveID)
                {
                    packet.ReadInt32("MoveCurveID", index);
                }

                if (hasAreaTriggerSphere)
                {
                    packet.ReadSingle("Radius", index);
                    packet.ReadSingle("RadiusTarget", index);
                }

                if (hasAreaTriggerBox)
                {
                    packet.ReadVector3("Extents", index);
                    packet.ReadVector3("ExtentsTarget", index);
                }

                if (hasAreaTriggerPolygon)
                {
                    var verticesCount       = packet.ReadInt32("VerticesCount", index);
                    var verticesTargetCount = packet.ReadInt32("VerticesTargetCount", index);
                    packet.ReadSingle("Height", index);
                    packet.ReadSingle("HeightTarget", index);

                    for (var i = 0; i < verticesCount; ++i)
                    {
                        packet.ReadVector2("Vertices", index, i);
                    }

                    for (var i = 0; i < verticesTargetCount; ++i)
                    {
                        packet.ReadVector2("VerticesTarget", index, i);
                    }
                }

                if (hasAreaTriggerCylinder)
                {
                    packet.ReadSingle("Radius", index);
                    packet.ReadSingle("RadiusTarget", index);
                    packet.ReadSingle("Height", index);
                    packet.ReadSingle("HeightTarget", index);
                    packet.ReadSingle("Float4", index);
                    packet.ReadSingle("Float5", index);
                }

                if (hasAreaTriggerSpline)
                {
                    AreaTriggerHandler.ReadAreaTriggerSpline(packet, index);
                }
            }

            if (hasGameObject) // 788
            {
                packet.ReadInt32("WorldEffectID", index);

                packet.ResetBitReader();

                var bit8 = packet.ReadBit("bit8", index);
                if (bit8)
                {
                    packet.ReadInt32("Int1", index);
                }
            }

            if (sceneObjCreate) // 1184
            {
                packet.ResetBitReader();

                var hasSceneLocalScriptData = packet.ReadBit("HasSceneLocalScriptData", index);
                var petBattleFullUpdate     = packet.ReadBit("HasPetBattleFullUpdate", index);

                if (hasSceneLocalScriptData)
                {
                    packet.ResetBitReader();
                    var dataLength = packet.ReadBits(7);
                    packet.ReadWoWString("Data", dataLength, index);
                }

                if (petBattleFullUpdate)
                {
                    BattlePetHandler.ReadPetBattleFullUpdate(packet, index);
                }
            }

            if (scenePendingInstances) // 1208
            {
                var sceneInstanceIDs = packet.ReadInt32("SceneInstanceIDsCount");

                for (var i = 0; i < sceneInstanceIDs; ++i)
                {
                    packet.ReadInt32("SceneInstanceIDs", index, i);
                }
            }

            for (var i = 0; i < pauseTimesCount; ++i)
            {
                packet.ReadInt32("PauseTimes", index, i);
            }

            return(moveInfo);
        }
예제 #36
0
 public override void Read(StreamHandler reader)
 {
     this.Unit = reader.ReadPackedGuid();
 }
예제 #37
0
        public static void HandleAuraUpdate(Packet packet)
        {
            var guid      = new byte[8];
            var powerGUID = new byte[8];

            packet.ReadBit(); // fake bit?

            packet.StartBitStream(guid, 6, 1, 0);

            var bits4 = (int)packet.ReadBits(24);

            packet.StartBitStream(guid, 2, 4);

            var hasPowerData = packet.ReadBit();

            var powerCount = 0u;

            if (hasPowerData)
            {
                packet.StartBitStream(powerGUID, 7, 0, 6);
                powerCount = packet.ReadBits(21);
                packet.StartBitStream(powerGUID, 3, 1, 2, 4, 5);
            }

            packet.StartBitStream(guid, 7, 3, 5);

            var hasAura        = new bool[bits4];
            var hasCasterGUID  = new bool[bits4];
            var hasDuration    = new bool[bits4];
            var hasMaxDuration = new bool[bits4];
            var effectCount    = new uint[bits4];
            var casterGUID     = new byte[bits4][];
            var bitsEC         = new uint[bits4];

            for (var i = 0; i < bits4; ++i)
            {
                hasAura[i] = packet.ReadBit();

                if (hasAura[i])
                {
                    hasMaxDuration[i] = packet.ReadBit();
                    effectCount[i]    = packet.ReadBits(22);
                    hasCasterGUID[i]  = packet.ReadBit();
                    if (hasCasterGUID[i])
                    {
                        casterGUID[i] = new byte[8];
                        packet.StartBitStream(casterGUID[i], 3, 0, 2, 6, 5, 7, 4, 1);
                    }

                    hasDuration[i] = packet.ReadBit();
                    bitsEC[i]      = packet.ReadBits(22);
                }
            }

            var auras = new List <Aura>();

            for (var i = 0; i < bits4; ++i)
            {
                if (hasAura[i])
                {
                    var aura = new Aura();

                    if (hasDuration[i])
                    {
                        aura.Duration = packet.ReadInt32("Duration", i);
                    }
                    else
                    {
                        aura.Duration = 0;
                    }

                    if (hasCasterGUID[i])
                    {
                        packet.ParseBitStream(casterGUID[i], 0, 7, 5, 6, 1, 3, 2, 4);
                        packet.WriteGuid("Caster GUID", casterGUID[i], i);
                        aura.CasterGuid = new WowGuid(BitConverter.ToUInt64(casterGUID[i], 0));
                    }
                    else
                    {
                        aura.CasterGuid = new WowGuid();
                    }

                    aura.AuraFlags = packet.ReadEnum <AuraFlagMoP>("Flags", TypeCode.Byte, i);

                    for (var j = 0; j < effectCount[i]; ++j)
                    {
                        packet.ReadSingle("Effect Value", i, j);
                    }

                    aura.SpellId = packet.ReadUInt32("Spell Id", i);

                    if (hasMaxDuration[i])
                    {
                        aura.MaxDuration = packet.ReadInt32("Max Duration", i);
                    }
                    else
                    {
                        aura.MaxDuration = 0;
                    }

                    for (var j = 0; j < bitsEC[i]; ++j)
                    {
                        packet.ReadSingle("FloatEA");
                    }

                    aura.Charges = packet.ReadByte("Charges", i);
                    packet.ReadInt32("Effect Mask", i);
                    aura.Level = packet.ReadUInt16("Caster Level", i);
                    auras.Add(aura);
                    packet.AddSniffData(StoreNameType.Spell, (int)aura.SpellId, "AURA_UPDATE");
                }

                packet.ReadByte("Slot", i);
            }

            if (hasPowerData)
            {
                packet.ReadXORByte(powerGUID, 7);
                packet.ReadXORByte(powerGUID, 4);
                packet.ReadXORByte(powerGUID, 5);
                packet.ReadXORByte(powerGUID, 1);
                packet.ReadXORByte(powerGUID, 6);
                for (var i = 0; i < powerCount; ++i)
                {
                    packet.ReadInt32("Value", i);
                    packet.ReadEnum <PowerType>("Power type", TypeCode.Int32, i); // Actually powertype for class
                }

                packet.ReadInt32("Attack power");
                packet.ReadInt32("Spell power");
                packet.ReadXORByte(powerGUID, 3);
                packet.ReadInt32("Current health");
                packet.ReadXORByte(powerGUID, 0);
                packet.ReadXORByte(powerGUID, 2);
                packet.WriteGuid("Power GUID", powerGUID);
            }

            packet.ParseBitStream(guid, 0, 4, 3, 7, 5, 6, 2, 1);

            packet.WriteGuid("Guid", guid);

            var GUID = new WowGuid(BitConverter.ToUInt64(guid, 0));

            if (Storage.Objects.ContainsKey(GUID))
            {
                var unit = Storage.Objects[GUID].Item1 as Unit;
                if (unit != null)
                {
                    // If this is the first packet that sends auras
                    // (hopefully at spawn time) add it to the "Auras" field,
                    // if not create another row of auras in AddedAuras
                    // (similar to ChangedUpdateFields)

                    if (unit.Auras == null)
                    {
                        unit.Auras = auras;
                    }
                    else
                    {
                        unit.AddedAuras.Add(auras);
                    }
                }
            }
        }