Esempio n. 1
0
        public static async Task OnCharacterCreate(WorldClient client, byte[] data)
        {
            var character = CMSG_CHAR_CREATE.RequestAsCharacter(data);

            client.User.Characters.Add(character);

            await client.SendPacket(SMSG_CHAR_CREATE.Success());
        }
Esempio n. 2
0
        private void CHARACTER_CREATE(CMSG_INTERNAL_CHARACTERCREATE cpkt)
        {
            //Argument with creation data given by the authentication server
            CharCreationArgument argument = new CharCreationArgument();

            argument.CharName    = cpkt.Name;
            argument.WeaponName  = cpkt.WeaponName;
            argument.WeaponAffix = cpkt.WeaponAffix;
            argument.FaceDetails = cpkt.FaceDetails;
            argument.UserId      = cpkt.UserId;

            //Only normans are supported by this time
            Character character = null;

            Saga.Factory.CharacterConfiguration.IDefaultCharacterSettings settings =
                Singleton.CharacterConfiguration.Normans;

            try
            {
                //CHECK IF NAME ALREADY EXISTS
                if (Singleton.Database.VerifyNameExists(cpkt.Name.ToUpperInvariant()))
                {
                    SMSG_CHAR_CREATE spkt = new SMSG_CHAR_CREATE();
                    spkt.Result    = 0xA;
                    spkt.SessionId = cpkt.SessionId;
                    this.Send((byte[])spkt);
                }
                //CREATE CHARACTER AND IF FAILED SENT ERROR MESSAGE
                else if (!settings.create(out character, argument))
                {
                    SMSG_CHAR_CREATE spkt = new SMSG_CHAR_CREATE();
                    spkt.Result    = 0x4;
                    spkt.SessionId = cpkt.SessionId;
                    this.Send((byte[])spkt);
                }
                //SUCCESSFULL CREATION
                else
                {
                    SMSG_CHAR_CREATE spkt = new SMSG_CHAR_CREATE();
                    spkt.CharatcerId = character.ModelId;
                    spkt.SessionId   = cpkt.SessionId;
                    this.Send((byte[])spkt);
                }
            }
            //DATABASE ERROR
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.ReadKey();
                SMSG_CHAR_CREATE spkt = new SMSG_CHAR_CREATE();
                spkt.Result    = 0x6;
                spkt.SessionId = cpkt.SessionId;
                this.Send((byte[])spkt);
            }
        }