Exemplo n.º 1
0
        public static void CreateCharacter(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            var style = packet.ReadInt();

            packet.Skip(2);
            var slot       = packet.ReadByte();
            var nameLength = packet.ReadByte();
            var name       = packet.ReadString(nameLength);

            var _class = (byte)(style & 0xFF ^ 8);

            style >>= 8;
            var colour = (byte)((style & 0xFF) >> 5);
            var face   = (byte)(style & 0x1F);

            style >>= 8;
            var hair = (byte)((style & 0xFF) >> 1);

            style >>= 8;
            var gender = (style != 0);

            var server     = (int)client.Metadata["server"];
            var syncServer = client.Metadata["syncServer"] as SyncReceiver;
            var slotorder  = (int)client.Metadata["slotorder"];

            var slots = new int[8]
            {
                slotorder / 0x10000000 % 0x10,
                slotorder / 0x1000000 % 0x10,
                slotorder / 0x100000 % 0x10,
                slotorder / 0x10000 % 0x10,
                slotorder / 0x1000 % 0x10,
                slotorder / 0x100 % 0x10,
                slotorder / 0x10 % 0x10,
                slotorder % 0x10,
            };

            for (int i = 0; i < 8; i++)
            {
                if (slots[i] == slot)
                {
                    slot = (byte)i;
                    break;
                }
            }

            slot = (byte)slots[slot];

            var status = CharacterManagement.CreateCharacter(syncServer, server, client.AccountID, slot, name, _class, gender, face, hair, colour);

            builder.New(0x86);
            {
                builder += client.AccountID * 8 + slot;
                builder += (byte)status;
            }

            client.Send(builder, "NewMyChartr");
        }