Ejemplo n.º 1
1
        public Account LoadAccount(string username)
        {
            string SqlQuery = "SELECT * FROM `accounts` WHERE `username` = ?username";
                MySqlCommand SqlCommand = new MySqlCommand(SqlQuery, AccountDAOConnection);
                SqlCommand.Parameters.AddWithValue("?username", username);
                MySqlDataReader AccountReader = SqlCommand.ExecuteReader();

                Account acc = new Account();
                if (AccountReader.HasRows)
                {
                    while (AccountReader.Read())
                    {
                        acc.AccountId = AccountReader.GetInt32(0);
                        acc.Username = AccountReader.GetString(1);
                        acc.Password = AccountReader.GetString(2);
                        acc.Email = AccountReader.GetString(3);
                        acc.AccessLevel = (byte)AccountReader.GetInt32(4);
                        acc.Membership = (byte)AccountReader.GetInt32(5);
                        acc.isGM = AccountReader.GetBoolean(6);
                        acc.LastOnlineUtc = AccountReader.GetInt64(7);
                        acc.Coins = (int)AccountReader.GetInt32(8);
                        acc.Ip = AccountReader.GetString(9);
                        acc.UiSettings = ByteUtilities.StringToByteArray(AccountReader.GetString(10));

                    }
                }
                AccountReader.Close();
                return (acc.Username == "") ? null : acc;
        }
Ejemplo n.º 2
0
 //I think, that account is verified at GS side
 public static Account GetAccount(string name)
 {
     Account account = null;
     MySqlCommand myCommand = new MySqlCommand("SELECT * FROM `game_accounts` WHERE name = '" + name + "'");
     try
     {
         MySqlDataReader dataReader = myCommand.ExecuteReader();
         dataReader.Read();
         //creating new account structure
         account = new Account();
         /*
         account.SetAccountId(dataReader.GetInt32(0));
         account.SetAccountName(dataReader.GetString(1));
         account.SetAccountPassword(dataReader.GetString(2));
         account.SetIsActive(dataReader.GetInt32(3));
         account.SetAdminLevel(dataReader.GetInt32(4));
         account.SetMemberLevel(dataReader.GetInt32(5));
         account.SetLastIp(dataReader.GetString(6));
         account.SetLastServer(dataReader.GetInt32(7));
         account.SetSecureIp(dataReader.GetString(8));
          */
     }
     catch (Exception e)
     {
         Log.ErrorException("MySQL ERROR!!! Can't initialize account",  e);
     }
     return account;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Get User Account info by name
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Account GetAccountByName(string name)
        {
            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                connection.Open();
                Account account = new Account();

                using (MySqlCommand command = connection.CreateCommand())
                {
                    command.CommandText = "AUTH_ACCOUNT_BYNAME_GET";
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@in_name", name);
                    var reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            account.id = reader.GetInt32(0);
                            account.name = reader.GetString(1);
                            account.passwd = reader.GetString(2);
                            account.isgm = reader.GetInt32(3);
                            account.activated = reader.GetInt32(4);
                            account.membership = reader.GetInt32(5);
                            account.last_ip = reader.GetString(6);
                            account.cash = reader.GetInt32(7);
                        }
                    }
                    reader.Close();
                }
                connection.Close();

                return account;
            }
        }
Ejemplo n.º 4
0
        public Account LoadAccount(string username)
        {
            string SQL = "SELECT * FROM `accounts` WHERE `name` = ?username";
            MySqlCommand cmd = new MySqlCommand(SQL, AccountDAOConnection);
            cmd.Parameters.AddWithValue("?username", username);
            MySqlDataReader AccountReader = cmd.ExecuteReader();

            Account acc = new Account();
            if (AccountReader.HasRows)
            {
                while (AccountReader.Read())
                {
                    acc.AccountId = AccountReader.GetInt32(0);
                    acc.Name = AccountReader.GetString(1);
                    acc.Password = AccountReader.GetString(2);
                    acc.AccessLevel = (byte)AccountReader.GetInt32(3);
                    acc.Membership = (byte)AccountReader.GetInt32(4);
                    acc.LastOnlineUtc = AccountReader.GetInt64(5);
                }
            }

            AccountReader.Close();

            return (acc.Name == "") ? null : acc;
        }
