Ejemplo n.º 1
0
        public void HandleMovementStatus(ref IPacketReader packet, ref IWorldManager manager)
        {
            if (manager.Account.ActiveCharacter.IsTeleporting)
            {
                return;
            }

            uint opcode = packet.Opcode;
            long pos    = packet.Position;

            var   character = manager.Account.ActiveCharacter;
            ulong Flags     = packet.ReadUInt64();

            character.Location.Update(packet, true);

            packet.Position = pos;
            PacketWriter writer = new PacketWriter(opcode, Sandbox.Instance.Opcodes[opcode].ToString());

            writer.Write(packet.ReadToEnd());
            manager.Send(writer);
        }
Ejemplo n.º 2
0
        public void HandleAuthSession(ref IPacketReader packet, ref IWorldManager manager)
        {
            Authenticator.PacketCrypt.Initialised = true;
            Authenticator.PacketCrypt.DigestSize  = 40;

            packet.ReadUInt64();
            string name = packet.ReadString().ToUpper();

            Account account = new Account(name);

            account.Load <Character>();
            manager.Account = account;

            PacketWriter writer = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_AUTH_RESPONSE], "SMSG_AUTH_RESPONSE");

            writer.WriteUInt8(0x0C); // AUTH_OK
            writer.WriteUInt32(0);
            writer.WriteUInt8(0);
            writer.WriteUInt32(0);
            manager.Send(writer);
        }
Ejemplo n.º 3
0
        public void HandleMessageChat(ref IPacketReader packet, ref IWorldManager manager)
        {
            var character = manager.Account.ActiveCharacter;

            PacketWriter writer = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_MESSAGECHAT], "SMSG_MESSAGECHAT");

            writer.WriteUInt8((byte)packet.ReadInt32()); // System Message
            packet.ReadUInt32();
            writer.WriteUInt32(0);                       // Language: General
            writer.WriteUInt64(character.Guid);

            string message = packet.ReadString();

            writer.WriteString(message);
            writer.WriteUInt8(0);

            if (!CommandManager.InvokeHandler(message, manager))
            {
                manager.Send(writer);
            }
        }
Ejemplo n.º 4
0
        public void HandlePlayerLogin(ref IPacketReader packet, ref IWorldManager manager)
        {
            ulong     guid      = packet.ReadUInt64();
            Character character = (Character)manager.Account.SetActiveChar(guid, Sandbox.Instance.Build);

            character.DisplayId = character.GetDisplayId();

            // Verify World : REQUIRED
            PacketWriter verify = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_LOGIN_VERIFY_WORLD], "SMSG_LOGIN_VERIFY_WORLD");

            verify.WriteUInt32(character.Location.Map);
            verify.WriteFloat(character.Location.X);
            verify.WriteFloat(character.Location.Y);
            verify.WriteFloat(character.Location.Z);
            verify.WriteFloat(character.Location.O);
            manager.Send(verify);

            // Account Data Hash : REQUIRED
            PacketWriter accountdata = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_ACCOUNT_DATA_MD5], "SMSG_ACCOUNT_DATA_MD5");

            for (int i = 0; i < 31; i++)
            {
                accountdata.WriteInt32(0);
            }
            manager.Send(accountdata);

            // Tutorial Flags : REQUIRED
            PacketWriter tutorial = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_TUTORIAL_FLAGS], "SMSG_TUTORIAL_FLAGS");

            for (int i = 0; i < 8; i++)
            {
                tutorial.WriteInt32(-1);
            }
            manager.Send(tutorial);

            HandleQueryTime(ref packet, ref manager);

            manager.Send(character.BuildUpdate());

            // handle flying
            manager.Send(character.BuildFly(character.IsFlying));

            // Force timesync : REQUIRED
            PacketWriter timesyncreq = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_TIME_SYNC_REQ], "SMSG_TIME_SYNC_REQ");

            timesyncreq.Write(0);
            manager.Send(timesyncreq);
        }
