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

0.9.1.0-post-fixes
UbitUmarov 2019-10-13 16:41:38 +01:00
parent 2c1909a873
commit 0273baaef6
3 changed files with 40 additions and 10 deletions

View File

@ -230,15 +230,22 @@ namespace OpenSim.Groups
if (d.Data.ContainsKey("Location") && d.Data["Location"] != string.Empty)
continue;
int nmembers = m_Database.MemberCount(d.GroupID);
if(nmembers == 0)
continue;
DirGroupsReplyData g = new DirGroupsReplyData();
g.groupID = d.GroupID;
if (d.Data.ContainsKey("Name"))
g.groupName = d.Data["Name"];
else
{
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);
}

View File

@ -3850,19 +3850,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
packet.QueryData.QueryID = queryID;
packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[
data.Length];
packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[data.Length];
int i = 0;
foreach (DirGroupsReplyData d in data)
{
packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
packet.QueryReplies[i].GroupID = d.groupID;
packet.QueryReplies[i].GroupName =
Utils.StringToBytes(d.groupName);
packet.QueryReplies[i].GroupName = Util.StringToBytes(d.groupName, 35);
packet.QueryReplies[i].Members = d.members;
packet.QueryReplies[i].SearchOrder = d.searchOrder;
i++;
++i;
}
OutPacket(packet, ThrottleOutPacketType.Task);

View File

@ -186,10 +186,35 @@ namespace OpenSim.Region.CoreModules.Framework.Search
if (string.IsNullOrEmpty(queryText))
remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]);
// TODO: This currently ignores pretty much all the query flags including Mature and sort order
remoteClient.SendDirGroupsReply(queryID, m_GroupsService.FindGroups(remoteClient, queryText).ToArray());
List<DirGroupsReplyData> answer = m_GroupsService.FindGroups(remoteClient, queryText);
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