Exemple #1
0
        public UpdateData(StreamHandler Reader, bool LazyReading)
        {
            this.m_map = (Maps)Reader.ReadUInt16();

            this.Reader = Reader;

            m_readers = new Action[]
                {
                    ReadUpdates,
                };

            if (!LazyReading)
                EnsureRead();
        }
Exemple #2
0
        public UpdateData(StreamHandler Reader, bool LazyReading)
        {
            this.m_map = (Maps)Reader.ReadUInt16();

            this.Reader = Reader;

            m_readers = new Action[]
            {
                ReadUpdates,
            };

            if (!LazyReading)
            {
                EnsureRead();
            }
        }
Exemple #3
0
        public void Read(StreamHandler Reader)
        {
            Slot  = Reader.ReadByte();
            Spell = Reader.ReadUInt32();

            Caster = Unit;

            if (Spell != 0)
            {
                Flags   = (AuraFlags)Reader.ReadUInt16();
                Level   = Reader.ReadByte();
                Charges = Reader.ReadByte();

                if ((Flags & AuraFlags.NotCaster) == 0)
                {
                    Caster = Reader.ReadPackedGuid();
                }

                if ((Flags & AuraFlags.Duration) != 0)
                {
                    MaxDuration = Reader.ReadUInt32();
                    var currentDurationMs = Reader.ReadUInt32();

                    this.AppliedTime = (uint)Environment.TickCount - currentDurationMs;
                }

                if ((Flags & AuraFlags.BasePoints) != 0)
                {
                    for (int i = 0; i < MaxEffects; ++i)
                    {
                        if ((Flags & (AuraFlags)(1 << i)) != 0)
                        {
                            BasePoints[i] = Reader.ReadInt32();
                        }
                        else
                        {
                            BasePoints[i] = 0;
                        }
                    }
                }
                else
                {
                    Array.Clear(BasePoints, 0, MaxEffects);
                }
            }
        }
Exemple #4
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;
        }
Exemple #5
0
        public void Read(StreamHandler Reader)
        {
            Slot = Reader.ReadByte();
            Spell = Reader.ReadUInt32();

            Caster = Unit;

            if (Spell != 0)
            {
                Flags = (AuraFlags)Reader.ReadUInt16();
                Level = Reader.ReadByte();
                Charges = Reader.ReadByte();

                if ((Flags & AuraFlags.NotCaster) == 0)
                    Caster = Reader.ReadPackedGuid();

                if ((Flags & AuraFlags.Duration) != 0)
                {
                    MaxDuration = Reader.ReadUInt32();
                    var currentDurationMs = Reader.ReadUInt32();

                    this.AppliedTime = (uint)Environment.TickCount - currentDurationMs;
                }

                if ((Flags & AuraFlags.BasePoints) != 0)
                {
                    for (int i = 0; i < MaxEffects; ++i)
                    {
                        if ((Flags & (AuraFlags)(1 << i)) != 0)
                            BasePoints[i] = Reader.ReadInt32();
                        else
                            BasePoints[i] = 0;
                    }
                }
                else
                    Array.Clear(BasePoints, 0, MaxEffects);
            }
        }
        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;
        }
Exemple #7
0
 public static string ReadPascalString16(this StreamHandler sh)
 {
     return(PascalStringReader(sh, sh.ReadUInt16()));
 }