Пример #1
0
        /// <summary>
        /// Handles the request to create a new account.
        /// </summary>
        /// <param name="conn">Connection that the request was made on.</param>
        /// <param name="name">The name of the character to create.</param>
        public void CreateAccountCharacter(IIPSocket conn, string name)
        {
            if (!RequireServerRunning())
            {
                return;
            }

            ThreadAsserts.IsMainThread();

            // Get the account
            var account = conn.Tag as IUserAccount;

            if (account == null)
            {
                return;
            }

            // Try to create the character
            string errorMessage;
            var    success = UserAccountManager.TryAddCharacter(account.Name, name, out errorMessage);

            // Send the result to the client (which we have to do both when successful and failed)
            using (var pw = ServerPacket.CreateAccountCharacter(success, errorMessage))
            {
                conn.Send(pw, ServerMessageType.System);
            }

            // If we successfully created the character, reload and resync the character listing
            if (success)
            {
                account.LoadCharacterIDs();
                account.SendAccountCharacterInfos();
            }
        }