Handle errors in profile files
This commit is contained in:
1 parent
a5ddeeee95
commit
e66d108df0
1 file changed
+10
-7
@@ -84,18 +84,21 @@ namespace VocaluxeLib.Profile
|
|||||||
{
|
{
|
||||||
PlayerName = value;
|
PlayerName = value;
|
||||||
string avatarFileName;
|
string avatarFileName;
|
||||||
xmlReader.TryGetEnumValue("//root/Info/Difficulty", ref Difficulty);
|
bool ok = xmlReader.TryGetEnumValue("//root/Info/Difficulty", ref Difficulty);
|
||||||
xmlReader.GetValue("//root/Info/Avatar", out avatarFileName, String.Empty);
|
ok &= xmlReader.GetValue("//root/Info/Avatar", out avatarFileName);
|
||||||
Avatar = CBase.Profiles.GetAvatarByFilename(avatarFileName);
|
Avatar = CBase.Profiles.GetAvatarByFilename(avatarFileName);
|
||||||
xmlReader.TryGetEnumValue("//root/Info/UserRole", ref UserRole);
|
ok &= Avatar != null;
|
||||||
xmlReader.TryGetEnumValue("//root/Info/Active", ref Active);
|
ok &= xmlReader.TryGetEnumValue("//root/Info/UserRole", ref UserRole);
|
||||||
|
ok &= xmlReader.TryGetEnumValue("//root/Info/Active", ref Active);
|
||||||
string passwordHash;
|
string passwordHash;
|
||||||
xmlReader.GetValue("//root/Info/PasswordHash", out passwordHash, "");
|
xmlReader.GetValue("//root/Info/PasswordHash", out passwordHash);
|
||||||
PasswordHash = !string.IsNullOrEmpty(passwordHash) ? Convert.FromBase64String(passwordHash) : null;
|
PasswordHash = !string.IsNullOrEmpty(passwordHash) ? Convert.FromBase64String(passwordHash) : null;
|
||||||
string passwordSalt;
|
string passwordSalt;
|
||||||
xmlReader.GetValue("//root/Info/PasswordSalt", out passwordSalt, "");
|
xmlReader.GetValue("//root/Info/PasswordSalt", out passwordSalt);
|
||||||
PasswordSalt = !string.IsNullOrEmpty(passwordSalt) ? Convert.FromBase64String(passwordSalt) : null;
|
PasswordSalt = !string.IsNullOrEmpty(passwordSalt) ? Convert.FromBase64String(passwordSalt) : null;
|
||||||
return true;
|
if (!ok)
|
||||||
|
CBase.Log.LogError("Error loading profile file: " + FileName);
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBase.Log.LogError("Can't find PlayerName in Profile File: " + FileName);
|
CBase.Log.LogError("Can't find PlayerName in Profile File: " + FileName);
|
||||||
|
|||||||
Reference in new issue
Block a user