Beispiel #1
0
        /// <summary>
        /// Deserializes an Account instance from an xml element. Intended only to be called from Accounts.Load.
        /// </summary>
        /// <param name="node">The XmlElement instance from which to deserialize.</param>
        public Account(XmlElement node)
        {
            m_Username = Accounts.GetText(node["username"], "empty");

            string plainPassword = Accounts.GetText(node["password"], null);
            string cryptPassword = Accounts.GetText(node["cryptPassword"], null);

            if (AccountHandler.ProtectPasswords)
            {
                if (cryptPassword != null)
                {
                    m_CryptPassword = cryptPassword;
                }
                else if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else
                {
                    SetPassword("empty");
                }
            }
            else
            {
                if (plainPassword == null)
                {
                    plainPassword = "******";
                }

                SetPassword(plainPassword);
            }

            m_AccessLevel = (AccessLevel)Enum.Parse(typeof(AccessLevel), Accounts.GetText(node["accessLevel"], "Player"), true);
            m_Flags       = Accounts.GetInt32(Accounts.GetText(node["flags"], "0"), 0);
            m_Created     = Accounts.GetDateTime(Accounts.GetText(node["created"], null), DateTime.Now);
            m_LastLogin   = Accounts.GetDateTime(Accounts.GetText(node["lastLogin"], null), DateTime.Now);

            m_Mobiles        = LoadMobiles(node);
            m_Comments       = LoadComments(node);
            m_Tags           = LoadTags(node);
            m_LoginIPs       = LoadAddressList(node);
            m_IPRestrictions = LoadAccessCheck(node);

            for (int i = 0; i < m_Mobiles.Length; ++i)
            {
                if (m_Mobiles[i] != null)
                {
                    m_Mobiles[i].Account = this;
                }
            }

            TimeSpan totalGameTime = Accounts.GetTimeSpan(Accounts.GetText(node["totalGameTime"], null), TimeSpan.Zero);

            if (totalGameTime == TimeSpan.Zero)
            {
                for (int i = 0; i < m_Mobiles.Length; i++)
                {
                    PlayerMobile m = m_Mobiles[i] as PlayerMobile;

                    if (m != null)
                    {
                        totalGameTime += m.GameTime;
                    }
                }
            }
            m_TotalGameTime = totalGameTime;
        }
Beispiel #2
0
        public Account(XmlElement node)
        {
            m_Username = Utility.GetText(node["username"], "empty");

            string plainPassword    = Utility.GetText(node["password"], null);
            string cryptPassword    = Utility.GetText(node["cryptPassword"], null);
            string newCryptPassword = Utility.GetText(node["newCryptPassword"], null);

            switch (AccountHandler.ProtectPasswords)
            {
            case PasswordProtection.None:
            {
                if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else if (newCryptPassword != null)
                {
                    m_NewCryptPassword = newCryptPassword;
                }
                else if (cryptPassword != null)
                {
                    m_CryptPassword = cryptPassword;
                }
                else
                {
                    SetPassword("empty");
                }

                break;
            }

            case PasswordProtection.Crypt:
            {
                if (cryptPassword != null)
                {
                    m_CryptPassword = cryptPassword;
                }
                else if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else if (newCryptPassword != null)
                {
                    m_NewCryptPassword = newCryptPassword;
                }
                else
                {
                    SetPassword("empty");
                }

                break;
            }

            default:                     // PasswordProtection.NewCrypt
            {
                if (newCryptPassword != null)
                {
                    m_NewCryptPassword = newCryptPassword;
                }
                else if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else if (cryptPassword != null)
                {
                    m_CryptPassword = cryptPassword;
                }
                else
                {
                    SetPassword("empty");
                }

                break;
            }
            }

            m_AccessLevel = (AccessLevel)Enum.Parse(typeof(AccessLevel), Utility.GetText(node["accessLevel"], "Player"), true);
            m_Flags       = Utility.GetXMLInt32(Utility.GetText(node["flags"], "0"), 0);
            m_Created     = Utility.GetXMLDateTime(Utility.GetText(node["created"], null), DateTime.Now);
            m_LastLogin   = Utility.GetXMLDateTime(Utility.GetText(node["lastLogin"], null), DateTime.Now);

            m_Mobiles        = LoadMobiles(node);
            m_Comments       = LoadComments(node);
            m_Tags           = LoadTags(node);
            m_LoginIPs       = LoadAddressList(node);
            m_IPRestrictions = LoadAccessCheck(node);

            for (int i = 0; i < m_Mobiles.Length; ++i)
            {
                if (m_Mobiles[i] != null)
                {
                    m_Mobiles[i].Account = this;
                }
            }

            TimeSpan totalGameTime = Utility.GetXMLTimeSpan(Utility.GetText(node["totalGameTime"], null), TimeSpan.Zero);

            if (totalGameTime == TimeSpan.Zero)
            {
                for (int i = 0; i < m_Mobiles.Length; i++)
                {
                    PlayerMobile m = m_Mobiles[i] as PlayerMobile;

                    if (m != null)
                    {
                        totalGameTime += m.GameTime;
                    }
                }
            }
            m_TotalGameTime = totalGameTime;

            if (this.Young)
            {
                CheckYoung();
            }

            Accounts.Add(this);
        }
