Hypergrid map search back on, this time with a config var in the grid service.

slimupdates
Diva Canto 2010-01-24 16:00:28 -08:00
parent ea3d287f70
commit 8ddf787cfd
3 changed files with 39 additions and 22 deletions

View File

@ -54,6 +54,7 @@ namespace OpenSim.Services.GridService
protected IAuthenticationService m_AuthenticationService = null; protected IAuthenticationService m_AuthenticationService = null;
protected bool m_AllowDuplicateNames = false; protected bool m_AllowDuplicateNames = false;
protected bool m_AllowHypergridMapSearch = false;
public GridService(IConfigSource config) public GridService(IConfigSource config)
: base(config) : base(config)
@ -74,6 +75,7 @@ namespace OpenSim.Services.GridService
m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args);
} }
m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch);
} }
if (m_RootInstance == null) if (m_RootInstance == null)
@ -327,6 +329,13 @@ namespace OpenSim.Services.GridService
} }
} }
if (m_AllowHypergridMapSearch && rdatas.Count == 0 && name.Contains("."))
{
GridRegion r = m_HypergridLinker.LinkRegion(scopeID, name);
if (r != null)
rinfos.Add(r);
}
return rinfos; return rinfos;
} }
@ -410,9 +419,14 @@ namespace OpenSim.Services.GridService
{ {
RegionData region = m_Database.Get(regionID, scopeID); RegionData region = m_Database.Get(regionID, scopeID);
int flags = Convert.ToInt32(region.Data["flags"]); if (region != null)
//m_log.DebugFormat("[GRID SERVICE]: Request for flags of {0}: {1}", regionID, flags); {
return flags; int flags = Convert.ToInt32(region.Data["flags"]);
//m_log.DebugFormat("[GRID SERVICE]: Request for flags of {0}: {1}", regionID, flags);
return flags;
}
else
return -1;
} }
private void HandleShowRegion(string module, string[] cmd) private void HandleShowRegion(string module, string[] cmd)

View File

@ -130,26 +130,17 @@ namespace OpenSim.Services.GridService
#region Link Region #region Link Region
public bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason) public GridRegion LinkRegion(UUID scopeID, string regionDescriptor)
{ {
regionID = UUID.Zero; string reason = string.Empty;
imageURL = string.Empty;
regionHandle = 0;
reason = string.Empty;
int xloc = random.Next(0, Int16.MaxValue) * (int)Constants.RegionSize; int xloc = random.Next(0, Int16.MaxValue) * (int)Constants.RegionSize;
GridRegion region = TryLinkRegionToCoords(regionDescriptor, xloc, 0, out reason); return TryLinkRegionToCoords(scopeID, regionDescriptor, xloc, 0, out reason);
if (region == null)
return false;
regionID = region.RegionID;
regionHandle = region.RegionHandle;
return true;
} }
private static Random random = new Random(); private static Random random = new Random();
// From the command line link-region // From the command line link-region
public GridRegion TryLinkRegionToCoords(string mapName, int xloc, int yloc, out string reason) public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason)
{ {
reason = string.Empty; reason = string.Empty;
string host = "127.0.0.1"; string host = "127.0.0.1";
@ -183,7 +174,7 @@ namespace OpenSim.Services.GridService
catch { } catch { }
GridRegion regInfo; GridRegion regInfo;
bool success = TryCreateLink(xloc, yloc, regionName, port, host, out regInfo, out reason); bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, out regInfo, out reason);
if (success) if (success)
{ {
regInfo.RegionName = mapName; regInfo.RegionName = mapName;
@ -195,7 +186,7 @@ namespace OpenSim.Services.GridService
// From the command line and the 2 above // From the command line and the 2 above
public bool TryCreateLink(int xloc, int yloc, public bool TryCreateLink(UUID scopeID, int xloc, int yloc,
string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo, out string reason) string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo, out string reason)
{ {
m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
@ -207,6 +198,7 @@ namespace OpenSim.Services.GridService
regInfo.ExternalHostName = externalHostName; regInfo.ExternalHostName = externalHostName;
regInfo.RegionLocX = xloc; regInfo.RegionLocX = xloc;
regInfo.RegionLocY = yloc; regInfo.RegionLocY = yloc;
regInfo.ScopeID = scopeID;
try try
{ {
@ -228,7 +220,16 @@ namespace OpenSim.Services.GridService
if (regionID != UUID.Zero) if (regionID != UUID.Zero)
{ {
GridRegion r = m_GridService.GetRegionByUUID(scopeID, regionID);
if (r != null)
{
m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize);
regInfo = r;
return true;
}
regInfo.RegionID = regionID; regInfo.RegionID = regionID;
regInfo.RegionName = regInfo.ExternalHostName + ":" + regInfo.HttpPort + ":" + regInfo.RegionName;
// Try get the map image // Try get the map image
regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL); regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL);
// I need a texture that works for this... the one I tried doesn't seem to be working // I need a texture that works for this... the one I tried doesn't seem to be working
@ -451,9 +452,9 @@ namespace OpenSim.Services.GridService
xloc = xloc * (int)Constants.RegionSize; xloc = xloc * (int)Constants.RegionSize;
yloc = yloc * (int)Constants.RegionSize; yloc = yloc * (int)Constants.RegionSize;
string reason = string.Empty; string reason = string.Empty;
if (TryLinkRegionToCoords(mapName, xloc, yloc, out reason) == null) if (TryLinkRegionToCoords(UUID.Zero, mapName, xloc, yloc, out reason) == null)
MainConsole.Instance.Output("Failed to link region: " + reason); MainConsole.Instance.Output("Failed to link region: " + reason);
MainConsole.Instance.Output("Hyperlink estalished"); MainConsole.Instance.Output("Hyperlink established");
} }
else else
{ {
@ -482,7 +483,7 @@ namespace OpenSim.Services.GridService
xloc = xloc * (int)Constants.RegionSize; xloc = xloc * (int)Constants.RegionSize;
yloc = yloc * (int)Constants.RegionSize; yloc = yloc * (int)Constants.RegionSize;
string reason = string.Empty; string reason = string.Empty;
if (TryCreateLink(xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason)) if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason))
{ {
if (cmdparams.Length >= 5) if (cmdparams.Length >= 5)
{ {
@ -584,7 +585,7 @@ namespace OpenSim.Services.GridService
xloc = xloc * (int)Constants.RegionSize; xloc = xloc * (int)Constants.RegionSize;
yloc = yloc * (int)Constants.RegionSize; yloc = yloc * (int)Constants.RegionSize;
string reason = string.Empty; string reason = string.Empty;
if (TryCreateLink(xloc, yloc, "", externalPort, if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort,
externalHostName, out regInfo, out reason)) externalHostName, out regInfo, out reason))
{ {
regInfo.RegionName = config.GetString("localName", ""); regInfo.RegionName = config.GetString("localName", "");

View File

@ -70,6 +70,8 @@
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
Realm = "regions" Realm = "regions"
AllowHypergridMapSearch = true
[HypergridService] [HypergridService]
GridService = "OpenSim.Services.GridService.dll:GridService" GridService = "OpenSim.Services.GridService.dll:GridService"
AssetService = "OpenSim.Services.AssetService.dll:AssetService" AssetService = "OpenSim.Services.AssetService.dll:AssetService"