private void SetFriends()
{
if (fSettingFriendsList.Count == 0) return;
if (fSettingFriendsList.Count == 1 && fSettingFriendsList[0] == DEFAULT_LIST_ITEM) return;
fFriends.Clear();
int key = 1;
foreach (String line in fSettingFriendsList) {
try {
if (String.IsNullOrEmpty(line)) continue;
if (line == DEFAULT_LIST_ITEM) continue;
String[] tokens = Regex.Split(line, @"\s+");
if (tokens != null && tokens.Length == 1 && !String.IsNullOrEmpty(tokens[0])) {
throw new Exception("Line contains only one name");
}
// Otherwise, store the sub-list of friends
List<String> subList = new List<String>();
foreach (String token in tokens) {
if (String.IsNullOrEmpty(token)) continue;
subList.Add(token);
}
fFriends[key] = subList;
++key;
} catch (Exception e) {
ConsoleWarn("In Friends List, skipping bad line: " + line);
ConsoleWarn(e.Message);
}
}
// Check uniqueness
fAllFriends.Clear();
foreach (int k in fFriends.Keys) {
List<String> copy = new List<String>(fFriends[k]);
foreach (String name in copy) {
if (fAllFriends.Contains(name)) {
ConsoleWarn("In Friends List, ^b" + name + "^n is duplicated on one line, please change the line");
fFriends[k].Remove(name);
} else {
fAllFriends.Add(name);
}
}
}
// Update player model
UpdateFriends();
// debugging
if (DebugLevel >= 6) {
ConsoleDebug("SetFriends list of friends: ");
foreach (int k in fFriends.Keys) {
ConsoleDebug(k.ToString() + ": " + String.Join(", ", fFriends[k].ToArray()));
}
}
}