diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 3d722eca96..d7f1f7bfea 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Net; using System.Reflection; using System.Xml; @@ -153,6 +154,11 @@ namespace OpenSim.Services.GridService // From the command line link-region public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason) + { + return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); + } + + public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) { reason = string.Empty; string host = "127.0.0.1"; @@ -191,7 +197,7 @@ namespace OpenSim.Services.GridService } GridRegion regInfo; - bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, out regInfo, out reason); + bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason); if (success) { regInfo.RegionName = mapName; @@ -204,7 +210,8 @@ namespace OpenSim.Services.GridService // From the command line and the 2 above 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, UUID ownerID, + out GridRegion regInfo, out string reason) { m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}:{2}, in {3}-{4}", externalHostName, externalPort, externalRegionName, xloc, yloc); @@ -216,6 +223,21 @@ namespace OpenSim.Services.GridService regInfo.RegionLocX = xloc; regInfo.RegionLocY = yloc; regInfo.ScopeID = scopeID; + regInfo.EstateOwner = ownerID; + + // Big HACK for Simian Grid !!! + // We need to clean up all URLs used in OpenSim !!! + if (externalHostName.Contains("/")) + regInfo.ServerURI = externalHostName; + + // Check for free coordinates + GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY); + if (region != null) + { + m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}", regInfo.RegionLocX, regInfo.RegionLocY, region.RegionName, region.RegionID); + reason = "Coordinates are already in use"; + return false; + } try { @@ -238,11 +260,11 @@ namespace OpenSim.Services.GridService if (regionID != UUID.Zero) { - GridRegion r = m_GridService.GetRegionByUUID(scopeID, regionID); - if (r != null) + region = m_GridService.GetRegionByUUID(scopeID, regionID); + if (region != null) { - m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); - regInfo = r; + m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize); + regInfo = region; return true; } @@ -352,17 +374,8 @@ namespace OpenSim.Services.GridService { // Check for regions which are not linked regions List hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); - // would like to use .Except, but doesn't seem to exist - //IEnumerable availableRegions = regions.Except(hyperlinks); - List availableRegions = regions.FindAll(delegate(GridRegion region) - { - // Ewww! n^2 - if (hyperlinks.Find(delegate(GridRegion r) { return r.RegionID == region.RegionID; }) == null) // not hyperlink. good. - return true; - - return false; - }); - if (availableRegions.Count == 0) + IEnumerable availableRegions = regions.Except(hyperlinks); + if (availableRegions.Count() == 0) return false; } @@ -526,7 +539,7 @@ namespace OpenSim.Services.GridService xloc = xloc * (int)Constants.RegionSize; yloc = yloc * (int)Constants.RegionSize; string reason = string.Empty; - if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason)) + if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) { if (cmdparams.Length >= 5) { @@ -628,8 +641,7 @@ namespace OpenSim.Services.GridService xloc = xloc * (int)Constants.RegionSize; yloc = yloc * (int)Constants.RegionSize; string reason = string.Empty; - if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, - externalHostName, out regInfo, out reason)) + if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) { regInfo.RegionName = config.GetString("localName", ""); } diff --git a/prebuild.xml b/prebuild.xml index 1eb8fee64b..f8301f46a1 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1078,6 +1078,7 @@ ../../../bin/ +