Beispiel #3
0
		private static void ConvertCurrency(CommandEventArgs e)
		{
			e.Mobile.SendMessage(
				"Converting All Banked Gold from {0} to {1}.  Please wait...",
				AccountGold.Enabled ? "checks and coins" : "account treasury",
				AccountGold.Enabled ? "account treasury" : "checks and coins");

			NetState.Pause();

			double found = 0.0, converted = 0.0;

			try
			{
				BankBox box;
				List<Gold> gold;
				List<BankCheck> checks;
				long share = 0, shared;
				int diff;

				foreach (var a in Accounts.GetAccounts().OfType<Account>().Where(a => a.Count > 0))
				{
					try
					{
						if (!AccountGold.Enabled)
						{
							share = (int)Math.Truncate((a.TotalCurrency / a.Count) * CurrencyThreshold);
							found += a.TotalCurrency * CurrencyThreshold;
						}

						foreach (var m in a.m_Mobiles.Where(m => m != null))
						{
							box = m.FindBankNoCreate();

							if (box == null)
							{
								continue;
							}

							if (AccountGold.Enabled)
							{
								foreach (var o in checks = box.FindItemsByType<BankCheck>())
								{
									found += o.Worth;

									if (!a.DepositGold(o.Worth))
									{
										break;
									}

									converted += o.Worth;
									o.Delete();
								}

								checks.Clear();
								checks.TrimExcess();

								foreach (var o in gold = box.FindItemsByType<Gold>())
								{
									found += o.Amount;

									if (!a.DepositGold(o.Amount))
									{
										break;
									}

									converted += o.Amount;
									o.Delete();
								}

								gold.Clear();
								gold.TrimExcess();
							}
							else
							{
								shared = share;

								while (shared > 0)
								{
									if (shared > 60000)
									{
										diff = (int)Math.Min(10000000, shared);

										if (a.WithdrawGold(diff))
										{
											box.DropItem(new BankCheck(diff));
										}
										else
										{
											break;
										}
									}
									else
									{
										diff = (int)Math.Min(60000, shared);

										if (a.WithdrawGold(diff))
										{
											box.DropItem(new Gold(diff));
										}
										else
										{
											break;
										}
									}

									converted += diff;
									shared -= diff;
								}
							}

							box.UpdateTotals();
						}
					}
					catch
					{ }
				}
			}
			catch
			{ }

			NetState.Resume();

			e.Mobile.SendMessage("Operation complete: {0:#,0} of {1:#,0} Gold has been converted in total.", converted, found);
		}
 /// <summary>
 /// Deserializes an AccountComment instance from an xml element.
 /// </summary>
 /// <param name="node">The XmlElement instance from which to deserialize.</param>
 public AccountComment(XmlElement node)
 {
     m_AddedBy      = Accounts.GetAttribute(node, "addedBy", "empty");
     m_LastModified = Accounts.GetDateTime(Accounts.GetAttribute(node, "lastModified"), DateTime.Now);
     m_Content      = Accounts.GetText(node, "");
 }
Beispiel #5
0
 /// <summary>
 /// Deserializes an AccountTag instance from an xml element.
 /// </summary>
 /// <param name="node">The XmlElement instance from which to deserialize.</param>
 public AccountTag(XmlElement node)
 {
     m_Name  = Accounts.GetAttribute(node, "name", "empty");
     m_Value = Accounts.GetText(node, "");
 }
