Пример #1
0
        /// <summary>
        /// Try to load a specific account from the database
        /// </summary>
        /// <param name="state"></param>
        /// <param name="Name"></param>
        /// <param name="Password"></param>
        /// <param name="Acc"></param>
        /// <returns>EAccountLoadResult</returns>
        public static EAccountLoadResult Load(NetState state, string Name, string Password, out Account Acc, bool loadChars)
        {
            // Lookup on object manager
            if ((Acc = World.Objects.SearchAccount(Name)) != null)
            {
                if (loadChars == true)
                {
                    Acc.LoadChars();
                }
                Acc.Netstate = state;
                return(EAccountLoadResult.Success);
            }

            // Not found, load from Database
            Acc          = new Account(true);    // auto-push to world
            Acc.Netstate = state;
            DataTable table = Core.Database.Query("SELECT a.*, COUNT(*) AS charCount FROM account AS a LEFT JOIN `char` AS c ON c.accountID = a.accountID WHERE a.username = '******' LIMIT 0,1", Name.MysqlEscape());

            table.TableName = "Account Table";
            if (table.Rows.Count == 0)
            {
                return(EAccountLoadResult.UnregisteredID);
            }

            DataRow accRow = table.Rows[0];

            // Password check
            if (accRow.Field <string>("password") != Password)
            {
                Acc = null;
                return(EAccountLoadResult.IncorrectPassword);
            }
            Rovolution.Server.Database.RovolutionDatabase.PrintTableTypes(accRow.Table);
            // Enfore a serial value equal to the account ID
            // Assumes our Account creation script wont take a same ID twice
            Acc.WorldID   = new WorldID(accRow.Field <uint>("accountID"), EDatabaseType.Account);
            Acc.Name      = accRow.Field <string>("username");
            Acc.Password  = accRow.Field <string>("password");
            Acc.Sex       = (accRow.Field <string>("sex").ToLower() == "m" ? EAccountSex.Male : EAccountSex.Female);
            Acc.Email     = accRow.Field <string>("email");
            Acc.GMLevel   = accRow.FieldNull <sbyte>("gmLevel");
            Acc.LastIP    = accRow.Field <string>("lastIP");
            Acc.LastLogin = accRow.FieldDateTime("lastLogin");
            Acc.LoginID1  = mLoginRandomizer.Next() + 1;
            Acc.LoginID2  = mLoginRandomizer.Next() + 1;
            // `accountState`, `unbanTime`, `expirationTime`, `loginCount`, `birthDate`
            if (loadChars == true)
            {
                Acc.LoadChars();
            }

            return(EAccountLoadResult.Success);
        }
Пример #2
0
		/// <summary>
		/// Try to load a specific account from the database
		/// </summary>
		/// <param name="state"></param>
		/// <param name="Name"></param>
		/// <param name="Password"></param>
		/// <param name="Acc"></param>
		/// <returns>EAccountLoadResult</returns>
		public static EAccountLoadResult Load(NetState state, string Name, string Password, out Account Acc, bool loadChars) {
			// Lookup on object manager
			if ((Acc = World.Objects.SearchAccount(Name)) != null) {
				if (loadChars == true) {
					Acc.LoadChars();
				}
				Acc.Netstate = state;
				return EAccountLoadResult.Success;
			}

			// Not found, load from Database
			Acc = new Account(true); // auto-push to world
			Acc.Netstate = state;
			DataTable table = Core.Database.Query("SELECT a.*, COUNT(*) AS charCount FROM account AS a LEFT JOIN `char` AS c ON c.accountID = a.accountID WHERE a.username = '******' LIMIT 0,1", Name.MysqlEscape());
			table.TableName = "Account Table";
			if (table.Rows.Count == 0) {
				return EAccountLoadResult.UnregisteredID;
			}

			DataRow accRow = table.Rows[0];

			// Password check
			if (accRow.Field<string>("password") != Password) {
				Acc = null;
				return EAccountLoadResult.IncorrectPassword;
			}
			Rovolution.Server.Database.RovolutionDatabase.PrintTableTypes(accRow.Table);
			// Enfore a serial value equal to the account ID
			// Assumes our Account creation script wont take a same ID twice
			Acc.WorldID = new WorldID(accRow.Field<uint>("accountID"), EDatabaseType.Account);
			Acc.Name = accRow.Field<string>("username");
			Acc.Password = accRow.Field<string>("password");
			Acc.Sex = (accRow.Field<string>("sex").ToLower() == "m" ? EAccountSex.Male : EAccountSex.Female);
			Acc.Email = accRow.Field<string>("email");
			Acc.GMLevel = accRow.FieldNull<sbyte>("gmLevel");
			Acc.LastIP = accRow.Field<string>("lastIP");
			Acc.LastLogin = accRow.FieldDateTime("lastLogin");
			Acc.LoginID1 = mLoginRandomizer.Next() + 1;
			Acc.LoginID2 = mLoginRandomizer.Next() + 1;
			// `accountState`, `unbanTime`, `expirationTime`, `loginCount`, `birthDate`
			if (loadChars == true) {
				Acc.LoadChars();
			}

			return EAccountLoadResult.Success;
		}