Beispiel #1
0
        public void Read(PacketIn p)
        {
            GUID = p.ReadPackedGUID();

            Flags  = (MovementFlags)p.ReadUInt32();
            Flags2 = (MovementFlags2)p.ReadUInt16();
            Time   = p.ReadUInt32();

            PositionX = p.ReadSingle();
            PositionY = p.ReadSingle();
            PositionZ = p.ReadSingle();
            PositionO = p.ReadSingle();

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_ONTRANSPORT))
            {
                if (MovementDataTransport == null)
                {
                    MovementDataTransport = new MovementDataTransport();
                }

                MovementDataTransport.TransportGuid = p.ReadPackedGUID();
                MovementDataTransport.TransportX    = p.ReadSingle();
                MovementDataTransport.TransportY    = p.ReadSingle();
                MovementDataTransport.TransportZ    = p.ReadSingle();
                MovementDataTransport.TransportO    = p.ReadSingle();
                MovementDataTransport.TransportTime = p.ReadUInt32();
                MovementDataTransport.TransportSeat = p.ReadByte();

                if (Flags2.HasFlag(MovementFlags2.MOVEMENTFLAG2_INTERPOLATED_MOVEMENT))
                {
                    MovementDataTransport.TransportTime2 = p.ReadUInt32();
                }
            }

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_SWIMMING | MovementFlags.MOVEMENTFLAG_FLYING) ||
                Flags2.HasFlag(MovementFlags2.MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING))
            {
                Pitch = p.ReadSingle();
            }

            FallTime = p.ReadUInt32();

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_FALLING))
            {
                FallVerticalSpeed = p.ReadSingle();
                FallSine          = p.ReadSingle();
                FallCosine        = p.ReadSingle();
                FallLateralSpeed  = p.ReadSingle();
            }

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_SPLINE_ELEVATION))
            {
                SplineElevation = p.ReadSingle();
            }
        }
Beispiel #2
0
        public void Write(PacketOut p)
        {
            p.Write(GUID);
            p.Write((UInt32)Flags);
            p.Write((UInt16)Flags2);
            p.Write(Time);
            p.Write(PositionX);
            p.Write(PositionY);
            p.Write(PositionZ);
            p.Write(PositionO);

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_ONTRANSPORT))
            {
                if (MovementDataTransport == null)
                {
                    MovementDataTransport = new MovementDataTransport();
                }

                p.Write(MovementDataTransport.TransportGuid);
                p.Write(MovementDataTransport.TransportX);
                p.Write(MovementDataTransport.TransportY);
                p.Write(MovementDataTransport.TransportZ);
                p.Write(MovementDataTransport.TransportO);
                p.Write(MovementDataTransport.TransportTime);
                p.Write(MovementDataTransport.TransportSeat);

                if (Flags2.HasFlag(MovementFlags2.MOVEMENTFLAG2_INTERPOLATED_MOVEMENT))
                {
                    p.Write(MovementDataTransport.TransportTime2);
                }
            }

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_SWIMMING | MovementFlags.MOVEMENTFLAG_FLYING) ||
                Flags2.HasFlag(MovementFlags2.MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING))
            {
                p.Write(Pitch);
            }

            p.Write(FallTime);

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_FALLING))
            {
                p.Write(FallVerticalSpeed);
                p.Write(FallSine);
                p.Write(FallCosine);
                p.Write(FallLateralSpeed);
            }

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_SPLINE_ELEVATION))
            {
                p.Write(SplineElevation);
            }
        }
Beispiel #3
0
        protected override void WriteMovementUpdate(PrimitiveWriter packet, UpdateFieldFlags relation)
        {
            WriteMovementPacketInfo(packet);

            #region Speed Block

            packet.Write(WalkSpeed);
            packet.Write(RunSpeed);
            packet.Write(RunBackSpeed);
            packet.Write(SwimSpeed);
            packet.Write(SwimBackSpeed);
            packet.Write(FlightSpeed);
            packet.Write(FlightBackSpeed);
            packet.Write(TurnSpeed);
            packet.Write(PitchRate);

            #endregion

            #region Spline Info
            if (MovementFlags.HasFlag(MovementFlags.SplineEnabled))
            {
                // TODO: Write spline flags
                //var splineFlags = SplineFlags.None;
            }

            #endregion
        }
