mantis 8598: filter dead groups from group search. honor querystart request. Viewers are very broken on this, seems protocol was made by someone with no idea about lludp
parent
2c1909a873
commit
0273baaef6
|
@ -230,15 +230,22 @@ namespace OpenSim.Groups
|
||||||
if (d.Data.ContainsKey("Location") && d.Data["Location"] != string.Empty)
|
if (d.Data.ContainsKey("Location") && d.Data["Location"] != string.Empty)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
int nmembers = m_Database.MemberCount(d.GroupID);
|
||||||
|
if(nmembers == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
DirGroupsReplyData g = new DirGroupsReplyData();
|
DirGroupsReplyData g = new DirGroupsReplyData();
|
||||||
g.groupID = d.GroupID;
|
|
||||||
|
|
||||||
if (d.Data.ContainsKey("Name"))
|
if (d.Data.ContainsKey("Name"))
|
||||||
g.groupName = d.Data["Name"];
|
g.groupName = d.Data["Name"];
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_log.DebugFormat("[Groups]: Key Name not found");
|
m_log.DebugFormat("[Groups]: Key Name not found");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
g.members = m_Database.MemberCount(d.GroupID);
|
g.groupID = d.GroupID;
|
||||||
|
g.members = nmembers;
|
||||||
|
|
||||||
groups.Add(g);
|
groups.Add(g);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3850,19 +3850,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
|
packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
|
||||||
packet.QueryData.QueryID = queryID;
|
packet.QueryData.QueryID = queryID;
|
||||||
|
|
||||||
packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[
|
packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[data.Length];
|
||||||
data.Length];
|
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (DirGroupsReplyData d in data)
|
foreach (DirGroupsReplyData d in data)
|
||||||
{
|
{
|
||||||
packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
|
packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
|
||||||
packet.QueryReplies[i].GroupID = d.groupID;
|
packet.QueryReplies[i].GroupID = d.groupID;
|
||||||
packet.QueryReplies[i].GroupName =
|
packet.QueryReplies[i].GroupName = Util.StringToBytes(d.groupName, 35);
|
||||||
Utils.StringToBytes(d.groupName);
|
|
||||||
packet.QueryReplies[i].Members = d.members;
|
packet.QueryReplies[i].Members = d.members;
|
||||||
packet.QueryReplies[i].SearchOrder = d.searchOrder;
|
packet.QueryReplies[i].SearchOrder = d.searchOrder;
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutPacket(packet, ThrottleOutPacketType.Task);
|
OutPacket(packet, ThrottleOutPacketType.Task);
|
||||||
|
|
|
@ -186,10 +186,35 @@ namespace OpenSim.Region.CoreModules.Framework.Search
|
||||||
if (string.IsNullOrEmpty(queryText))
|
if (string.IsNullOrEmpty(queryText))
|
||||||
remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]);
|
remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]);
|
||||||
|
|
||||||
// TODO: This currently ignores pretty much all the query flags including Mature and sort order
|
List<DirGroupsReplyData> answer = m_GroupsService.FindGroups(remoteClient, queryText);
|
||||||
remoteClient.SendDirGroupsReply(queryID, m_GroupsService.FindGroups(remoteClient, queryText).ToArray());
|
if(answer.Count == 0)
|
||||||
}
|
{
|
||||||
|
remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// filter out groups with no members
|
||||||
|
DirGroupsReplyData[] result = new DirGroupsReplyData[answer.Count];
|
||||||
|
int count = 0;
|
||||||
|
foreach(DirGroupsReplyData dgrd in answer)
|
||||||
|
{
|
||||||
|
if(dgrd.members > 0)
|
||||||
|
result[count++] = dgrd;
|
||||||
|
}
|
||||||
|
answer = null;
|
||||||
|
|
||||||
|
// viewers don't sent sorting, so results they show are a nice mess
|
||||||
|
if ((queryStart > 0) && (queryStart < count))
|
||||||
|
{
|
||||||
|
int len = count - queryStart;
|
||||||
|
DirGroupsReplyData[] tmp = new DirGroupsReplyData[len];
|
||||||
|
Array.Copy(result, queryStart, tmp, 0, len);
|
||||||
|
result = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: This currently ignores pretty much all the query flags including Mature and sort order
|
||||||
|
remoteClient.SendDirGroupsReply(queryID, result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Event Handlers
|
#endregion Event Handlers
|
||||||
|
|
Loading…
Reference in New Issue