Check for the 4096 limitation in dynamic region hyperlinks.

0.6.3-post-fixes
diva 2009-02-01 00:59:42 +00:00
parent 1a14066aa6
commit ff149ae197
1 changed files with 43 additions and 6 deletions

View File

@ -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<RegionInfo> regionInfos)
private void TryLinkRegion(IClientAPI client, string mapName, List<RegionInfo> 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;
}
if (!Check4096(client, regInfo))
{
return false;
}
m_log.Debug("[HGrid] Dynamic link region succeeded");
return true;
}
/// <summary>
/// Cope with this viewer limitation.
/// </summary>
/// <param name="regInfo"></param>
/// <returns></returns>
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;
}
}
}
}