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);
            }
        }
Example #3
0
        public void HandlePlayerLogin(ref IPacketReader packet, ref IWorldManager manager)
        {
            BitUnpacker unpacker = new BitUnpacker(packet);

            byte[] mask  = { 5, 6, 2, 4, 0, 3, 1, 7 };
            byte[] bytes = { 0, 4, 5, 6, 2, 3, 7, 1 };
            ulong  guid  = unpacker.ReadPackedGuid(mask, bytes);

            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);

            // 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(3); // spell count
            spells.WriteUInt32(CharacterData.COMMON_SPELL_ID);
            spells.WriteUInt16(0);
            spells.WriteUInt32(CharacterData.ORCISH_SPELL_ID);
            spells.WriteUInt16(0);
            spells.WriteUInt32(CharacterData.PANDAREN_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);
        }