Example #1
0
        public bool GetBit()
        {
            if (Position == 8)
            {
                Value    = reader.ReadUInt8();
                Position = 0;
            }

            int returnValue = Value;

            Value = (byte)(2 * returnValue);
            ++Position;

            return(Convert.ToBoolean(returnValue >> 7));
        }
Example #2
0
        void HandleRealmData(byte[] data)
        {
            using (var reader = new PacketReader(data, false))
            {
                ClientLink cmd = (ClientLink)reader.ReadUInt8();

                switch (cmd)
                {
                    case ClientLink.CMD_AUTH_LOGON_CHALLENGE:
                    case ClientLink.CMD_AUTH_RECONNECT_CHALLENGE:
                        HandleAuthLogonChallenge(reader);
                        break;
                    case ClientLink.CMD_AUTH_LOGON_PROOF:
                    case ClientLink.CMD_AUTH_RECONNECT_PROOF:
                        HandleAuthLogonProof(reader);
                        break;
                    case ClientLink.CMD_REALM_LIST:
                        HandleRealmList(reader);
                        break;
                    default:
                        Log.Message(LogType.NORMAL, "Received unknown ClientLink: {0}", cmd);
                        break;
                }
            }
        }
Example #3
0
        public static void HandleCharDelete(ref PacketReader packet, ref WorldClass session)
        {
            bool[] guidMask = new bool[8];
            byte[] guidBytes = new byte[8];

            BitUnpack BitUnpack = new BitUnpack(packet);

            var unknown = BitUnpack.GetBit();

            guidMask[7] = BitUnpack.GetBit();
            guidMask[2] = BitUnpack.GetBit();
            guidMask[5] = BitUnpack.GetBit();
            guidMask[6] = BitUnpack.GetBit();
            guidMask[3] = BitUnpack.GetBit();
            guidMask[4] = BitUnpack.GetBit();
            guidMask[0] = BitUnpack.GetBit();
            guidMask[1] = BitUnpack.GetBit();

            if (guidMask[2]) guidBytes[2] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[6]) guidBytes[6] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[1]) guidBytes[1] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[4]) guidBytes[4] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[3]) guidBytes[3] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[0]) guidBytes[0] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[7]) guidBytes[7] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[5]) guidBytes[5] = (byte)(packet.ReadUInt8() ^ 1);

            var guid = BitConverter.ToUInt64(guidBytes, 0);

            PacketWriter deleteChar = new PacketWriter(ServerMessage.DeleteChar);
            deleteChar.WriteUInt8(0x47);
            session.Send(ref deleteChar);

            DB.Characters.Execute("DELETE FROM characters WHERE guid = ?", guid);
            DB.Characters.Execute("DELETE FROM character_spells WHERE guid = ?", guid);
            DB.Characters.Execute("DELETE FROM character_skills WHERE guid = ?", guid);
        }