Ejemplo n.º 5
0
        public void HandleTextEmote(ref IPacketReader packet, ref IWorldManager manager)
        {
            uint      emote     = packet.ReadUInt32();
            uint      emotenum  = packet.ReadUInt32();
            ulong     guid      = packet.ReadUInt64();
            uint      emoteId   = Emotes.Get((TextEmotes)emote);
            Character character = (Character)manager.Account.ActiveCharacter;

            PacketWriter pw = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_TEXT_EMOTE], "SMSG_TEXT_EMOTE");

            pw.Write(character.Guid);
            pw.Write(emote);
            pw.Write(emotenum);
            pw.WriteUInt32(0);
            pw.WriteUInt8(0);
            manager.Send(pw);

            switch ((TextEmotes)emote)
            {
            case TextEmotes.EMOTE_SIT:
                character.StandState = StandState.SITTING;
                manager.Send(character.BuildUpdate());
                return;

            case TextEmotes.EMOTE_STAND:
                character.StandState = StandState.STANDING;
                manager.Send(character.BuildUpdate());
                return;

            case TextEmotes.EMOTE_SLEEP:
                character.StandState = StandState.SLEEPING;
                manager.Send(character.BuildUpdate());
                return;

            case TextEmotes.EMOTE_KNEEL:
                character.StandState = StandState.KNEEL;
                manager.Send(character.BuildUpdate());
                return;
            }

            if (emoteId > 0)
            {
                pw = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_EMOTE], "SMSG_EMOTE");
                pw.WriteUInt32(emoteId);
                pw.WriteUInt64(character.Guid);
                manager.Send(pw);
            }
        }
Ejemplo n.º 6
0
        public void HandleNameCache(ref IPacketReader packet, ref IWorldManager manager)
        {
            ulong guid      = packet.ReadUInt64();
            var   character = manager.Account.GetCharacter(guid, Sandbox.Instance.Build);

            if (character == null)
            {
                return;
            }

            PacketWriter nameCache = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_NAME_QUERY_RESPONSE], "SMSG_NAME_QUERY_RESPONSE");

            nameCache.WritePackedGUID(guid);
            nameCache.WriteUInt8(0);
            nameCache.WriteString(character.Name);
            nameCache.WriteUInt8(0);
            nameCache.WriteUInt8(character.Race);
            nameCache.WriteUInt8(character.Gender);
            nameCache.WriteUInt8(character.Class);
            nameCache.WriteUInt8(0);
            manager.Send(nameCache);
        }
Ejemplo n.º 7
0
        public void HandleWorldTeleport(ref IPacketReader packet, ref IWorldManager manager)
        {
            packet.ReadUInt32();
            byte  zone = packet.ReadUInt8();
            float x    = packet.ReadFloat();
            float y    = packet.ReadFloat();
            float z    = packet.ReadFloat();
            float o    = packet.ReadFloat();

            PacketWriter movementStatus = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_MOVE_WORLDPORT_ACK], "SMSG_MOVE_WORLDPORT_ACK");

            movementStatus.WriteUInt64(0);
            movementStatus.WriteFloat(0);
            movementStatus.WriteFloat(0);
            movementStatus.WriteFloat(0);
            movementStatus.WriteFloat(0);
            movementStatus.WriteFloat(x);
            movementStatus.WriteFloat(y);
            movementStatus.WriteFloat(z);
            movementStatus.WriteFloat(o);
            movementStatus.WriteFloat(0);
            movementStatus.WriteUInt32(0);
            manager.Send(movementStatus);
        }
Ejemplo n.º 8
0
        public void HandleMessageChat(ref IPacketReader packet, ref IWorldManager manager)
        {
            var character = manager.Account.ActiveCharacter;

            var bitunpack = new BitUnpacker(packet);
            var language  = packet.ReadUInt32();
            var message   = packet.ReadString(bitunpack.GetBits <int>(9));

            PacketWriter writer = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_MESSAGECHAT], "SMSG_MESSAGECHAT");

            writer.WriteUInt8(1);  // System Message
            writer.WriteUInt32(0); // Language: General
            writer.WriteUInt64(character.Guid);
            writer.WriteUInt32(0);
            writer.WriteUInt64(0);
            writer.WriteInt32(message.Length + 1);
            writer.WriteString(message);
            writer.WriteUInt8(0);

            if (!CommandManager.InvokeHandler(message, manager))
            {
                manager.Send(writer);
            }
        }
