diff --git a/Client/Context/IntroContext.cs b/Client/Context/IntroContext.cs index 6934145..2e3acae 100644 --- a/Client/Context/IntroContext.cs +++ b/Client/Context/IntroContext.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Client.ConsoleForms; using Client.ConsoleForms.Graphics; diff --git a/Server/Database.cs b/Server/Database.cs index b85ed4a..5da55f4 100644 --- a/Server/Database.cs +++ b/Server/Database.cs @@ -317,28 +317,18 @@ namespace Server public User[] Users(Predicate p) { List l = new List(); + + // Get changed users foreach (var entry in changeList) if (p(entry)) l.Add(entry); + // Get loaded users foreach(var entry in loadedUsers) if (!l.Contains(entry) && p(entry)) l.Add(entry); - /* - using (var reader = XmlReader.Create(DatabaseName)) - { - if (!Traverse(reader, MasterEntry)) return null; - - while (((reader.NodeType==XmlNodeType.Element && reader.Name.Equals("User")) || SkipSpaces(reader)) && reader.NodeType != XmlNodeType.EndElement) - { - if (reader.NodeType == XmlNodeType.EndElement) break; - User e = User.Parse(ReadEntry(reader), this); - if (e!=null && !l.Contains(e = FromEncoded(e)) && p(e)) l.Add(e); - } - } - */ - + // Get from database using (var reader = XmlReader.Create(DatabaseName)) { if (!Traverse(reader, MasterEntry)) return null; @@ -355,6 +345,15 @@ namespace Server } } + // Remove users scheduled for eviction + foreach(var user in toRemove) + for(int i = l.Count - 1; i>=0; --i) + if (l[i].Name.Equals(user.Name)) + { + l.RemoveAt(i); + i = -1; + } + return l.ToArray(); }