Beispiel #4
0
        protected override void Write(BinaryWriter writer)
        {
            writer.Write(ObjectId.GetPacked());
            writer.Write((int)MovementFlags);
            writer.Write(Time);
            writer.Write(Position.X);
            writer.Write(Position.Y);
            writer.Write(Position.Z);
            writer.Write(Orientation);

            if (MovementFlags.HasFlag(MovementFlags.OnTransport))
            {
                writer.Write(Transport.Id);
                writer.Write(Transport.Position.X);
                writer.Write(Transport.Position.Y);
                writer.Write(Transport.Position.Z);
                writer.Write(Transport.Orientation);
            }

            if (MovementFlags.HasFlag(MovementFlags.ModeSwimming))
            {
                writer.Write(Pitch.Value);
            }

            writer.Write(FallTime);

            if (MovementFlags.HasFlag(MovementFlags.ModeFalling))
            {
                writer.Write(Falling.Velocity);
                writer.Write(Falling.SinAngle);
                writer.Write(Falling.CosAngle);
                writer.Write(Falling.XYSpeed);
            }
        }
Beispiel #5
0
        public MovementInfo(InPacket packet)
        {
            Flags    = (MovementFlags)packet.ReadUInt32();
            Flags2   = (MovementFlags2)packet.ReadUInt16();
            Time     = packet.ReadUInt32();
            Position = packet.ReadVector3();
            O        = packet.ReadSingle();

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_ONTRANSPORT))
            {
                TransportGuid     = packet.ReadPackedGuid();
                TransportPosition = packet.ReadVector3();
                TransportO        = packet.ReadSingle();
                TransportTime     = packet.ReadUInt32();
                TransportSeat     = packet.ReadByte();
                if (Flags2.HasFlag(MovementFlags2.MOVEMENTFLAG2_INTERPOLATED_MOVEMENT))
                {
                    TransportTime2 = packet.ReadUInt32();
                }
            }

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_SWIMMING) || Flags.HasFlag(MovementFlags.MOVEMENTFLAG_FLYING) ||
                Flags2.HasFlag(MovementFlags2.MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING))
            {
                Pitch = packet.ReadSingle();
            }

            FallTime = packet.ReadUInt32();

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_FALLING))
            {
                JumpZSpeed   = packet.ReadSingle();
                JumpSinAngle = packet.ReadSingle();
                JumpCosAngle = packet.ReadSingle();
                JumpXYSpeed  = packet.ReadSingle();
            }

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_SPLINE_ELEVATION))
            {
                SplineElevation = packet.ReadSingle();
            }
        }
Beispiel #6
0
        protected override void Read(BinaryReader reader)
        {
            MovementFlags = (MovementFlags)reader.ReadInt32();
            Time          = reader.ReadInt32();
            Position      = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
            Orientation   = reader.ReadSingle();

            if (MovementFlags.HasFlag(MovementFlags.OnTransport))
            {
                Transport = new TransportInfo()
                {
                    Id          = new ObjectID(reader.ReadInt64()),
                    Position    = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()),
                    Orientation = reader.ReadSingle(),
                };
            }
            else
            {
                Transport = null;
            }

            if (MovementFlags.HasFlag(MovementFlags.ModeSwimming))
            {
                Pitch = reader.ReadSingle();
            }
            else
            {
                Pitch = null;
            }

            FallTime = reader.ReadInt32();

            if (MovementFlags.HasFlag(MovementFlags.ModeFalling))
            {
                Falling = new FallingInfo()
                {
                    Velocity = reader.ReadSingle(),
                    SinAngle = reader.ReadSingle(),
                    CosAngle = reader.ReadSingle(),
                    XYSpeed  = reader.ReadSingle(),
                };
            }
            else
            {
                Falling = null;
            }
        }
