merge issues and a few more changes

avinationmerge
UbitUmarov 2015-09-17 05:10:24 +01:00
parent 133f3a41eb
commit f6c2e6e1a3
1 changed files with 116 additions and 152 deletions

View File

@ -334,10 +334,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
protected static OSDMapLayer GetOSDMapLayerResponse() protected static OSDMapLayer GetOSDMapLayerResponse()
{ {
OSDMapLayer mapLayer = new OSDMapLayer(); OSDMapLayer mapLayer = new OSDMapLayer();
// mapLayer.Right = 2048; mapLayer.Right = 2048;
mapLayer.Right = 5000; mapLayer.Top = 2048;
// mapLayer.Top = 2048;
mapLayer.Top = 5000;
mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006");
return mapLayer; return mapLayer;
@ -447,18 +445,33 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
if (!m_rootAgents.Contains(remoteClient.AgentId)) if (!m_rootAgents.Contains(remoteClient.AgentId))
return; return;
} }
// local or remote request?
if (regionhandle != 0 && regionhandle != m_scene.RegionInfo.RegionHandle)
{
// its Remote Map Item Request
// ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes.
RequestMapItems("", remoteClient.AgentId, flags, EstateID, godlike, itemtype, regionhandle);
return;
}
uint xstart = 0; uint xstart = 0;
uint ystart = 0; uint ystart = 0;
Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle, out xstart, out ystart); Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle, out xstart, out ystart);
if (itemtype == (int)GridItemType.AgentLocations) // Service 6 right now (MAP_ITEM_AGENTS_LOCATION; green dots) // its about this region...
{
if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
{
// Just requesting map info about the current, local region
int tc = Environment.TickCount;
List<mapItemReply> mapitems = new List<mapItemReply>(); List<mapItemReply> mapitems = new List<mapItemReply>();
mapItemReply mapitem = new mapItemReply(); mapItemReply mapitem = new mapItemReply();
bool adultRegion;
switch (itemtype)
{
case (int)GridItemType.AgentLocations:
// Service 6 right now (MAP_ITEM_AGENTS_LOCATION; green dots)
int tc = Environment.TickCount;
if (m_scene.GetRootAgentCount() <= 1) if (m_scene.GetRootAgentCount() <= 1)
{ {
mapitem = new mapItemReply( mapitem = new mapItemReply(
@ -471,7 +484,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
} }
else else
{ {
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) m_scene.ForEachRootScenePresence(delegate (ScenePresence sp)
{ {
// Don't send a green dot for yourself // Don't send a green dot for yourself
if (sp.UUID != remoteClient.AgentId) if (sp.UUID != remoteClient.AgentId)
@ -487,26 +500,29 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
}); });
} }
remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
break;
case (int)GridItemType.AdultLandForSale:
case (int)GridItemType.LandForSale:
// Service 7 (MAP_ITEM_LAND_FOR_SALE)
adultRegion = m_scene.RegionInfo.RegionSettings.Maturity == 2;
if(adultRegion)
{
if (itemtype == (int)GridItemType.LandForSale)
break;
} }
else else
{ {
// Remote Map Item Request if (itemtype == (int)GridItemType.AdultLandForSale)
break;
}
// ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes.
RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle);
}
}
else if (itemtype == (int)GridItemType.LandForSale) // Service 7 (MAP_ITEM_LAND_FOR_SALE)
{
if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
{
// Parcels // Parcels
ILandChannel landChannel = m_scene.LandChannel; ILandChannel landChannel = m_scene.LandChannel;
List<ILandObject> parcels = landChannel.AllParcels(); List<ILandObject> parcels = landChannel.AllParcels();
// Local Map Item Request
List<mapItemReply> mapitems = new List<mapItemReply>();
mapItemReply mapitem = new mapItemReply();
if ((parcels != null) && (parcels.Count >= 1)) if ((parcels != null) && (parcels.Count >= 1))
{ {
foreach (ILandObject parcel_interface in parcels) foreach (ILandObject parcel_interface in parcels)
@ -523,8 +539,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
{ {
Vector3 min = parcel.AABBMin; Vector3 min = parcel.AABBMin;
Vector3 max = parcel.AABBMax; Vector3 max = parcel.AABBMax;
float x = (min.X+max.X)/2; float x = (min.X + max.X) / 2;
float y = (min.Y+max.Y)/2; float y = (min.Y + max.Y) / 2;
mapitem = new mapItemReply( mapitem = new mapItemReply(
xstart + (uint)x, xstart + (uint)x,
ystart + (uint)y, ystart + (uint)y,
@ -538,21 +554,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
} }
} }
remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
} break;
else
{
// Remote Map Item Request
// ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. case (int)GridItemType.Telehub:
RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); // Service 1 (MAP_ITEM_TELEHUB)
}
}
else if (itemtype == (int)GridItemType.Telehub) // Service 1 (MAP_ITEM_TELEHUB)
{
if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
{
List<mapItemReply> mapitems = new List<mapItemReply>();
mapItemReply mapitem = new mapItemReply();
SceneObjectGroup sog = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject); SceneObjectGroup sog = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject);
if (sog != null) if (sog != null)
@ -569,12 +574,21 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
} }
} break;
else
{ case (uint)GridItemType.PgEvent:
// Remote Map Item Request case (uint)GridItemType.MatureEvent:
RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); case (uint)GridItemType.AdultEvent:
} case (uint)GridItemType.Classified:
case (uint)GridItemType.Popular:
// TODO
// just dont not cry about them
break;
default:
// unkown map item type
m_log.DebugFormat("[WORLD MAP]: Unknown MapItem type {1}", itemtype);
break;
} }
} }
@ -838,21 +852,24 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
string response_mapItems_reply = null; string response_mapItems_reply = null;
{ // get the response { // get the response
StreamReader sr = null;
try try
{ {
WebResponse webResponse = mapitemsrequest.GetResponse(); using (WebResponse webResponse = mapitemsrequest.GetResponse())
{
if (webResponse != null) if (webResponse != null)
{ {
sr = new StreamReader(webResponse.GetResponseStream()); using (StreamReader sr = new StreamReader(webResponse.GetResponseStream()))
{
response_mapItems_reply = sr.ReadToEnd().Trim(); response_mapItems_reply = sr.ReadToEnd().Trim();
} }
}
else else
{ {
Interlocked.Decrement(ref nAsyncRequests); Interlocked.Decrement(ref nAsyncRequests);
return; return;
} }
} }
}
catch (WebException) catch (WebException)
{ {
lock (m_blacklistedurls) lock (m_blacklistedurls)
@ -878,11 +895,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
Interlocked.Decrement(ref nAsyncRequests); Interlocked.Decrement(ref nAsyncRequests);
return; return;
} }
finally
{
if (sr != null)
sr.Close();
}
OSD rezResponse = null; OSD rezResponse = null;
try try
@ -918,6 +930,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
Interlocked.Decrement(ref nAsyncRequests); Interlocked.Decrement(ref nAsyncRequests);
flags &= 0xffff;
if (id != UUID.Zero) if (id != UUID.Zero)
{ {
ScenePresence av = null; ScenePresence av = null;
@ -943,6 +957,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
} }
/* send things viewer didn't ask ?
// Service 7 (MAP_ITEM_LAND_FOR_SALE) // Service 7 (MAP_ITEM_LAND_FOR_SALE)
itemtype = 7; itemtype = 7;
@ -986,6 +1001,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
} }
av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
} }
*/
} }
} }
} }
@ -1000,63 +1016,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
{ {
m_log.DebugFormat("[WoldMapModule] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag); m_log.DebugFormat("[WoldMapModule] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag);
/* this flag does not seem to mean what his says
if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible
{
List<MapBlockData> response = new List<MapBlockData>();
// this should return one mapblock at most. It is triggered by a click
// on an unloaded square.
// But make sure: Look whether the one we requested is in there
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
(int)Util.RegionToWorldLoc((uint)minX),
(int)Util.RegionToWorldLoc((uint)maxX),
(int)Util.RegionToWorldLoc((uint)minY),
(int)Util.RegionToWorldLoc((uint)maxY) );
if (regions != null)
{
foreach (GridRegion r in regions)
{
if (r.RegionLocX == Util.RegionToWorldLoc((uint)minX) &&
r.RegionLocY == Util.RegionToWorldLoc((uint)minY))
{
// found it => add it to response
MapBlockData block = new MapBlockData();
if ((flag & 2) == 2)
response.AddRange(Map2BlockFromGridRegion(r, flag));
else
{
MapBlockFromGridRegion(block, r, flag);
response.Add(block);
}
break;
}
}
}
if (response.Count == 0)
{
// response still empty => couldn't find the map-tile the user clicked on => tell the client
MapBlockData block = new MapBlockData();
block.X = (ushort)minX;
block.Y = (ushort)minY;
block.Access = (byte)SimAccess.Down; // means 'simulator is offline'
<<<<<<< HEAD
// block.Access = (byte)SimAccess.NonExistent;
=======
>>>>>>> avn/ubitvar
response.Add(block);
}
// The lower 16 bits are an unsigned int16
remoteClient.SendMapBlock(response, flag & 0xffff);
}
else
{
// normal mapblock request. Use the provided values
*/
GetAndSendBlocks(remoteClient, minX, minY, maxX, maxY, flag); GetAndSendBlocks(remoteClient, minX, minY, maxX, maxY, flag);
// }
} }
protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
@ -1125,13 +1086,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
maxX * (int)Constants.RegionSize, maxX * (int)Constants.RegionSize,
minY * (int)Constants.RegionSize, minY * (int)Constants.RegionSize,
maxY * (int)Constants.RegionSize); maxY * (int)Constants.RegionSize);
// (minX - 4) * (int)Constants.RegionSize,
// (maxX + 4) * (int)Constants.RegionSize,
// (minY - 4) * (int)Constants.RegionSize,
// (maxY + 4) * (int)Constants.RegionSize);
//mb it means this // only send a negative answer for a single region request
if(regions.Count == 0 && (flag & 0x10000) != 0) // corresponding to a click on the map. Current viewers
// keep displaying "loading.." without this
if(regions.Count == 0 && (flag & 0x10000) != 0 && minX == maxX && minY == maxY)
{ {
MapBlockData block = new MapBlockData(); MapBlockData block = new MapBlockData();
block.X = (ushort)minX; block.X = (ushort)minX;
@ -1144,8 +1103,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
return allBlocks; return allBlocks;
} }
flag &= 0xffff;
foreach (GridRegion r in regions) foreach (GridRegion r in regions)
{ {
if (r == null)
continue;
MapBlockData block = new MapBlockData(); MapBlockData block = new MapBlockData();
if ((flag & 2) == 2) if ((flag & 2) == 2)
{ {
@ -1159,15 +1122,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
mapBlocks.Add(block); mapBlocks.Add(block);
allBlocks.Add(block); allBlocks.Add(block);
} }
if (mapBlocks.Count >= 10) if (mapBlocks.Count >= 10)
{ {
remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); remoteClient.SendMapBlock(mapBlocks, flag);
mapBlocks.Clear(); mapBlocks.Clear();
Thread.Sleep(50); Thread.Sleep(50);
} }
} }
if (mapBlocks.Count > 0) if (mapBlocks.Count > 0)
remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); remoteClient.SendMapBlock(mapBlocks, flag);
return allBlocks; return allBlocks;
} }
@ -1175,7 +1139,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
public void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) public void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag)
{ {
block.Access = r.Access; block.Access = r.Access;
switch (flag & 0xffff) switch (flag)
{ {
case 0: case 0:
block.MapImageId = r.TerrainImage; block.MapImageId = r.TerrainImage;