diff --git a/OpenSim/Addons/Groups/Service/GroupsService.cs b/OpenSim/Addons/Groups/Service/GroupsService.cs index 0792a470e3..b5f8ff5494 100644 --- a/OpenSim/Addons/Groups/Service/GroupsService.cs +++ b/OpenSim/Addons/Groups/Service/GroupsService.cs @@ -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); } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 7c2a887604..80ca67bce0 100755 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -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); diff --git a/OpenSim/Region/CoreModules/Framework/Search/BasicSearchModule.cs b/OpenSim/Region/CoreModules/Framework/Search/BasicSearchModule.cs index c04d856ce3..1026eae91d 100644 --- a/OpenSim/Region/CoreModules/Framework/Search/BasicSearchModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Search/BasicSearchModule.cs @@ -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 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