From ff149ae197c1092a9a98ea84a2363fa967490857 Mon Sep 17 00:00:00 2001 From: diva Date: Sun, 1 Feb 2009 00:59:42 +0000 Subject: Check for the 4096 limitation in dynamic region hyperlinks. --- .../Modules/World/WorldMap/MapSearchModule.cs | 49 +++++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs index cb05092..7346d92 100644 --- a/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs @@ -110,7 +110,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap if (mapName.Contains(".") && mapName.Contains(":")) { // It probably is a domain name. Try to link to it. - TryLinkRegion(mapName, regionInfos); + TryLinkRegion(remoteClient, mapName, regionInfos); } } @@ -154,7 +154,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap return (m_scene.SceneGridService is HGSceneCommunicationService); } - private void TryLinkRegion(string mapName, List regionInfos) + private void TryLinkRegion(IClientAPI client, string mapName, List regionInfos) { string host = "127.0.0.1"; string portstr; @@ -183,7 +183,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap { uint xloc = (uint)(random.Next(0, Int16.MaxValue)); RegionInfo regInfo; - bool success = TryCreateLink(xloc, 0, port, host, out regInfo); + bool success = TryCreateLink(client, xloc, 0, port, host, out regInfo); if (success) { regInfo.RegionName = mapName; @@ -192,7 +192,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap } } - private bool TryCreateLink(uint xloc, uint yloc, uint externalPort, string externalHostName, out RegionInfo regInfo) + private bool TryCreateLink(IClientAPI client, uint xloc, uint yloc, uint externalPort, string externalHostName, out RegionInfo regInfo) { m_log.DebugFormat("[HGrid]: Dynamic link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); @@ -219,14 +219,51 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap } catch (Exception e) { - m_log.Warn("[HGrid] Unable to dynamically link region: " + e); + m_log.Warn("[HGrid] Unable to dynamically link region: " + e.Message); return false; } - m_log.Debug("[HGrid] Dynamic link region succeeded"); + if (!Check4096(client, regInfo)) + { + return false; + } + m_log.Debug("[HGrid] Dynamic link region succeeded"); return true; } + /// + /// Cope with this viewer limitation. + /// + /// + /// + private bool Check4096(IClientAPI client, RegionInfo regInfo) + { + ulong realHandle; + if (UInt64.TryParse(regInfo.regionSecret, out realHandle)) + { + uint x, y; + Utils.LongToUInts(realHandle, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + + if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) || + (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096)) + { + m_scene.CommsManager.GridService.RegisterRegion(regInfo); + m_log.Debug("[HGrid]: Region deregistered."); + client.SendAlertMessage("Region is too far (" + x + ", " + y + ")"); + return false; + } + return true; + } + else + { + m_scene.CommsManager.GridService.RegisterRegion(regInfo); + m_log.Debug("[HGrid]: Gnomes. Region deregistered."); + return false; + } + } + } } -- cgit v1.1