private void UpdateFromWhitelist(PlayerModel player)
{
if (player == null) return;
foreach (String item in fSettingWhitelist) {
try {
// Example item: name B U S D R
List<String> tokens = new List<String>(Regex.Split(item, @"\s+"));
if (tokens.Count < 1) continue;
String guid = (String.IsNullOrEmpty(player.EAGUID)) ? INVALID_NAME_TAG_GUID : player.EAGUID;
String xt = ExtractTag(player);
if (String.IsNullOrEmpty(xt)) xt = INVALID_NAME_TAG_GUID;
// If nothing matches, keep looking
if (!(tokens[0] == player.Name || tokens[0] == xt || tokens[0] == guid)) continue;
// Reset
player.Whitelist = 0;
// Set new flags
if (tokens.Count == 1) { // no option codes means set all of them
player.Whitelist = WL_ALL;
DebugWrite("^9DEBUG: UpdateFromWhitelist(^b" + player.FullName + "^n) set ALL flags!", 7);
} else {
for (int i = 1; i < tokens.Count; ++i) {
switch (tokens[i]) {
case "B":
player.Whitelist |= WL_BALANCE;
DebugWrite("^9DEBUG: UpdateFromWhitelist(^b" + player.FullName + "^n) set WL_BALANCE flag!", 7);
break;
case "U":
player.Whitelist |= WL_UNSTACK;
DebugWrite("^9DEBUG: UpdateFromWhitelist(^b" + player.FullName + "^n) set WL_UNSTACK flag!", 7);
break;
case "S":
player.Whitelist |= WL_SWITCH;
DebugWrite("^9DEBUG: UpdateFromWhitelist(^b" + player.FullName + "^n) set WL_SWITCH flag!", 7);
break;
case "D":
player.Whitelist |= WL_DISPERSE;
DebugWrite("^9DEBUG: UpdateFromWhitelist(^b" + player.FullName + "^n) set WL_DISPERSE flag!", 7);
break;
case "R":
player.Whitelist |= WL_RANK;
DebugWrite("^9DEBUG: UpdateFromWhitelist(^b" + player.FullName + "^n) set WL_RANK flag!", 7);
break;
default:
ConsoleWarn("Skipping unknown Whitelist code " + tokens[i] + ", in item: " + item);
break;
}
}
}
return;
} catch (Exception e) {
ConsoleException(e);
}
}
}