Beispiel #6
0
        /// <summary>
        /// Deserializes an Account instance from an xml element. Intended only to be called from Accounts.Load.
        /// </summary>
        /// <param name="node">The XmlElement instance from which to deserialize.</param>
        public Account(XmlElement node)
        {
            m_Username = Accounts.GetText(node["username"], "empty");

            string plainPassword = Accounts.GetText(node["password"], null);
            string cryptPassword = Accounts.GetText(node["cryptPassword"], null);

            if (AccountHandler.ProtectPasswords)
            {
                if (cryptPassword != null)
                {
                    m_CryptPassword = cryptPassword;
                }
                else if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else
                {
                    SetPassword("empty");
                }
            }
            else
            {
                if (plainPassword == null)
                {
                    plainPassword = "******";
                }

                SetPassword(plainPassword);
            }

            m_AccessLevel = (AccessLevel)Enum.Parse(typeof(AccessLevel), Accounts.GetText(node["accessLevel"], "Player"), true);
            m_Flags       = Accounts.GetInt32(Accounts.GetText(node["flags"], "0"), 0);
            m_Created     = Accounts.GetDateTime(Accounts.GetText(node["created"], null), DateTime.Now);
            m_LastLogin   = Accounts.GetDateTime(Accounts.GetText(node["lastLogin"], null), DateTime.Now);

            m_EmailAddress = Accounts.GetText(node["email"], "empty");

            m_WatchReason = Accounts.GetText(node["watchreason"], "");
            m_WatchExpire = Accounts.GetDateTime(Accounts.GetText(node["watchexpiredate"], null), DateTime.MinValue);

            m_Mobiles        = LoadMobiles(node);
            m_Comments       = LoadComments(node);
            m_Tags           = LoadTags(node);
            m_LoginIPs       = LoadAddressList(node);
            m_IPRestrictions = LoadAccessCheck(node);
            m_EmailHistory   = LoadEmailHistory(node);

            m_bAccountActivated          = Accounts.GetBool(node["accountactivated"], false);
            m_ActivationKey              = Accounts.GetText(node["activationkey"], "");
            m_ResetPassword              = Accounts.GetText(node["resetpassword"], "");
            m_ResetPasswordRequestedTime = Accounts.GetDateTime(Accounts.GetText(node["resetpwdtime"], null), DateTime.MinValue);

            for (int i = 0; i < m_Mobiles.Length; ++i)
            {
                if (m_Mobiles[i] != null)
                {
                    m_Mobiles[i].Account = this;
                }
            }
        }
Beispiel #7
0
        public Account(XmlElement node)
        {
            Username = Utility.GetText(node["username"], "empty");

            Enum.TryParse(Utility.GetText(node["passwordAlgorithm"], null), true, out m_PasswordAlgorithm);

            // Backward compatibility with RunUO/ServUO
            if (m_PasswordAlgorithm == PasswordProtectionAlgorithm.None)
            {
                var upgraded =
                    UpgradePassword(
                        Utility.GetText(node["newSecureCryptPassword"], null),
                        PasswordProtectionAlgorithm.SHA2
                        ) ||
                    UpgradePassword(Utility.GetText(node["newCryptPassword"], null), PasswordProtectionAlgorithm.SHA1) ||
                    UpgradePassword(Utility.GetText(node["cryptPassword"], null), PasswordProtectionAlgorithm.MD5);

                // Automatically upgrade plain passwords to current algorithm.
                if (!upgraded)
                {
                    SetPassword(Utility.GetText(node["password"], null));
                }
            }
            else
            {
                Password = Utility.GetText(node["password"], null);
            }

            Enum.TryParse(Utility.GetText(node["accessLevel"], "Player"), true, out m_AccessLevel);
            Flags     = Utility.GetXMLInt32(Utility.GetText(node["flags"], "0"), 0);
            Created   = Utility.GetXMLDateTime(Utility.GetText(node["created"], null), DateTime.UtcNow);
            LastLogin = Utility.GetXMLDateTime(Utility.GetText(node["lastLogin"], null), DateTime.UtcNow);

            TotalGold = Utility.GetXMLInt32(Utility.GetText(node["totalGold"], "0"), 0);
            TotalPlat = Utility.GetXMLInt32(Utility.GetText(node["totalPlat"], "0"), 0);

            m_Mobiles      = LoadMobiles(node);
            m_Comments     = LoadComments(node);
            m_Tags         = LoadTags(node);
            LoginIPs       = LoadAddressList(node);
            IPRestrictions = LoadAccessCheck(node);

            for (var i = 0; i < m_Mobiles.Length; ++i)
            {
                if (m_Mobiles[i] != null)
                {
                    m_Mobiles[i].Account = this;
                }
            }

            var totalGameTime = Utility.GetXMLTimeSpan(Utility.GetText(node["totalGameTime"], null), TimeSpan.Zero);

            if (totalGameTime == TimeSpan.Zero)
            {
                for (var i = 0; i < m_Mobiles.Length; i++)
                {
                    if (m_Mobiles[i] is PlayerMobile m)
                    {
                        totalGameTime += m.GameTime;
                    }
                }
            }

            m_TotalGameTime = totalGameTime;

            if (Young)
            {
                CheckYoung();
            }

            Accounts.Add(this);
        }
