HGWorldMap: don't send map blocks of hyperlinks that are farther than 4096 cells from the current region.

0.7.1-dev
Diva Canto 2011-05-30 17:19:46 -07:00
parent e5eb4c47e0
commit 5dfc62644b
2 changed files with 28 additions and 5 deletions

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
@ -58,7 +59,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid
#endregion
protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
protected override List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
{
List<MapBlockData> mapBlocks = new List<MapBlockData>();
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
@ -67,9 +68,26 @@ namespace OpenSim.Region.CoreModules.Hypergrid
foreach (GridRegion r in regions)
{
MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r);
mapBlocks.Add(block);
uint x = 0, y = 0;
long handle = 0;
if (r.RegionSecret != null && r.RegionSecret != string.Empty)
{
if (long.TryParse(r.RegionSecret, out handle))
{
Utils.LongToUInts((ulong)handle, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
}
}
if (handle == 0 ||
// Check the distance from the current region
(handle != 0 && Math.Abs((int)(x - m_scene.RegionInfo.RegionLocX)) < 4096 && Math.Abs((int)(y - m_scene.RegionInfo.RegionLocY)) < 4096))
{
MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, r);
mapBlocks.Add(block);
}
}
// Different from super
@ -77,6 +95,8 @@ namespace OpenSim.Region.CoreModules.Hypergrid
//
remoteClient.SendMapBlock(mapBlocks, 0);
return mapBlocks;
}

View File

@ -363,11 +363,14 @@ namespace OpenSim.Services.GridService
else
regInfo.RegionName = externalName;
m_log.Debug("[HYPERGRID LINKER]: naming linked region " + regInfo.RegionName);
m_log.DebugFormat("[HYPERGRID LINKER]: naming linked region {0}, handle {1}", regInfo.RegionName, handle.ToString());
// Get the map image
regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL, m_MapTileDirectory);
// Store the origin's coordinates somewhere
regInfo.RegionSecret = handle.ToString();
AddHyperlinkRegion(regInfo, handle);
m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} with image {1}", regInfo.RegionName, regInfo.TerrainImage);
return true;