Beispiel #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="packet">The packet to read the info from</param>
        /// <param name="chr">The active character in the client that send the movement packet</param>
        /// <param name="mover">The unit we want this movement info to affect</param>
        /// <param name="clientTime">Used to return the read client time</param>
        /// <returns>A boolean value used to determine broadcasting of this movement info to other clients</returns>
        public static bool ReadMovementInfo(RealmPacketIn packet, Character chr, Unit mover, out uint clientTime)
        {
            MovementFlags  movementFlags  = (MovementFlags)packet.ReadInt32();
            MovementFlags2 movementFlags2 = (MovementFlags2)packet.ReadInt16();

            clientTime = packet.ReadUInt32();
            Vector3 pt          = packet.ReadVector3();
            float   orientation = packet.ReadFloat();

            if (movementFlags.HasFlag((Enum)MovementFlags.OnTransport))
            {
                EntityId       id            = packet.ReadPackedEntityId();
                Vector3        vector3       = packet.ReadVector3();
                float          num1          = packet.ReadFloat();
                uint           num2          = packet.ReadUInt32();
                int            num3          = (int)packet.ReadByte();
                ITransportInfo transportInfo = mover.Map.GetObject(id) as ITransportInfo;
                bool           flag          = transportInfo is Vehicle;
                if (transportInfo == null)
                {
                    if (mover.Transport != null)
                    {
                        mover.Transport.RemovePassenger(mover);
                    }
                    return(false);
                }

                if (mover.TransportInfo != transportInfo)
                {
                    if (flag)
                    {
                        return(false);
                    }
                    ((Transport)transportInfo).AddPassenger(mover);
                }

                if (!flag)
                {
                    mover.TransportPosition    = vector3;
                    mover.TransportOrientation = num1;
                    mover.TransportTime        = num2;
                }
            }
            else if (mover.Transport != null)
            {
                mover.Transport.RemovePassenger(mover);
            }

            if (movementFlags.HasFlag((Enum)(MovementFlags.Swimming | MovementFlags.Flying)) ||
                movementFlags2.HasFlag((Enum)MovementFlags2.AlwaysAllowPitching))
            {
                if (movementFlags.HasFlag((Enum)MovementFlags.Flying) && !chr.CanFly)
                {
                    return(false);
                }
                float moveAngle = packet.ReadFloat();
                if (chr == mover)
                {
                    chr.MovePitch(moveAngle);
                }
            }

            int num4 = (int)packet.ReadUInt32();

            if (movementFlags.HasFlag((Enum)MovementFlags.Falling))
            {
                double num1 = (double)packet.ReadFloat();
                double num2 = (double)packet.ReadFloat();
                double num3 = (double)packet.ReadFloat();
                double num5 = (double)packet.ReadFloat();
            }

            if (packet.PacketId.RawId == 201U && chr == mover)
            {
                chr.OnFalling();
            }
            if (movementFlags.HasFlag((Enum)MovementFlags.Swimming) && chr == mover)
            {
                chr.OnSwim();
            }
            else if (chr.IsSwimming && chr == mover)
            {
                chr.OnStopSwimming();
            }
            if (movementFlags.HasFlag((Enum)MovementFlags.SplineElevation))
            {
                double num6 = (double)packet.ReadFloat();
            }

            bool flag1 = pt == mover.Position;

            if (!flag1 && mover.IsInWorld && !mover.SetPosition(pt, orientation))
            {
                return(false);
            }
            if (flag1)
            {
                mover.Orientation = orientation;
            }
            else
            {
                mover.OnMove();
            }
            mover.MovementFlags  = movementFlags;
            mover.MovementFlags2 = movementFlags2;
            if (flag1)
            {
                mover.Orientation = orientation;
            }
            else if (!mover.CanMove)
            {
                return(false);
            }
            return(true);
        }
Beispiel #8
0
        public MovementInfo(InPacket packet)
        {
            Flags = (MovementFlags)packet.ReadUInt32();
            Flags2 = (MovementFlags2)packet.ReadUInt16();
            Time = packet.ReadUInt32();
            Position = packet.ReadVector3();
            O = packet.ReadSingle();

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_ONTRANSPORT))
            {
                TransportGuid = packet.ReadPackedGuid();
                TransportPosition = packet.ReadVector3();
                TransportO = packet.ReadSingle();
                TransportTime = packet.ReadUInt32();
                TransportSeat = packet.ReadByte();
                if (Flags2.HasFlag(MovementFlags2.MOVEMENTFLAG2_INTERPOLATED_MOVEMENT))
                    TransportTime2 = packet.ReadUInt32();
            }

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_SWIMMING) || Flags.HasFlag(MovementFlags.MOVEMENTFLAG_FLYING)
                || Flags2.HasFlag(MovementFlags2.MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING))
                Pitch = packet.ReadSingle();

            FallTime = packet.ReadUInt32();

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_FALLING))
            {
                JumpZSpeed = packet.ReadSingle();
                JumpSinAngle = packet.ReadSingle();
                JumpCosAngle = packet.ReadSingle();
                JumpXYSpeed = packet.ReadSingle();
            }

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_SPLINE_ELEVATION))
                SplineElevation = packet.ReadSingle();
        }
