Exemplo n.º 1
0
        public static void HandleCharacterCreate(PacketStream P, CityClient Client)
        {
            byte PacketLength = (byte)P.ReadByte();
            //Length of the unencrypted data, excluding the header (ID, length, unencrypted length).
            byte UnencryptedLength = (byte)P.ReadByte();

            //Accountname isn't encrypted in this packet.
            string AccountName = P.ReadString();

            PacketStream FetchKeyPack = new PacketStream(0x01, 00);
            FetchKeyPack.WriteString(AccountName);
            Client.Send(FetchKeyPack.ToArray());

            //TODO: Wait until the key has been received...
            AResetEvent.WaitOne();

            P.DecryptPacket(Client.EncKey, Client.CryptoService, UnencryptedLength);

            PacketStream OutPacket = new PacketStream(0x01, 0x00);
            OutPacket.WriteByte((byte)0x01);
            OutPacket.WriteByte((byte)AccountName.Length);
            OutPacket.Write(Encoding.ASCII.GetBytes(AccountName), 0, AccountName.Length);

            Logger.LogDebug("Received CharacterCreate!");

            Guid ID = new Guid();

            Sim Character = new Sim(ID.ToString());
            Character.Timestamp = P.ReadString();
            Character.Name = P.ReadString();
            Character.Sex = P.ReadString();

            //TODO: This should check if the character exists in the DB...
            Database.CreateCharacter(Character);
        }
        public static void HandleCharacterCreate(PacketStream P, CityClient Client)
        {
            byte PacketLength = (byte)P.ReadByte();
            //Length of the unencrypted data, excluding the header (ID, length, unencrypted length).
            byte UnencryptedLength = (byte)P.ReadByte();

            //Accountname isn't encrypted in this packet.
            string AccountName = P.ReadString();

            PacketStream FetchKeyPack = new PacketStream(0x01, 00);

            FetchKeyPack.WriteString(AccountName);
            Client.Send(FetchKeyPack.ToArray());

            //TODO: Wait until the key has been received...
            AResetEvent.WaitOne();

            P.DecryptPacket(Client.EncKey, Client.CryptoService, UnencryptedLength);

            PacketStream OutPacket = new PacketStream(0x01, 0x00);

            OutPacket.WriteByte((byte)0x01);
            OutPacket.WriteByte((byte)AccountName.Length);
            OutPacket.Write(Encoding.ASCII.GetBytes(AccountName), 0, AccountName.Length);

            Logger.LogDebug("Received CharacterCreate!");

            Guid ID = new Guid();

            Sim Character = new Sim(ID.ToString());

            Character.Timestamp = P.ReadString();
            Character.Name      = P.ReadString();
            Character.Sex       = P.ReadString();

            //TODO: This should check if the character exists in the DB...
            Database.CreateCharacter(Character);
        }