Example #4
0
        public static void HandleMoveStopTurn(ref PacketReader packet, ref WorldClass session)
        {
            ObjectMovementValues movementValues = new ObjectMovementValues();
            BitUnpack BitUnpack = new BitUnpack(packet);

            bool[] guidMask = new bool[8];
            byte[] guidBytes = new byte[8];

            Vector4 vector = new Vector4()
            {
                X = packet.ReadFloat(),
                Z = packet.ReadFloat(),
                Y = packet.ReadFloat()
            };

            bool HasTime = !BitUnpack.GetBit();

            guidMask[5] = BitUnpack.GetBit();

            bool Unknown = BitUnpack.GetBit();

            movementValues.IsTransport = BitUnpack.GetBit();

            bool Unknown2 = BitUnpack.GetBit();

            guidMask[3] = BitUnpack.GetBit();

            bool HasSplineElevation = !BitUnpack.GetBit();

            guidMask[0] = BitUnpack.GetBit();

            bool HasPitch = !BitUnpack.GetBit();

            uint counter = BitUnpack.GetBits<uint>(24);

            guidMask[1] = BitUnpack.GetBit();
            guidMask[7] = BitUnpack.GetBit();

            movementValues.HasMovementFlags = !BitUnpack.GetBit();
            movementValues.IsAlive = !BitUnpack.GetBit();

            guidMask[2] = BitUnpack.GetBit();
            guidMask[6] = BitUnpack.GetBit();

            movementValues.HasRotation = !BitUnpack.GetBit();

            bool Unknown3 = BitUnpack.GetBit();

            movementValues.HasMovementFlags2 = !BitUnpack.GetBit();

            bool Unknown4 = BitUnpack.GetBit();

            guidMask[4] = BitUnpack.GetBit();

            /*if (movementValues.IsTransport)
            {

            }

            if (IsInterpolated)
            {

            }*/

            if (movementValues.HasMovementFlags)
                movementValues.MovementFlags = (MovementFlag)BitUnpack.GetBits<uint>(30);

            if (movementValues.HasMovementFlags2)
                movementValues.MovementFlags2 = (MovementFlag2)BitUnpack.GetBits<uint>(13);

            if (guidMask[6]) guidBytes[6] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[0]) guidBytes[0] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[5]) guidBytes[5] = (byte)(packet.ReadUInt8() ^ 1);

            for (int i = 0; i < counter; i++)
                packet.ReadUInt32();

            if (guidMask[1]) guidBytes[1] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[7]) guidBytes[7] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[3]) guidBytes[3] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[4]) guidBytes[4] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[2]) guidBytes[2] = (byte)(packet.ReadUInt8() ^ 1);

            /*if (movementValues.IsTransport)
            {

            }*/

            if (movementValues.HasRotation)
                vector.W = packet.ReadFloat();

            if (movementValues.IsAlive)
                movementValues.Time = packet.ReadUInt32();

            /*if (IsInterpolated)
            {

            }*/

            if (HasPitch)
                packet.ReadFloat();

            if (HasSplineElevation)
                packet.ReadFloat();

            if (HasTime)
                movementValues.Time = packet.ReadUInt32();

            var guid = BitConverter.ToUInt64(guidBytes, 0);
            HandleMoveUpdate(guid, movementValues, vector);
        }
Example #5
0
        public static void HandleActivePlayer(ref PacketReader packet, ref WorldClass session)
        {
            byte active = packet.ReadUInt8();    // Always 0

            Log.Message(LogType.DEBUG, "Player {0} (Guid: {1}) is active.", session.Character.Name, session.Character.Guid);
        }
Example #6
0
        public static void HandleViolenceLevel(ref PacketReader packet, ref WorldClass session)
        {
            byte violenceLevel = packet.ReadUInt8();

            Log.Message(LogType.DEBUG, "Violence level from account '{0} (Id: {1})' is {2}.", session.Account.Name, session.Account.Id, violenceLevel);
        }
Example #7
0
        public static void HandleDBQueryBulk(ref PacketReader packet, ref WorldClass session)
        {
            List<int> IdList = new List<int>();
            BitUnpack BitUnpack = new BitUnpack(packet);

            var type = (DBTypes)packet.ReadUInt32();

            var count = BitUnpack.GetBits<uint>(21);

            bool[][] Mask = new bool[count][];
            byte[][] Bytes = new byte[count][];

            for (int i = 0; i < count; i++)
            {
                Mask[i] = new bool[8];
                Bytes[i] = new byte[8];
            }

            for (int i = 0; i < count; i++)
            {
                Mask[i][7] = BitUnpack.GetBit();
                Mask[i][2] = BitUnpack.GetBit();
                Mask[i][3] = BitUnpack.GetBit();
                Mask[i][5] = BitUnpack.GetBit();
                Mask[i][4] = BitUnpack.GetBit();
                Mask[i][6] = BitUnpack.GetBit();
                Mask[i][0] = BitUnpack.GetBit();
                Mask[i][1] = BitUnpack.GetBit();
            }

            for (int i = 0; i < count; i++)
            {
                if (Mask[i][5])
                    Bytes[i][5] = (byte)(packet.ReadUInt8() ^ 1);

                IdList.Add(packet.ReadInt32());

                if (Mask[i][7])
                    Bytes[i][7] = (byte)(packet.ReadByte() ^ 1);

                if (Mask[i][3])
                    Bytes[i][3] = (byte)(packet.ReadByte() ^ 1);

                if (Mask[i][0])
                    Bytes[i][0] = (byte)(packet.ReadByte() ^ 1);

                if (Mask[i][1])
                    Bytes[i][1] = (byte)(packet.ReadByte() ^ 1);

                if (Mask[i][6])
                    Bytes[i][6] = (byte)(packet.ReadByte() ^ 1);

                if (Mask[i][2])
                    Bytes[i][2] = (byte)(packet.ReadByte() ^ 1);

                if (Mask[i][4])
                    Bytes[i][4] = (byte)(packet.ReadByte() ^ 1);
            }

            switch (type)
            {
                case DBTypes.BroadcastText:
                {
                    foreach (var id in IdList)
                        HandleBroadcastText(ref session, id);

                    break;
                }
                default:
                    break;
            }
        }
