Пример #1
0
        public static void PacketReceived(GameAccount gameAccount, Type type, byte[] buffer)
        {
            if (gameAccount == 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);
        }
Пример #2
0
        public GameAccount 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();

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

                    }
                }
                AccountReader.Close();


                SqlQuery = "SELECT * FROM `accout_items` WHERE `Id` = @ID";
                SqlCommand = new MySqlCommand(SqlQuery, AccountDAOConnection);
                SqlCommand.Parameters.AddWithValue("@Id", acc.AccountId);
                AccountReader = SqlCommand.ExecuteReader();

                if (AccountReader.HasRows)
                {
                    while (AccountReader.Read())
                    {
                        AccountItem tmpItem = new AccountItem();
                        tmpItem.ItemId = AccountReader.GetInt32(1);
                        tmpItem.Options = AccountReader.GetInt32(2);

                        acc.AccountItems.Add(tmpItem);
                    }
                }
                AccountReader.Close();


                return (acc.Username == "") ? null : acc;
        }
Пример #3
0
        public List<Player> OnAuthorized(GameAccount gameAccount)
        {
            var list = DAOManager.playerDAO.LoadAccountPlayers(gameAccount.Username);

            foreach (var player in list)
            {
                player.Inventory = DAOManager.inventoryDAO.LoadStorage(player, StorageType.Inventory);
                player.CharacterWarehouse = DAOManager.inventoryDAO.LoadStorage(player, StorageType.CharacterWarehouse);
                player.Quests = DAOManager.questDAO.LoadQuests(player);
                player.Skills = DAOManager.skillDAO.LoadSkills(player);
                //player.Guild = DAOManager.guildDAO.LoadPlayerGuild(player);

                if (gameAccount.IsGM.Equals(true))
                { player.PlayerData.IsGM = true; }

            }
            return list;
        }
Пример #4
0
 public SpSendCharacterList(GameAccount gameAccount)
 {
     GameAccount = gameAccount;
 }
Пример #5
0
 public SpAccountItems(GameAccount gameAccount)
 {
     GameAccount = gameAccount;
 }
Пример #6
0
        public Storage LoadAccountStorage(GameAccount gameAccount)
        {
            string SQL = "SELECT * FROM `inventory` WHERE "
                + "`accountname` = ?accountname AND `storagetype` = ?type";
            MySqlCommand cmd = new MySqlCommand(SQL, InventoryDAOConnection);
            cmd.Parameters.AddWithValue("?accountname", gameAccount.Username);
            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),
                        Amount = LoadAccountStorageReader.GetInt32(3),
                        Color = LoadAccountStorageReader.GetInt32(4),
                    };
                    storage.Items.Add(LoadAccountStorageReader.GetInt32(5), item);
                }
            }
            LoadAccountStorageReader.Close();

            return storage;
        }
Пример #7
0
        private void OnDisconnected(object sender, EventArgs e)
        {
            AccountLogic.ClientDisconnected(this);

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

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

            Buffer = null;
            Session = null;
            Client = null;
            SendData = null;
            SendLock = null;
        }
Пример #8
0
 public bool SaveAccount(GameAccount gameAccount)
 {
     string SqlQuery = "INSERT INTO `accounts` (`username`,`password`) VALUES(?username, ?password);";
     MySqlCommand SqlCommand = new MySqlCommand(SqlQuery, AccountDAOConnection);
     SqlCommand.Parameters.AddWithValue("?username", gameAccount.Username);
     SqlCommand.Parameters.AddWithValue("?password", gameAccount.Password);
     try
     {
         SqlCommand.ExecuteNonQuery();
         return true;
     }
     catch (Exception ex)
     {
         Logger.WriteLine(LogState.Exception, "DAO: SAVE ACCOUNT ERROR! " + ex.Message);
     }
     return false;
 }