public Account(XmlElement node) { this.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) { this.SetPassword(plainPassword); } else if (newCryptPassword != null) { this.m_NewCryptPassword = newCryptPassword; } else if (cryptPassword != null) { this.m_CryptPassword = cryptPassword; } else { this.SetPassword("empty"); } break; } case PasswordProtection.Crypt: { if (cryptPassword != null) { this.m_CryptPassword = cryptPassword; } else if (plainPassword != null) { this.SetPassword(plainPassword); } else if (newCryptPassword != null) { this.m_NewCryptPassword = newCryptPassword; } else { this.SetPassword("empty"); } break; } default: // PasswordProtection.NewCrypt { if (newCryptPassword != null) { this.m_NewCryptPassword = newCryptPassword; } else if (plainPassword != null) { this.SetPassword(plainPassword); } else if (cryptPassword != null) { this.m_CryptPassword = cryptPassword; } else { this.SetPassword("empty"); } break; } } Enum.TryParse(Utility.GetText(node["accessLevel"], "Player"), true, out this.m_AccessLevel); this.m_Flags = Utility.GetXMLInt32(Utility.GetText(node["flags"], "0"), 0); this.m_Created = Utility.GetXMLDateTime(Utility.GetText(node["created"], null), DateTime.Now); this.m_LastLogin = Utility.GetXMLDateTime(Utility.GetText(node["lastLogin"], null), DateTime.Now); this.m_Mobiles = LoadMobiles(node); this.m_Comments = LoadComments(node); this.m_Tags = LoadTags(node); this.m_LoginIPs = LoadAddressList(node); this.m_IPRestrictions = LoadAccessCheck(node); for (int i = 0; i < this.m_Mobiles.Length; ++i) { if (this.m_Mobiles[i] != null) { this.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 < this.m_Mobiles.Length; i++) { PlayerMobile m = this.m_Mobiles[i] as PlayerMobile; if (m != null) { totalGameTime += m.GameTime; } } } this.m_TotalGameTime = totalGameTime; if (this.Young) { this.CheckYoung(); } Accounts.Add(this); }
public Account(XmlElement node) { Serial = Accounts.NewAccount; var ourType = GetType(); TypeRef = Accounts.Types.IndexOf(ourType); if (TypeRef == -1) { Accounts.Types.Add(ourType); TypeRef = Accounts.Types.Count - 1; } 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); }
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); }
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); string saltedCryptPassword = Utility.GetText(node["saltedCryptPassword"], null); switch (AccountHandler.ProtectPasswords) { case PasswordProtection.None: { if (plainPassword != null) { SetPassword(plainPassword); } else if (cryptPassword != null) { m_CryptPassword = cryptPassword; } else if (newCryptPassword != null) { m_NewCryptPassword = newCryptPassword; } else if (saltedCryptPassword != null) { m_SaltedCryptPassword = saltedCryptPassword; } 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 if (saltedCryptPassword != null) { m_SaltedCryptPassword = saltedCryptPassword; } else { SetPassword("empty"); } break; } case PasswordProtection.NewCrypt: { if (newCryptPassword != null) { m_NewCryptPassword = newCryptPassword; } else if (plainPassword != null) { SetPassword(plainPassword); } else if (cryptPassword != null) { m_CryptPassword = cryptPassword; } else if (saltedCryptPassword != null) { m_SaltedCryptPassword = saltedCryptPassword; } else { SetPassword("empty"); } break; } default: { if (saltedCryptPassword != null) { m_SaltedCryptPassword = saltedCryptPassword; } else if (plainPassword != null) { SetPassword(plainPassword); } else if (cryptPassword != null) { m_CryptPassword = cryptPassword; } else if (newCryptPassword != null) { m_NewCryptPassword = newCryptPassword; } 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_SFO = (FeatureFlags)Utility.GetXMLInt32(Utility.GetText(node["SFO"], "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_Email = Utility.GetText(node["email"], String.Empty); m_Language = Utility.GetText(node["language"], String.Empty); m_SecurityQuestion = Utility.GetText(node["secquest"], String.Empty); m_SecurityAnswer = Utility.GetText(node["secanswer"], String.Empty); 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); }