Ejemplo n.º 5
0
        public Account LoadAccount(string accountname)
        {
            string SqlQuery = "SELECT * FROM `accounts` WHERE `accountname` = ?accountname";
            MySqlCommand SqlCommand = new MySqlCommand(SqlQuery, AccountDAOConnection);
            SqlCommand.Parameters.AddWithValue("?accountname", accountname);
            MySqlDataReader AccountReader = SqlCommand.ExecuteReader();

            Account account = new Account();
            if (AccountReader.HasRows)
            {
                while (AccountReader.Read())
                {
                    account.AccountId = AccountReader.GetInt32(0);
                    account.AccountName = AccountReader.GetString(1);
                    account.AccountPassword = AccountReader.GetString(2);
                    account.AccountEmail = AccountReader.GetString(3);
                    account.AccessLevel = (byte)AccountReader.GetInt32(4);
                    account.Membership = AccountReader.GetInt32(5);
                    account.isGM = AccountReader.GetBoolean(6);
                    account.LastOnlineUtc = AccountReader.GetInt64(7);
                    account.Coins = (int)AccountReader.GetInt32(8);

                }
            }
            AccountReader.Close();
            return (account.AccountName == "") ? null : account;
        }
Ejemplo n.º 6
0
        public Storage LoadAccountStorage(Account account)
        {
            string SQL = "SELECT * FROM `inventory` WHERE "
                + "`accountname` = ?accountname AND `storagetype` = ?type";
            MySqlCommand cmd = new MySqlCommand(SQL, InventoryDAOConnection);
            cmd.Parameters.AddWithValue("?accountname", account.Name);
            cmd.Parameters.AddWithValue("?type", StorageType.AccountWarehouse.ToString());
            MySqlDataReader LoadAccountStorageReader = cmd.ExecuteReader();

            var storage = new Storage { StorageType = StorageType.AccountWarehouse };
            if (LoadAccountStorageReader.HasRows)
            {
                while (LoadAccountStorageReader.Read())
                {
                    StorageItem item = new StorageItem()
                    {
                        ItemId = LoadAccountStorageReader.GetInt32(2),
                        Count = LoadAccountStorageReader.GetInt32(3),
                        Color = LoadAccountStorageReader.GetInt32(4),
                    };
                    storage.Items.Add(LoadAccountStorageReader.GetInt32(5), item);
                }
            }
            LoadAccountStorageReader.Close();

            return storage;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Get Account Player Characters
        /// </summary>
        /// <param name="Account"></param>
        /// <param name="ServerId"></param>
        /// <returns></returns>
        public static List<Player> GetPlayers(Account Account, int ServerId)
        {
            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                List<Player> list = new List<Player>();
                connection.Open();
                using (MySqlCommand command = connection.CreateCommand())
                {
                    command.CommandText = "GAME_PLAYER_GET_ALL";
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@in_AccID", Account.id);
                    command.Parameters.AddWithValue("@in_SrvID", ServerId);
                    var reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            Player p = new Player();
                            p.Account = Account;
                            p.PlayerId = reader.GetInt32(0);
                            p.ServerId = reader.GetInt32(2);
                            p.PlayerData.Name = reader.GetString(3);
                            p.Level = reader.GetInt32(4);
                            p.PlayerData.Class = (PlayerClass)reader.GetInt32(5);
                            p.PlayerData.Title = reader.GetInt32(6);
                            p.Position.MapId = reader.GetInt32(7);
                            p.Position.X = reader.GetFloat(8);
                            p.Position.Y = reader.GetFloat(9);
                            p.Position.Z = reader.GetFloat(10);
                            p.PlayerData.Gender = (Gender)reader.GetInt32(11);
                            p.PlayerData.Forces = reader.GetInt32(12);
                            p.PlayerData.HairStyle = reader.GetInt32(13);
                            p.PlayerData.HairColor = reader.GetInt32(14);
                            p.PlayerData.Face = reader.GetInt32(15);
                            p.PlayerData.Voice = reader.GetInt32(16);
                            p.GameStats = Global.Global.StatsService.InitStats(p);
                            p.LifeStats.Hp = reader.GetInt32(17);
                            p.LifeStats.Mp = reader.GetInt32(18);
                            p.LifeStats.Sp = reader.GetInt32(19);
                            p.Exp = reader.GetInt64(20);
                            p.SkillPoint = reader.GetInt32(21);
                            p.AbilityPoint = reader.GetInt32(22);
                            p.AscensionPoint = reader.GetInt32(23);
                            p.HonorPoint = reader.GetInt32(24);
                            p.KarmaPoint = reader.GetInt32(25);

                            list.Add(p);
                        }
                    }
                }
                connection.Close();
                return list;
            }
        }
Ejemplo n.º 8
0
        public static void PacketReceived(Account account, Type type, byte[] buffer)
        {
            if (account == null)
                return;

            string callStack = "";
            StackTrace stackTrace = new StackTrace(true);
            var frames = stackTrace.GetFrames();
            
            if (frames != null)
                foreach (var frame in frames)
                    callStack += string.Format("{0}\n", frame);
        }