Beispiel #8
0
        public Account(XmlElement node)
        {
            Username = Utility.GetText(node["username"], "empty");

            string plainPassword       = Utility.GetText(node["password"], null);
            string cryptPassword       = Utility.GetText(node["cryptPassword"], null);
            string newCryptPassword    = Utility.GetText(node["newCryptPassword"], null);
            string saltedCryptPassword = Utility.GetText(node["saltedCryptPassword"], null);

            switch (AccountHandler.ProtectPasswords)
            {
            case PasswordProtection.None:
            {
                if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else if (cryptPassword != null)
                {
                    CryptPassword = cryptPassword;
                }
                else if (newCryptPassword != null)
                {
                    NewCryptPassword = newCryptPassword;
                }
                else if (saltedCryptPassword != null)
                {
                    SaltedCryptPassword = saltedCryptPassword;
                }
                else
                {
                    SetPassword("empty");
                }
            }
            break;

            case PasswordProtection.Crypt:
            {
                if (cryptPassword != null)
                {
                    CryptPassword = cryptPassword;
                }
                else if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else if (newCryptPassword != null)
                {
                    NewCryptPassword = newCryptPassword;
                }
                else if (saltedCryptPassword != null)
                {
                    SaltedCryptPassword = saltedCryptPassword;
                }
                else
                {
                    SetPassword("empty");
                }
            }
            break;

            case PasswordProtection.NewCrypt:
            {
                if (newCryptPassword != null)
                {
                    NewCryptPassword = newCryptPassword;
                }
                else if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else if (cryptPassword != null)
                {
                    CryptPassword = cryptPassword;
                }
                else if (saltedCryptPassword != null)
                {
                    SaltedCryptPassword = saltedCryptPassword;
                }
                else
                {
                    SetPassword("empty");
                }
            }
            break;

            default:
            {
                if (saltedCryptPassword != null)
                {
                    SaltedCryptPassword = saltedCryptPassword;
                }
                else if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else if (cryptPassword != null)
                {
                    CryptPassword = cryptPassword;
                }
                else if (newCryptPassword != null)
                {
                    NewCryptPassword = newCryptPassword;
                }
                else
                {
                    SetPassword("empty");
                }
            }
            break;
            }

            AccessLevel al;

            if (Enum.TryParse(Utility.GetText(node["accessLevel"], "Player"), true, out al))
            {
                AccessLevel = al;
            }

            Flags     = Utility.GetXMLInt32(Utility.GetText(node["flags"], "0"), 0);
            Created   = Utility.GetXMLDateTime(Utility.GetText(node["created"], null), DateTime.UtcNow);
            LastLogin = Utility.GetXMLDateTime(Utility.GetText(node["lastLogin"], null), DateTime.UtcNow);

            Email            = Utility.GetText(node["email"], String.Empty);
            Language         = Utility.GetText(node["language"], String.Empty);
            SecurityQuestion = Utility.GetText(node["secquest"], String.Empty);
            SecurityAnswer   = Utility.GetText(node["secanswer"], String.Empty);

            Mobiles        = LoadMobiles(node);
            Comments       = LoadComments(node);
            Tags           = LoadTags(node);
            LoginIPs       = LoadAddressList(node);
            IPRestrictions = LoadAccessCheck(node);

            foreach (Mobile t in Mobiles.Where(m => m != null))
            {
                t.Account = this;
            }

            TimeSpan totalGameTime = Utility.GetXMLTimeSpan(Utility.GetText(node["totalGameTime"], null), TimeSpan.Zero);

            if (totalGameTime == TimeSpan.Zero)
            {
                totalGameTime = Mobiles.OfType <PlayerMobile>().Aggregate(totalGameTime, (current, m) => current + m.GameTime);
            }

            TotalAcctGameTime = totalGameTime;

            if (Young)
            {
                CheckYoung();
            }

            Accounts.Add(this);
        }
