Example #1
0
        public void HandleAuthSession(ref IPacketReader packet, ref IWorldManager manager)
        {
            Authenticator.PacketCrypt.Initialised = true;

            packet.Position = 58;
            int addonsize        = packet.ReadInt32();
            int decompressedSize = packet.ReadInt32();

            byte[] addonData = this.GetAddonInfo(packet);

            // get account name
            packet.Position = 62 + addonsize;
            var    bitUnpack = new BitUnpacker(packet);
            int    nameLen   = bitUnpack.GetBits <int>(12);
            string name      = packet.ReadString(nameLen).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");
            var          bitPack = new BitPacker(writer);

            bitPack.Write(0); // IsInQueue
            bitPack.Write(1); // HasAccountData
            bitPack.Flush();
            writer.WriteUInt8(0);
            writer.WriteUInt8(4);
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            writer.WriteUInt8(4);
            writer.WriteUInt32(0);
            writer.WriteUInt8(0xC);
            manager.Send(writer);

            // create addoninfo packet
            var addonPacketInfo     = new PacketReader(addonData, false);
            var addonPacketResponse = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_ADDON_INFO], "SMSG_ADDON_INFO");

            this.WriteAddonInfo(addonPacketInfo, addonPacketResponse, decompressedSize);
            manager.Send(addonPacketResponse);

            // 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.WriteUInt32(0);
            }
            manager.Send(tutorial);
        }
Example #2
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);
            }
        }