Merge branch 'master' of /var/git/opensim/

viewer-2-initial-appearance
opensim mirror account 2010-10-28 17:40:06 -07:00
commit 8b867ba23e
2 changed files with 28 additions and 20 deletions

View File

@ -27,6 +27,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using System.Xml; using System.Xml;
@ -153,6 +154,11 @@ namespace OpenSim.Services.GridService
// From the command line link-region // From the command line link-region
public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason) 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; reason = string.Empty;
string host = "127.0.0.1"; string host = "127.0.0.1";
@ -189,7 +195,7 @@ namespace OpenSim.Services.GridService
//} //}
GridRegion regInfo; 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) if (success)
{ {
regInfo.RegionName = mapName; regInfo.RegionName = mapName;
@ -202,7 +208,8 @@ namespace OpenSim.Services.GridService
// From the command line and the 2 above // From the command line and the 2 above
public bool TryCreateLink(UUID scopeID, 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, 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); m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}:{2}, in {3}-{4}", externalHostName, externalPort, externalRegionName, xloc, yloc);
@ -214,12 +221,22 @@ namespace OpenSim.Services.GridService
regInfo.RegionLocX = xloc; regInfo.RegionLocX = xloc;
regInfo.RegionLocY = yloc; regInfo.RegionLocY = yloc;
regInfo.ScopeID = scopeID; regInfo.ScopeID = scopeID;
regInfo.EstateOwner = ownerID;
// Big HACK for Simian Grid !!! // Big HACK for Simian Grid !!!
// We need to clean up all URLs used in OpenSim !!! // We need to clean up all URLs used in OpenSim !!!
if (externalHostName.Contains("/")) if (externalHostName.Contains("/"))
regInfo.ServerURI = externalHostName; 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 try
{ {
regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
@ -241,11 +258,11 @@ namespace OpenSim.Services.GridService
if (regionID != UUID.Zero) if (regionID != UUID.Zero)
{ {
GridRegion r = m_GridService.GetRegionByUUID(scopeID, regionID); region = m_GridService.GetRegionByUUID(scopeID, regionID);
if (r != null) if (region != null)
{ {
m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize);
regInfo = r; regInfo = region;
return true; return true;
} }
@ -355,17 +372,8 @@ namespace OpenSim.Services.GridService
{ {
// Check for regions which are not linked regions // Check for regions which are not linked regions
List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID);
// would like to use .Except, but doesn't seem to exist IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks);
//IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks); if (availableRegions.Count() == 0)
List<GridRegion> 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)
return false; return false;
} }
@ -529,7 +537,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(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) if (cmdparams.Length >= 5)
{ {
@ -631,8 +639,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(UUID.Zero, xloc, yloc, "", externalPort, if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
externalHostName, out regInfo, out reason))
{ {
regInfo.RegionName = config.GetString("localName", ""); regInfo.RegionName = config.GetString("localName", "");
} }

View File

@ -1084,6 +1084,7 @@
<ReferencePath>../../../bin/</ReferencePath> <ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/> <Reference name="System"/>
<Reference name="System.Core"/>
<Reference name="System.Xml"/> <Reference name="System.Xml"/>
<Reference name="OpenMetaverseTypes" path="../../../bin/"/> <Reference name="OpenMetaverseTypes" path="../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../bin/"/> <Reference name="OpenMetaverse" path="../../../bin/"/>