Exemple #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;

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