From 78073fa440a57335ddfe2a2df54f82598c966255 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 6 Oct 2008 04:29:48 +0000 Subject: MapItems/Green Dots * Fixes 1 too large count in region you're in (Region no longer reports the green dot about yourself to you) * For all local requests, the region will check itself instead of going to it's web service. (optimization) --- .../Modules/World/WorldMap/WorldMapModule.cs | 82 +++++++++++++++++----- 1 file changed, 63 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs index 8091c59..d40574a 100644 --- a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs @@ -248,32 +248,76 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, uint EstateID, bool godlike, uint itemtype, ulong regionhandle) { + uint xstart = 0; + uint ystart = 0; + Helpers.LongToUInts(m_scene.RegionInfo.RegionHandle, out xstart, out ystart); if (itemtype == 6) // we only sevice 6 right now (avatar green dots) { - RegionInfo mreg = m_scene.SceneGridService.RequestNeighbouringRegionInfo(regionhandle); - if (mreg != null) - { - string httpserver = "http://" + mreg.ExternalEndPoint.Address.ToString() + ":" + mreg.HttpPort + "/MAP/MapItems/" + regionhandle.ToString(); - List returnitems = new List(); - LLSDMap ramap = RequestMapItems(httpserver); - if (ramap.ContainsKey(itemtype.ToString())) + if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) + { + List avatars = m_scene.GetAvatars(); + int tc = System.Environment.TickCount; + List mapitems = new List(); + mapItemReply mapitem = new mapItemReply(); + if (avatars.Count == 0 || avatars.Count == 1) + { + mapitem = new mapItemReply(); + mapitem.x = (uint)(xstart + 1); + mapitem.y = (uint)(ystart + 1); + mapitem.id = UUID.Zero; + mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()); + mapitem.Extra = 0; + mapitem.Extra2 = 0; + mapitems.Add(mapitem); + } + else { - LLSDArray itemarray = (LLSDArray)ramap[itemtype.ToString()]; - for (int i = 0; i < itemarray.Count; i++) + + foreach (ScenePresence av in avatars) { - LLSDMap mapitem = (LLSDMap)itemarray[i]; - mapItemReply mi = new mapItemReply(); - mi.x = (uint)mapitem["X"].AsInteger(); - mi.y = (uint)mapitem["Y"].AsInteger(); - mi.id = mapitem["ID"].AsUUID(); - mi.Extra = mapitem["Extra"].AsInteger(); - mi.Extra2 = mapitem["Extra2"].AsInteger(); - mi.name = mapitem["Name"].AsString(); - returnitems.Add(mi); + // Don't send a green dot for yourself + if (av.UUID != remoteClient.AgentId) + { + mapitem = new mapItemReply(); + mapitem.x = (uint)(xstart + av.AbsolutePosition.X); + mapitem.y = (uint)(ystart + av.AbsolutePosition.Y); + mapitem.id = UUID.Zero; + mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()); + mapitem.Extra = 1; + mapitem.Extra2 = 0; + mapitems.Add(mapitem); + } } + } + remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); + } + else + { + RegionInfo mreg = m_scene.SceneGridService.RequestNeighbouringRegionInfo(regionhandle); + if (mreg != null) + { + string httpserver = "http://" + mreg.ExternalEndPoint.Address.ToString() + ":" + mreg.HttpPort + "/MAP/MapItems/" + regionhandle.ToString(); + List returnitems = new List(); + LLSDMap ramap = RequestMapItems(httpserver); + if (ramap.ContainsKey(itemtype.ToString())) + { + LLSDArray itemarray = (LLSDArray)ramap[itemtype.ToString()]; + for (int i = 0; i < itemarray.Count; i++) + { + LLSDMap mapitem = (LLSDMap)itemarray[i]; + mapItemReply mi = new mapItemReply(); + mi.x = (uint)mapitem["X"].AsInteger(); + mi.y = (uint)mapitem["Y"].AsInteger(); + mi.id = mapitem["ID"].AsUUID(); + mi.Extra = mapitem["Extra"].AsInteger(); + mi.Extra2 = mapitem["Extra2"].AsInteger(); + mi.name = mapitem["Name"].AsString(); + returnitems.Add(mi); + } + } + remoteClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); } - remoteClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); } } -- cgit v1.1