Beispiel #9
0
        public void Dump(string indent, TextWriter writer)
        {
            writer.WriteLine(indent + "UpdateFlags: " + UpdateFlags);
            if (EntityId != EntityId.Zero)
            {
                writer.WriteLine(indent + "EntityId: " + EntityId);
            }
            if (MovementFlags != MovementFlags.None)
            {
                writer.WriteLine(indent + "MovementFlags: " + MovementFlags);
            }
            if (MovementFlags2 != MovementFlags2.None)
            {
                writer.WriteLine(indent + "MovementFlags2: " + MovementFlags2);
            }

            writer.WriteLine(indent + "Timestamp: " + Timestamp);
            writer.WriteLine(indent + "Position: " + Position);

            if (MovementFlags.HasAnyFlag(MovementFlags.OnTransport) ||
                UpdateFlags.HasAnyFlag(UpdateFlags.StationaryObjectOnTransport))
            {
                writer.WriteLine(indent + "Transporter: " + TransporterId);
                writer.WriteLine(indent + "TransporterPosition: " + TransporterPosition);
                writer.WriteLine(indent + "TransporterTime: " + TransporterTime);
                writer.WriteLine(indent + "TransportSeatPosition: " + TransportSeatPosition);
            }

            if (MovementFlags.HasAnyFlag(MovementFlags.Swimming | MovementFlags.Flying) ||      // don't use HasFlag!
                MovementFlags2.HasFlag(MovementFlags2.AlwaysAllowPitching))
            {
                writer.WriteLine(indent + "Pitch: " + Pitch);
            }

            if (FallTime != 0)
            {
                writer.WriteLine(indent + "FallTime: " + FallTime);
            }

            if (MovementFlags.HasAnyFlag(MovementFlags.Falling))
            {
                writer.WriteLine(indent + "FallFloat1: " + FallFloat1);
                writer.WriteLine(indent + "FallFloat2: " + FallFloat2);
                writer.WriteLine(indent + "FallFloat3: " + FallFloat3);
                writer.WriteLine(indent + "FallFloat4: " + FallFloat4);
            }

            if (MovementFlags.HasFlag(MovementFlags.SplineElevation))
            {
                writer.WriteLine(indent + "Spline0x4000000: " + Spline0x4000000);
            }

            if (Speeds.Run != 0)
            {
                writer.WriteLine(indent + "Speeds: " + Speeds);
            }

            if (MovementFlags.HasFlag(MovementFlags.SplineEnabled))
            {
                DumpSpline(indent, writer);
            }

            if (UpdateFlags.HasFlag(UpdateFlags.Flag_0x8))
            {
                writer.WriteLine(indent + "Flag_0x8: " + Flag0x8);
            }

            if (UpdateFlags.HasFlag(UpdateFlags.Flag_0x10))
            {
                writer.WriteLine(indent + "Flag0x10: " + Flag0x10);
            }

            if (UpdateFlags.HasFlag(UpdateFlags.AttackingTarget))
            {
                writer.WriteLine(indent + "AttackingTarget: " + AttackingTarget);
            }

            if (UpdateFlags.HasFlag(UpdateFlags.Transport))
            {
                writer.WriteLine(indent + "TransportTimeSync: " + TransportTimeSync);
            }

            if (UpdateFlags.HasFlag(UpdateFlags.Vehicle))
            {
                writer.WriteLine(indent + "VehicleId: " + VehicleId);
                writer.WriteLine(indent + "VehicleAimAdjustment: " + VehicleAimAdjustment);
            }

            if (UpdateFlags.HasFlag(UpdateFlags.HasRotation))
            {
                writer.WriteLine(indent + "Flag_0x200_Rotation: " + Flag0x200);
            }
        }
Beispiel #10
0
        public void Read(PacketIn p)
        {
            GUID = p.ReadPackedGUID();

            Flags = (MovementFlags)p.ReadUInt32();
            Flags2 = (MovementFlags2)p.ReadUInt16();
            Time = p.ReadUInt32();

            PositionX = p.ReadSingle();
            PositionY = p.ReadSingle();
            PositionZ = p.ReadSingle();
            PositionO = p.ReadSingle();

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_ONTRANSPORT))
            {
                if (MovementDataTransport == null)
                    MovementDataTransport = new MovementDataTransport();

                MovementDataTransport.TransportGuid = p.ReadPackedGUID();
                MovementDataTransport.TransportX = p.ReadSingle();
                MovementDataTransport.TransportY = p.ReadSingle();
                MovementDataTransport.TransportZ = p.ReadSingle();
                MovementDataTransport.TransportO = p.ReadSingle();
                MovementDataTransport.TransportTime = p.ReadUInt32();
                MovementDataTransport.TransportSeat = p.ReadByte();

                if (Flags2.HasFlag(MovementFlags2.MOVEMENTFLAG2_INTERPOLATED_MOVEMENT))
                    MovementDataTransport.TransportTime2 = p.ReadUInt32();
            }

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_SWIMMING | MovementFlags.MOVEMENTFLAG_FLYING) ||
                Flags2.HasFlag(MovementFlags2.MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING))
                Pitch = p.ReadSingle();

            FallTime = p.ReadUInt32();

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_FALLING))
            {
                FallVerticalSpeed = p.ReadSingle();
                FallSine = p.ReadSingle();
                FallCosine = p.ReadSingle();
                FallLateralSpeed = p.ReadSingle();
            }

            if (Flags.HasFlag(MovementFlags.MOVEMENTFLAG_SPLINE_ELEVATION))
                SplineElevation = p.ReadSingle();
        }