Fix serverside "list" command
This commit is contained in:
parent
9755f06120
commit
1a04a0b2cb
@ -1,8 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Client.ConsoleForms;
|
using Client.ConsoleForms;
|
||||||
using Client.ConsoleForms.Graphics;
|
using Client.ConsoleForms.Graphics;
|
||||||
|
|
||||||
|
@ -317,28 +317,18 @@ namespace Server
|
|||||||
public User[] Users(Predicate<User> p)
|
public User[] Users(Predicate<User> p)
|
||||||
{
|
{
|
||||||
List<User> l = new List<User>();
|
List<User> l = new List<User>();
|
||||||
|
|
||||||
|
// Get changed users
|
||||||
foreach (var entry in changeList)
|
foreach (var entry in changeList)
|
||||||
if (p(entry))
|
if (p(entry))
|
||||||
l.Add(entry);
|
l.Add(entry);
|
||||||
|
|
||||||
|
// Get loaded users
|
||||||
foreach(var entry in loadedUsers)
|
foreach(var entry in loadedUsers)
|
||||||
if (!l.Contains(entry) && p(entry))
|
if (!l.Contains(entry) && p(entry))
|
||||||
l.Add(entry);
|
l.Add(entry);
|
||||||
|
|
||||||
/*
|
// Get from database
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
using (var reader = XmlReader.Create(DatabaseName))
|
using (var reader = XmlReader.Create(DatabaseName))
|
||||||
{
|
{
|
||||||
if (!Traverse(reader, MasterEntry)) return null;
|
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();
|
return l.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user