Ejemplo n.º 9
0
        public static void PacketSent(Account account, string name, byte[] buffer)
        {
            if (account == null)
                return;

            const string callStack = "";
            /*StackTrace stackTrace = new StackTrace(true);
            var frames = stackTrace.GetFrames();

            if (frames != null)
                foreach (var frame in frames)
                    callStack += string.Format("{0}\n", frame);*/

            InformerService.PacketSent(account.Name, name, buffer, callStack);
        }
Ejemplo n.º 10
0
        public static void PacketReceived(Account account, Type type, byte[] buffer)
        {
            if (account == null)
                return;

            StackTrace stackTrace = new StackTrace(true);
            var frames = stackTrace.GetFrames();
            string callStack = "";

            if (frames != null)
                foreach (var frame in frames)
                    callStack += string.Format("{0}\n", frame);

            InformerService.PacketReceived(account.Name, type != null ? type.Name : "unk", buffer, callStack);
        }
Ejemplo n.º 11
0
 public bool SaveAccount(Account account)
 {
     string SqlQuery = "INSERT INTO `accounts` (`username`,`password`) VALUES(?username, ?password);";
     MySqlCommand SqlCommand = new MySqlCommand(SqlQuery, AccountDAOConnection);
     SqlCommand.Parameters.AddWithValue("?username", account.Username);
     SqlCommand.Parameters.AddWithValue("?password", account.Password);
     try
     {
         SqlCommand.ExecuteNonQuery();
         return true;
     }
     catch (Exception ex)
     {
         Log.ErrorException("DAO: SAVE ACCOUNT ERROR!", ex);
     }
     return false;
 }
Ejemplo n.º 12
0
        public bool SaveAccount(Account account)
        {
            string cmdString = "INSERT INTO accounts (`Name`,`Password`) VALUES (?name, ?pass);";
            MySqlCommand command = new MySqlCommand(cmdString, AccountDAOConnection);
            command.Parameters.AddWithValue("?name", account.Name);
            command.Parameters.AddWithValue("?pass", "test");

            try
            {
                command.ExecuteNonQuery();
                return true;
            }
            catch (MySqlException ex)
            {
                Log.ErrorException("SaveAccount Error", ex);
            }

            return false;
        }
Ejemplo n.º 13
0
        public static void PacketSent(Account account, string name, byte[] buffer)
        {
            if (account == null)
            {
                return;
            }

            StackTrace stackTrace = new StackTrace(true);
            var frames = stackTrace.GetFrames();
            string callStack = "";

            if (frames != null)
            {
                foreach (var frame in frames)
                {
                    callStack += string.Format("{0}\n", frame);
                }
            }
        }
Ejemplo n.º 14
0
        public Account LoadAccount(string username)
        {
            string cmdString = "SELECT * FROM accounts WHERE Name=?username";
            MySqlCommand command = new MySqlCommand(cmdString, AccountDAOConnection);
            command.Parameters.AddWithValue("?username", username);
            MySqlDataReader reader = command.ExecuteReader();

            Account acc = new Account();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    acc.AccountId = reader.GetInt32(0);
                    acc.Name = reader.GetString(1);
                    acc.AccessLevel = (byte)reader.GetInt32(3);
                    acc.Membership = (byte)reader.GetInt32(4);
                    acc.LastOnlineUtc = reader.GetInt64(5);
                }
            }

            reader.Close();

            return (acc.Name == "") ? null : acc;
        }
Ejemplo n.º 15
0
        public Dictionary<int, StorageItem> LoadAccountStorage(Account account)
        {
            string cmdString = "SELECT * FROM inventory WHERE AccountName=?aname AND StorageType=?type";
            MySqlCommand command = new MySqlCommand(cmdString, InvenDAOConnection);
            command.Parameters.AddWithValue("?aname", account.Name);
            command.Parameters.AddWithValue("?type", StorageType.AccountWarehouse.ToString());
            MySqlDataReader reader = command.ExecuteReader();

            Dictionary<int, StorageItem> items = new Dictionary<int, StorageItem>();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    StorageItem item = new StorageItem()
                    {
                        ItemId = reader.GetInt32(3),
                        Count = reader.GetInt32(4),
                        Color = reader.GetInt32(5),
                    };
                    items.Add(reader.GetInt32(6), item);
                }
            }
            reader.Close();

            return items;
        }
Ejemplo n.º 16
0
        private void OnDisconnected(object sender, EventArgs e)
        {
            AccountLogic.ClientDisconnected(this);

            if (_account != null)
                _account.Connection = null;
            _account = null;

            if (Player != null)
                Player.Connection = null;
            Player = null;

            Buffer = null;
            Session = null;
            Client = null;
            SendData = null;
            SendLock = null;
        }
Ejemplo n.º 17
0
 public SpCharacterList(Account account)
 {
     Account = account;
 }
Ejemplo n.º 18
0
 public SpAuth(Account acc, LoginResponse resp)
 {
     Account = acc;
     Response = resp;
 }