Example #8
0
        public static void HandleMoveFallLand(ref PacketReader packet, ref WorldClass session)
        {
            ObjectMovementValues movementValues = new ObjectMovementValues();
            BitUnpack BitUnpack = new BitUnpack(packet);

            bool[] guidMask = new bool[8];
            byte[] guidBytes = new byte[8];

            Vector4 vector = new Vector4()
            {
                Y = packet.ReadFloat(),
                X = packet.ReadFloat(),
                Z = packet.ReadFloat()
            };

            uint counter = BitUnpack.GetBits<uint>(24);

            guidMask[2] = BitUnpack.GetBit();

            bool HasTime = !BitUnpack.GetBit();

            bool HasSplineElevation = !BitUnpack.GetBit();

            guidMask[6] = BitUnpack.GetBit();
            guidMask[0] = BitUnpack.GetBit();

            movementValues.IsTransport = BitUnpack.GetBit();

            bool Unknown3 = BitUnpack.GetBit();
            bool Unknown = BitUnpack.GetBit();

            guidMask[4] = BitUnpack.GetBit();

            movementValues.HasMovementFlags2 = !BitUnpack.GetBit();

            bool HasPitch = !BitUnpack.GetBit();

            movementValues.HasRotation = !BitUnpack.GetBit();

            bool Unknown2 = BitUnpack.GetBit();

            guidMask[1] = BitUnpack.GetBit();

            movementValues.IsAlive = !BitUnpack.GetBit();
            movementValues.HasMovementFlags = !BitUnpack.GetBit();

            guidMask[5] = BitUnpack.GetBit();
            guidMask[7] = BitUnpack.GetBit();
            guidMask[3] = BitUnpack.GetBit();

            bool Unknown4 = BitUnpack.GetBit();

            /*if (movementValues.IsTransport)
            {
                vehicleGuidMask[4] = BitUnpack.GetBit();
                vehicleGuidMask[1] = BitUnpack.GetBit();
                bool vehicleUnknown2 = BitUnpack.GetBit();
                vehicleGuidMask[2] = BitUnpack.GetBit();
                vehicleGuidMask[3] = BitUnpack.GetBit();
                vehicleGuidMask[7] = BitUnpack.GetBit();
                vehicleGuidMask[0] = BitUnpack.GetBit();
                bool vehicleUnknown1 = BitUnpack.GetBit();
                vehicleGuidMask[5] = BitUnpack.GetBit();
                vehicleGuidMask[6] = BitUnpack.GetBit();
            }

            if (movementValues.IsInterpolated)
                    movementValues.IsInterpolated2 = BitUnpack.GetBit();*/

            if (movementValues.HasMovementFlags2)
                movementValues.MovementFlags2 = (MovementFlag2)BitUnpack.GetBits<uint>(13);

            if (movementValues.HasMovementFlags)
                movementValues.MovementFlags = (MovementFlag)BitUnpack.GetBits<uint>(30);

            if (guidMask[0]) guidBytes[0] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[2]) guidBytes[2] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[1]) guidBytes[1] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[4]) guidBytes[4] = (byte)(packet.ReadUInt8() ^ 1);

            for (int i = 0; i < counter; i++)
                packet.ReadUInt32();

            if (guidMask[6]) guidBytes[6] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[5]) guidBytes[5] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[7]) guidBytes[7] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[3]) guidBytes[3] = (byte)(packet.ReadUInt8() ^ 1);

            /*if (movementValues.IsTransport)
            {
                Vector4 vehiclevector = new Vector4();
                vehiclevector.X = packet.ReadFloat();
                if (vehicleGuidMask[0]) vehicleGuidBytes[0] = (byte)(packet.ReadUInt8() ^ 1);
                if ( vehicleUnknown1 ) uint _25 = packet.ReadUInt32();
                if (vehicleGuidMask[4]) vehicleGuidBytes[4] = (byte)(packet.ReadUInt8() ^ 1);
                if (vehicleGuidMask[5]) vehicleGuidBytes[5] = (byte)(packet.ReadUInt8() ^ 1);
                if (vehicleGuidMask[3]) vehicleGuidBytes[3] = (byte)(packet.ReadUInt8() ^ 1);
                byte _88 = packet.ReadUInt8();
                if (vehicleGuidMask[7]) vehicleGuidBytes[7] = (byte)(packet.ReadUInt8() ^ 1);
                vehiclevector.O = packet.ReadFloat();
                vehiclevector.Z = packet.ReadFloat();
                vehiclevector.Y = packet.ReadFloat();
                if (vehicleGuidMask[6]) vehicleGuidBytes[6] = (byte)(packet.ReadUInt8() ^ 1);
                uint _23 = packet.ReadUInt32();
                if (vehicleGuidMask[2]) vehicleGuidBytes[2] = (byte)(packet.ReadUInt8() ^ 1);
                if ( vehicleUnknown2 ) uint _27 = packet.ReadUInt32();
                if (vehicleGuidMask[1]) vehicleGuidBytes[1] = (byte)(packet.ReadUInt8() ^ 1);
            }*/
               // return

            if (HasPitch)
                packet.ReadFloat(); // float _28

            /*if (movementValues.IsInterpolated)
            {
                if (movementValues.IsInterpolated2)
                {
                    float _33 = packet.ReadFloat();
                    float _34 = packet.ReadFloat();
                    float _35 = packet.ReadFloat();
                }
                float _ 31 = packet.ReadFloat();
                uint _30 = packet.ReadUInt32();
            }*/

            if (movementValues.HasRotation)
                vector.O = packet.ReadFloat();

            if (HasTime)
                movementValues.Time = packet.ReadUInt32();

            if (HasSplineElevation)
                packet.ReadFloat();

            if (movementValues.IsAlive)
                movementValues.Time = packet.ReadUInt32();

            var guid = BitConverter.ToUInt64(guidBytes, 0);
            HandleMoveUpdate(guid, movementValues, vector);
        }
