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)
0.6.0-stable
Teravus Ovares 2008-10-06 04:29:48 +00:00
parent b55c9761b4
commit 78073fa440
1 changed files with 66 additions and 22 deletions

View File

@ -248,32 +248,76 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags,
uint EstateID, bool godlike, uint itemtype, ulong regionhandle) 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) if (itemtype == 6) // we only sevice 6 right now (avatar green dots)
{ {
RegionInfo mreg = m_scene.SceneGridService.RequestNeighbouringRegionInfo(regionhandle); if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
if (mreg != null)
{ {
string httpserver = "http://" + mreg.ExternalEndPoint.Address.ToString() + ":" + mreg.HttpPort + "/MAP/MapItems/" + regionhandle.ToString(); List<ScenePresence> avatars = m_scene.GetAvatars();
List<mapItemReply> returnitems = new List<mapItemReply>(); int tc = System.Environment.TickCount;
LLSDMap ramap = RequestMapItems(httpserver); List<mapItemReply> mapitems = new List<mapItemReply>();
if (ramap.ContainsKey(itemtype.ToString())) mapItemReply mapitem = new mapItemReply();
if (avatars.Count == 0 || avatars.Count == 1)
{ {
LLSDArray itemarray = (LLSDArray)ramap[itemtype.ToString()]; mapitem = new mapItemReply();
for (int i = 0; i < itemarray.Count; i++) mapitem.x = (uint)(xstart + 1);
{ mapitem.y = (uint)(ystart + 1);
LLSDMap mapitem = (LLSDMap)itemarray[i]; mapitem.id = UUID.Zero;
mapItemReply mi = new mapItemReply(); mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString());
mi.x = (uint)mapitem["X"].AsInteger(); mapitem.Extra = 0;
mi.y = (uint)mapitem["Y"].AsInteger(); mapitem.Extra2 = 0;
mi.id = mapitem["ID"].AsUUID(); mapitems.Add(mapitem);
mi.Extra = mapitem["Extra"].AsInteger(); }
mi.Extra2 = mapitem["Extra2"].AsInteger(); else
mi.name = mapitem["Name"].AsString(); {
returnitems.Add(mi);
} foreach (ScenePresence av in avatars)
{
// 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<mapItemReply> returnitems = new List<mapItemReply>();
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);
} }
} }