示例#1
0
 public NET_AccountInfo(Account account)
     : base(0x01, false)
 {
     ns.Write((int)account.AccountId);
     ns.Write((byte)account.AccessLevel);
     ns.Write((byte)account.Membership);
     ns.WriteDynamicASCII(account.Name);
     //ns.WriteDynamicASCII(account.Password);
     ns.Write((int)account.Session);
     ns.Write((long)account.LastEnteredTime);
     ns.WriteDynamicASCII(account.LastIp);
 }
示例#2
0
        /// <summary>
        /// Inserts Or Update Existing Account Into your current Login Server MySql DataBase.
        /// </summary>
        /// <param name="account">Your Account Which you want Insert(If Not Exist) Or Update(If Exist)</param>
        public static void InsertOrUpdate(Account account)
        {
            MySqlConnection con = new MySqlConnection(Settings.Default.DataBaseConnectionString);
            try
            {
                con.Open();
                MySqlCommand command = null;
                if (m_DbAccounts.Contains(account))
                {
                    command = new MySqlCommand("UPDATE `accounts` SET `id` = @id, `name` = @name, `mainaccess` = @mainaccess, `useraccess` = @useraccess, `last_ip` = @lastip, `password` = @password, `last_online` = @lastonline, `characters` = @characters WHERE `id` = @aid", con);
                }
                else
                {
                    command = new MySqlCommand("INSERT INTO `accounts`(id, name, mainaccess, useraccess, last_ip, password, last_online, characters) VALUES(@id, @name, @mainaccess, @useraccess, @lastip, @password, @lastonline, @characters)", con);
                }

                MySqlParameterCollection parameters = command.Parameters;
                parameters.Add("@id", MySqlDbType.Int32).Value = account.AccountId;
                parameters.Add("@name", MySqlDbType.String).Value = account.Name;
                parameters.Add("@mainaccess", MySqlDbType.Byte).Value = account.AccessLevel;
                parameters.Add("@useraccess", MySqlDbType.Byte).Value = account.Membership;
                parameters.Add("@lastip", MySqlDbType.String).Value = account.LastIp;
                parameters.Add("@password", MySqlDbType.String).Value = account.Password;
                parameters.Add("@lastonline", MySqlDbType.Int64).Value = account.LastEnteredTime;
                if (m_DbAccounts.Contains(account))
                    parameters.Add("@aid", MySqlDbType.Int32).Value = account.AccountId;

                parameters.Add("@characters", MySqlDbType.Int32).Value = account.Characters;

                command.ExecuteNonQuery();
                command = null;
            }
            finally
            {
                m_DbAccounts.Add(account);
                con.Close();
                con = null;
            }
        }
示例#3
0
        /// <summary>
        /// Fully Load Account Data From Current MySQL Db.
        /// </summary>
        public static void LoadAccountData()
        {
            m_DbAccounts = new List<Account>();
            MySqlConnection con = new MySqlConnection(Settings.Default.DataBaseConnectionString);
            try
            {
                con.Open();
                MySqlCommand command = new MySqlCommand("SELECT * FROM `accounts`", con);
                MySqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Account account = new Account();
                    account.AccessLevel = (byte)reader.GetInt32("mainaccess");
                    account.AccountId = reader.GetInt32("id");
                    account.Name = reader.GetString("name");
                    account.Password = reader.GetString("password");
                    account.LastEnteredTime = reader.GetInt64("last_online");
                    account.LastIp = reader.GetString("last_ip");
                    account.Membership = (byte)reader.GetInt32("useraccess");
                    account.Characters = reader.GetInt32("characters");
                    m_DbAccounts.Add(account);
                }
                command = null;
                reader = null;
            }
            finally
            {
                con.Close();
                con = null;
            }

            Logger.Trace("Loaded {0} Accounts", m_DbAccounts.Count);
        }
示例#4
0
        private static void Handle_SignIn(ArcheAgeConnection net, PacketReader reader)
        {
            reader.Offset += 10; //Static Data - 0A 00 00 00 07 00 00 00 00 00

            string m_RLogin = reader.ReadStringSafe(reader.ReadLEInt16()); //Reading Login

            Account n_Current = AccountHolder.AccountList.FirstOrDefault(n => n.Name == m_RLogin);
            if (n_Current == null)
            {
                //Make New Temporary
                if (Settings.Default.Account_AutoCreation)
                {
                    Account m_New = new Account();
                    m_New.AccountId = AccountHolder.AccountList.Count + 1;
                    m_New.LastEnteredTime = Utility.CurrentTimeMilliseconds();
                    m_New.AccessLevel = 0;
                    m_New.LastIp = net.ToString();
                    m_New.Membership = 0;
                    m_New.Name = m_RLogin;
                    net.CurrentAccount = m_New;
                    AccountHolder.AccountList.Add(m_New);
                }
                else
                    net.CurrentAccount = null;
            }
            else
            {
                net.CurrentAccount = n_Current;
            }
            net.SendAsync(new NP_AcceptLogin());
            net.SendAsync(new NP_AESKey());
        }