Example #9
0
        public static void HandleForceWalkSpeedChangeAck(ref PacketReader packet, ref WorldClass session)
        {
            ObjectMovementValues movementValues = new ObjectMovementValues();
            BitUnpack BitUnpack = new BitUnpack(packet);

            bool[] guidMask = new bool[8];
            byte[] guidBytes = new byte[8];

            Vector4 vector = new Vector4()
            {
                Y = packet.ReadFloat(),
                Z = packet.ReadFloat(),
                X = packet.ReadFloat()
            };

            uint zeroes = packet.ReadUInt32();
            float walkspeed = packet.ReadFloat();

            bool Unknown2 = BitUnpack.GetBit();

            guidMask[6] = BitUnpack.GetBit();

            bool HasPitch = !BitUnpack.GetBit();
            movementValues.IsTransport = BitUnpack.GetBit();
            bool Unknown3 = BitUnpack.GetBit();

            guidMask[1] = BitUnpack.GetBit();
            guidMask[2] = BitUnpack.GetBit();

            movementValues.IsAlive = !BitUnpack.GetBit();
            bool HasTime = !BitUnpack.GetBit();

            uint counter = BitUnpack.GetBits<uint>(24);

            guidMask[0] = BitUnpack.GetBit();

            movementValues.HasMovementFlags = !BitUnpack.GetBit();

            guidMask[5] = BitUnpack.GetBit();

            bool Unknown4 = BitUnpack.GetBit();
            bool HasSplineElevation = !BitUnpack.GetBit();

            guidMask[3] = BitUnpack.GetBit();

            movementValues.HasRotation = !BitUnpack.GetBit();
            movementValues.HasMovementFlags2 = !BitUnpack.GetBit();

            guidMask[7] = BitUnpack.GetBit();
            guidMask[4] = BitUnpack.GetBit();

            bool Unknown = BitUnpack.GetBit();

            /*if (movementValues.IsTransport)
            {
                vehicleGuidMask[2] = BitUnpack.GetBit();
                vehicleGuidMask[5] = BitUnpack.GetBit();
                vehicleGuidMask[4] = BitUnpack.GetBit();
                vehicleGuidMask[1] = BitUnpack.GetBit();
                vehicleGuidMask[0] = BitUnpack.GetBit();
                vehicleGuidMask[3] = BitUnpack.GetBit();
                vehicleGuidMask[7] = BitUnpack.GetBit();
                vehicleGuidMask[6] = BitUnpack.GetBit();
                bool vehicleUnknown1 = BitUnpack.GetBit();
                bool vehicleUnknown2 = BitUnpack.GetBit();
            }*/

            if (movementValues.HasMovementFlags)
                movementValues.MovementFlags = (MovementFlag)BitUnpack.GetBits<uint>(30);

            /*if (movementValues.IsInterpolated)
                    movementValues.IsInterpolated2 = BitUnpack.GetBit();*/

            if (movementValues.HasMovementFlags2)
                movementValues.MovementFlags2 = (MovementFlag2)BitUnpack.GetBits<uint>(13);

            if (guidMask[3]) guidBytes[3] = (byte)(packet.ReadUInt8() ^ 1);

            for (int i = 0; i < counter; i++)
                packet.ReadUInt32();

            if (guidMask[0]) guidBytes[0] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[4]) guidBytes[4] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[1]) guidBytes[1] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[2]) guidBytes[2] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[7]) guidBytes[7] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[6]) guidBytes[6] = (byte)(packet.ReadUInt8() ^ 1);
            if (guidMask[5]) guidBytes[5] = (byte)(packet.ReadUInt8() ^ 1);

            /*if (movementValues.IsTransport)
            {
                Vector4 vehiclevector = new Vector4();
                if (vehicleGuidMask[7]) vehicleGuidBytes[7] = (byte)(packet.ReadUInt8() ^ 1);
                if (vehicleGuidMask[5]) vehicleGuidBytes[5] = (byte)(packet.ReadUInt8() ^ 1);
                vehiclevector.Z = packet.ReadFloat();
                if (vehicleGuidMask[3]) vehicleGuidBytes[3] = (byte)(packet.ReadUInt8() ^ 1);
                byte _88 = packet.ReadUInt8(); 					  																			 // (BYTE)DATA[88]
                if (vehicleGuidMask[1]) vehicleGuidBytes[1] = (byte)(packet.ReadUInt8() ^ 1);
                if (vehicleGuidMask[0]) vehicleGuidBytes[0] = (byte)(packet.ReadUInt8() ^ 1);
                vehiclevector.X = packet.ReadFloat();
                if (vehicleGuidMask[4]) vehicleGuidBytes[4] = (byte)(packet.ReadUInt8() ^ 1);
                if ( vehicleUnknown1 ) packet.ReadUInt32();
                vehiclevector.Y = packet.ReadFloat();
                if (vehicleGuidMask[6]) vehicleGuidBytes[6] = (byte)(packet.ReadUInt8() ^ 1);
                uint _23 = packet.ReadUInt32();
                if (vehicleGuidMask[2]) vehicleGuidBytes[2] = (byte)(packet.ReadUInt8() ^ 1);
                if ( vehicleUnknown2 ) packet.ReadUInt32();
                vehiclevector.O = packet.ReadFloat();
            }

            if (movementValues.IsInterpolated)
            {
                float _31 = packet.ReadFloat();
                if (movementValues.IsInterpolated2)
                {
                    float _34 = packet.ReadFloat();
                    float _33 = packet.ReadFloat();
                    float _35 = packet.ReadFloat();
                }
                uint _30 = packet.ReadUInt32();
            }*/

            if (HasTime)
                movementValues.Time = packet.ReadUInt32();

            if (movementValues.IsAlive)
                movementValues.Time = packet.ReadUInt32();

            if (HasPitch)
                packet.ReadFloat();

            if (movementValues.HasRotation)
                vector.O = packet.ReadFloat();

            if (HasSplineElevation)
                packet.ReadFloat();

            var guid = BitConverter.ToUInt64(guidBytes, 0);
            HandleMoveUpdate(guid, movementValues, vector);

            Log.Message(LogType.DEBUG, "Character with Guid: {0}, AccountId: {1} changed walk speed to {2}", guid, session.Account.Id, walkspeed);
        }
Example #10
0
 public static void HandleActionbarToggles(ref PacketReader packet, ref WorldClass session)
 {
     byte actionBar = packet.ReadUInt8();
     Log.Message(LogType.DEBUG, "HandleActionbarToggles - Character (Guid: {0}) send Actionbar Slot: {1}.", session.Character.Guid, actionBar);
 }