/// <summary> /// Deserializes a list of string values from an xml element. Null values are not added to the list. /// </summary> /// <param name="node">The XmlElement from which to deserialize.</param> /// <returns>String list. Value will never be null.</returns> public static string[] LoadAccessCheck(XmlElement node) { string[] stringList; XmlElement accessCheck = node["accessCheck"]; if (accessCheck != null) { ArrayList list = new ArrayList(); foreach (XmlElement ip in accessCheck.GetElementsByTagName("ip")) { string text = Accounts.GetText(ip, null); if (text != null) { list.Add(text); } } stringList = (string[])list.ToArray(typeof(string)); } else { stringList = new string[0]; } return(stringList); }
/// <summary> /// Deserializes a list of Mobile instances from an xml element. /// </summary> /// <param name="node">The XmlElement instance from which to deserialize.</param> /// <returns>Mobile list. Value will never be null.</returns> public static Mobile[] LoadMobiles(XmlElement node) { Mobile[] list = new Mobile[6]; XmlElement chars = node["chars"]; //int length = Accounts.GetInt32( Accounts.GetAttribute( chars, "length", "6" ), 6 ); //list = new Mobile[length]; //Above is legacy, no longer used if (chars != null) { foreach (XmlElement ele in chars.GetElementsByTagName("char")) { try { int index = Accounts.GetInt32(Accounts.GetAttribute(ele, "index", "0"), 0); int serial = Accounts.GetInt32(Accounts.GetText(ele, "0"), 0); if (index >= 0 && index < list.Length) { list[index] = World.FindMobile(serial); } } catch { } } } return(list); }
/// <summary> /// Deserializes a list of Mobile instances from an xml element. /// </summary> /// <param name="node">The XmlElement instance from which to deserialize.</param> /// <returns>Mobile list. Value will never be null.</returns> public static Mobile[] LoadMobiles(XmlElement node) { Mobile[] list; XmlElement chars = node["chars"]; if (chars == null) { list = new Mobile[5]; } else { int length = Accounts.GetInt32(Accounts.GetAttribute(chars, "length", "5"), 5); list = new Mobile[length]; foreach (XmlElement ele in chars.GetElementsByTagName("char")) { try { int index = Accounts.GetInt32(Accounts.GetAttribute(ele, "index", "0"), 0); int serial = Accounts.GetInt32(Accounts.GetText(ele, "0"), 0); if (index >= 0 && index < list.Length) { list[index] = World.FindMobile(serial); } } catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); } } } return(list); }
public static string[] LoadEmailHistory(XmlElement node) { string[] stringList; XmlElement emailHistory = node["emailHistory"]; if (emailHistory != null) { ArrayList list = new ArrayList(); foreach (XmlElement address in emailHistory.GetElementsByTagName("addr")) { string text = Accounts.GetText(address, null); if (text != null) { list.Add(text); } } stringList = (string[])list.ToArray(typeof(string)); } else { stringList = new string[0]; } return(stringList); }
/// <summary> /// Deserializes a list of IPAddress values from an xml element. /// </summary> /// <param name="node">The XmlElement from which to deserialize.</param> /// <returns>Address list. Value will never be null.</returns> public static IPAddress[] LoadAddressList(XmlElement node) { IPAddress[] list; XmlElement addressList = node["addressList"]; if (addressList != null) { int count = Accounts.GetInt32(Accounts.GetAttribute(addressList, "count", "0"), 0); list = new IPAddress[count]; count = 0; foreach (XmlElement ip in addressList.GetElementsByTagName("ip")) { try { if (count < list.Length) { list[count] = IPAddress.Parse(Accounts.GetText(ip, null)); count++; } } catch { } } if (count != list.Length) { IPAddress[] old = list; list = new IPAddress[count]; for (int i = 0; i < count && i < old.Length; ++i) { list[i] = old[i]; } } } else { list = new IPAddress[0]; } return(list); }
/// <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, ""); }
/// <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, ""); }
/// <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(); } }
/// <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; } } }