Beispiel #9
0
        public Account(Accounts accounts, XmlElement node)
        {
            m_Username = Utility.GetText(node["username"], "empty");

            string plainPassword    = Utility.GetText(node["password"], null);
            string cryptPassword    = Utility.GetText(node["cryptPassword"], null);
            string newCryptPassword = Utility.GetText(node["newCryptPassword"], null);

            switch (AccountHandler.ProtectPasswords)
            {
            case PasswordProtection.None:
            {
                if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else if (newCryptPassword != null)
                {
                    m_NewCryptPassword = newCryptPassword;
                }
                else if (cryptPassword != null)
                {
                    m_CryptPassword = cryptPassword;
                }
                else
                {
                    SetPassword("empty");
                }

                break;
            }

            case PasswordProtection.Crypt:
            {
                if (cryptPassword != null)
                {
                    m_CryptPassword = cryptPassword;
                }
                else if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else if (newCryptPassword != null)
                {
                    m_NewCryptPassword = newCryptPassword;
                }
                else
                {
                    SetPassword("empty");
                }

                break;
            }

            default:                     // PasswordProtection.NewCrypt
            {
                if (newCryptPassword != null)
                {
                    m_NewCryptPassword = newCryptPassword;
                }
                else if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else if (cryptPassword != null)
                {
                    m_CryptPassword = cryptPassword;
                }
                else
                {
                    SetPassword("empty");
                }

                break;
            }
            }
            try
            {
                m_AccessLevel = (AccessLevel)Enum.Parse(typeof(AccessLevel), Utility.GetText(node["accessLevel"], "Player"), true);
            }
            catch
            {
                switch (Utility.GetText(node["accessLevel"], "Player"))
                {
                case "GameMaster": m_AccessLevel = AccessLevel.Batisseur; break;

                case "Seer": m_AccessLevel = AccessLevel.Chroniqueur; break;

                case "Administrator": m_AccessLevel = AccessLevel.Chroniqueur; break;

                default:
                    Console.WriteLine("ERROR: Incapable d'identifier le accesslevel d'un compte (accesslevel: {0}). Avez-vous changé leurs noms?",
                                      Utility.GetText(node["accessLevel"], "Player"));
                    break;
                }
            }
            m_Flags     = Utility.GetXMLInt32(Utility.GetText(node["flags"], "0"), 0);
            m_Created   = Utility.GetXMLDateTime(Utility.GetText(node["created"], null), DateTime.Now);
            m_LastLogin = Utility.GetXMLDateTime(Utility.GetText(node["lastLogin"], null), DateTime.Now);

            m_Mobiles        = LoadMobiles(node);
            m_Comments       = LoadComments(node);
            m_Tags           = LoadTags(node);
            m_LoginIPs       = LoadAddressList(node);
            m_IPRestrictions = LoadAccessCheck(node);


            for (int i = 0; i < m_Mobiles.Length; ++i)
            {
                if (m_Mobiles[i] != null)
                {
                    m_Mobiles[i].Account = this;
                }
            }

            TimeSpan totalGameTime = Utility.GetXMLTimeSpan(Utility.GetText(node["totalGameTime"], null), TimeSpan.Zero);

            if (totalGameTime == TimeSpan.Zero)
            {
                for (int i = 0; i < m_Mobiles.Length; i++)
                {
                    PlayerMobile m = m_Mobiles[i] as PlayerMobile;

                    if (m != null)
                    {
                        totalGameTime += m.GameTime;
                    }
                }
            }
            m_TotalGameTime = totalGameTime;

            accounts.Add(this);

            m_Transfert = LoadTransfert(node);
        }