Ejemplo n.º 9
0
        public void HandlePlayerLogin(ref IPacketReader packet, ref IWorldManager manager)
        {
            ulong     guid      = packet.ReadUInt64();
            Character character = (Character)manager.Account.SetActiveChar(guid, Sandbox.Instance.Build);

            character.DisplayId = character.GetDisplayId();

            // Verify World : REQUIRED
            PacketWriter verify = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_LOGIN_VERIFY_WORLD], "SMSG_LOGIN_VERIFY_WORLD");

            verify.WriteUInt32(character.Location.Map);
            verify.WriteFloat(character.Location.X);
            verify.WriteFloat(character.Location.Y);
            verify.WriteFloat(character.Location.Z);
            verify.WriteFloat(character.Location.O);
            manager.Send(verify);

            // Account Data Hash : REQUIRED
            PacketWriter accountdata = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_ACCOUNT_DATA_MD5], "SMSG_ACCOUNT_DATA_MD5");

            accountdata.WriteInt32((int)DateTimeOffset.UtcNow.ToUnixTimeSeconds());
            accountdata.WriteUInt8(1);
            accountdata.WriteUInt32((uint)AccountDataMask.ALL);
            for (int i = 0; i < 8; i++)
            {
                accountdata.WriteUInt32(0);
            }
            manager.Send(accountdata);

            // Tutorial Flags : REQUIRED
            PacketWriter tutorial = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_TUTORIAL_FLAGS], "SMSG_TUTORIAL_FLAGS");

            for (int i = 0; i < 8; i++)
            {
                tutorial.WriteInt32(-1);
            }
            manager.Send(tutorial);

            // send language spells so we can type commands
            PacketWriter spells = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_INITIAL_SPELLS], "SMSG_INITIAL_SPELLS");

            spells.WriteUInt8(0);
            spells.WriteUInt16(2); // spell count
            spells.WriteUInt32(CharacterData.COMMON_SPELL_ID);
            spells.WriteUInt16(0);
            spells.WriteUInt32(CharacterData.ORCISH_SPELL_ID);
            spells.WriteUInt16(0);
            spells.WriteUInt16(0); // cooldown count
            manager.Send(spells);

            HandleQueryTime(ref packet, ref manager);

            manager.Send(character.BuildUpdate());

            // handle flying
            manager.Send(character.BuildFly(character.IsFlying));

            // Force timesync : REQUIRED
            PacketWriter timesyncreq = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_TIME_SYNC_REQ], "SMSG_TIME_SYNC_REQ");

            timesyncreq.Write(0);
            manager.Send(timesyncreq);
        }
Ejemplo n.º 10
0
 public void HandleStandState(ref IPacketReader packet, ref IWorldManager manager)
 {
     manager.Account.ActiveCharacter.StandState = (StandState)packet.ReadUInt32();
     manager.Send(manager.Account.ActiveCharacter.BuildUpdate());
 }
Ejemplo n.º 11
0
        public static void Gps(IWorldManager manager, string[] args)
        {
            var character = manager.Account.ActiveCharacter;

            manager.Send(character.BuildMessage(character.Location.ToString()));
        }
Ejemplo n.º 12
0
        public void HandleCharEnum(ref IPacketReader packet, ref IWorldManager manager)
        {
            var account = manager.Account;
            var result  = account.Characters.Where(x => x.Build == Sandbox.Instance.Build);

            // Account Data Hash : REQUIRED
            PacketWriter accountdata = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_ACCOUNT_DATA_MD5], "SMSG_ACCOUNT_DATA_MD5");

            accountdata.WriteInt32((int)DateTimeOffset.UtcNow.ToUnixTimeSeconds());
            accountdata.WriteUInt8(1);
            accountdata.WriteUInt32((uint)AccountDataMask.GLOBAL);
            for (int i = 0; i < 3; i++)
            {
                accountdata.WriteUInt32(0);
            }
            manager.Send(accountdata);

            PacketWriter writer = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_CHAR_ENUM], "SMSG_CHAR_ENUM");

            writer.WriteUInt8((byte)result.Count());

            foreach (Character c in result)
            {
                writer.WriteUInt64(c.Guid);
                writer.WriteString(c.Name);

                writer.WriteUInt8(c.Race);
                writer.WriteUInt8(c.Class);
                writer.WriteUInt8(c.Gender);
                writer.WriteUInt8(c.Skin);
                writer.WriteUInt8(c.Face);
                writer.WriteUInt8(c.HairStyle);
                writer.WriteUInt8(c.HairColor);
                writer.WriteUInt8(c.FacialHair);
                writer.WriteUInt8((byte)c.Level);

                writer.WriteUInt32(c.Zone);
                writer.WriteUInt32(c.Location.Map);

                writer.WriteFloat(c.Location.X);
                writer.WriteFloat(c.Location.Y);
                writer.WriteFloat(c.Location.Z);

                writer.WriteUInt32(0);
                writer.WriteUInt32(0);
                writer.WriteUInt32(0);

                writer.WriteUInt8(0);
                writer.WriteUInt32(0);
                writer.WriteUInt32(0);
                writer.WriteUInt32(0);

                // Items
                int inventorySize = Authenticator.ClientBuild < 12122 ? 0x14 : 0x17;
                for (int j = 0; j < inventorySize; j++)
                {
                    writer.WriteUInt32(0);    // DisplayId
                    writer.WriteUInt8(0);     // InventoryType
                    writer.WriteUInt32(0);    // Enchant
                }
            }

            manager.Send(writer);
        }
