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