Ejemplo n.º 13
0
        public void HandleTextEmote(ref IPacketReader packet, ref IWorldManager manager)
        {
            // I don't like to do this but since its the only packet change
            // it's really not worth creating a whole new plugin for it
            bool build_4211 = packet.Size == 22;

            uint emote = packet.ReadUInt32(), emotenum = 0;

            if (build_4211)
            {
                emotenum = packet.ReadUInt32();
            }

            ulong     guid      = packet.ReadUInt64();
            uint      emoteId   = Emotes.Get((TextEmotes)emote);
            Character character = (Character)manager.Account.ActiveCharacter;

            PacketWriter pw = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_TEXT_EMOTE], "SMSG_TEXT_EMOTE");

            pw.Write(character.Guid);
            pw.Write(emote);

            if (build_4211)
            {
                pw.WriteInt64(0);
            }
            else
            {
                pw.WriteInt32(1);
                pw.WriteUInt8(0);
            }
            manager.Send(pw);

            switch ((TextEmotes)emote)
            {
            case TextEmotes.EMOTE_SIT:
                character.StandState = StandState.SITTING;
                manager.Send(character.BuildUpdate());
                return;

            case TextEmotes.EMOTE_STAND:
                character.StandState = StandState.STANDING;
                manager.Send(character.BuildUpdate());
                return;

            case TextEmotes.EMOTE_SLEEP:
                character.StandState = StandState.SLEEPING;
                manager.Send(character.BuildUpdate());
                return;

            case TextEmotes.EMOTE_KNEEL:
                character.StandState = StandState.KNEEL;
                manager.Send(character.BuildUpdate());
                return;
            }

            if (emoteId > 0)
            {
                pw = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_EMOTE], "SMSG_EMOTE");
                pw.WriteUInt32(emoteId);
                pw.WriteUInt64(character.Guid);
                manager.Send(pw);
            }
        }
Ejemplo n.º 14
0
        public void HandleCharEnum(ref IPacketReader packet, ref IWorldManager manager)
        {
            var account = manager.Account;
            var result  = account.Characters.Where(x => x.Build == Sandbox.Instance.Build);

            PacketWriter writer    = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_CHAR_ENUM], "SMSG_CHAR_ENUM");
            BitPacker    bitPacker = new BitPacker(writer);

            bitPacker.Write(1);
            bitPacker.Write(0, 23);
            bitPacker.Write(result.Count(), 17);

            foreach (Character c in result)
            {
                bitPacker.Write(0, 3);
                bitPacker.Write(c.Guid & 0xFF);
                bitPacker.Write((c.Guid >> 8) & 0xFF);
                bitPacker.Write(0);
                bitPacker.Write(c.Name.Length, 7);
                bitPacker.Write(0, 4);
                bitPacker.Write((c.Guid >> 16) & 0xFF);
                bitPacker.Write((c.Guid >> 24) & 0xFF);
                bitPacker.Write(0, 5);
            }

            bitPacker.Flush();

            foreach (Character c in result)
            {
                writer.WriteUInt8(c.Gender);
                writer.WriteUInt8((byte)c.Level);

                // items
                for (int i = 0; i < 0x17; i++)
                {
                    writer.WriteUInt32(0);
                    writer.WriteUInt32(0);
                    writer.WriteUInt8(0);
                }

                writer.WriteGUIDByte(c.Guid, 0);
                writer.WriteFloat(c.Location.Z);
                writer.WriteUInt8(c.HairColor);
                writer.WriteUInt32(c.Zone);
                writer.WriteGUIDByte(c.Guid, 3);
                writer.WriteGUIDByte(c.Guid, 1);
                writer.WriteUInt32(0);
                writer.WriteFloat(c.Location.X);
                writer.WriteUInt8(0);
                writer.WriteUInt8(c.HairStyle);
                writer.WriteUInt32(c.Location.Map);
                writer.WriteUInt8(c.Face);
                writer.WriteUInt8(c.Skin);
                writer.Write(System.Text.Encoding.ASCII.GetBytes(c.Name));
                writer.WriteUInt8(c.FacialHair);
                writer.WriteUInt8(c.Class);
                writer.WriteUInt32(0);
                writer.WriteUInt8(c.Race);
                writer.WriteFloat(c.Location.Y);
                writer.WriteGUIDByte(c.Guid, 2);
                writer.WriteUInt32(0); // customise flags
                writer.WriteUInt32(0); // char flags
                writer.WriteUInt32(0);
            }

            manager.Send(writer);
        }