aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/GridService/HypergridLinker.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs39
1 files changed, 20 insertions, 19 deletions
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index b0cf723..1289cf6 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -130,26 +130,17 @@ namespace OpenSim.Services.GridService
130 130
131 #region Link Region 131 #region Link Region
132 132
133 public bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason) 133 public GridRegion LinkRegion(UUID scopeID, string regionDescriptor)
134 { 134 {
135 regionID = UUID.Zero; 135 string reason = string.Empty;
136 imageURL = string.Empty;
137 regionHandle = 0;
138 reason = string.Empty;
139 int xloc = random.Next(0, Int16.MaxValue) * (int)Constants.RegionSize; 136 int xloc = random.Next(0, Int16.MaxValue) * (int)Constants.RegionSize;
140 GridRegion region = TryLinkRegionToCoords(regionDescriptor, xloc, 0, out reason); 137 return TryLinkRegionToCoords(scopeID, regionDescriptor, xloc, 0, out reason);
141 if (region == null)
142 return false;
143
144 regionID = region.RegionID;
145 regionHandle = region.RegionHandle;
146 return true;
147 } 138 }
148 139
149 private static Random random = new Random(); 140 private static Random random = new Random();
150 141
151 // From the command line link-region 142 // From the command line link-region
152 public GridRegion TryLinkRegionToCoords(string mapName, int xloc, int yloc, out string reason) 143 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason)
153 { 144 {
154 reason = string.Empty; 145 reason = string.Empty;
155 string host = "127.0.0.1"; 146 string host = "127.0.0.1";
@@ -183,7 +174,7 @@ namespace OpenSim.Services.GridService
183 catch { } 174 catch { }
184 175
185 GridRegion regInfo; 176 GridRegion regInfo;
186 bool success = TryCreateLink(xloc, yloc, regionName, port, host, out regInfo, out reason); 177 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, out regInfo, out reason);
187 if (success) 178 if (success)
188 { 179 {
189 regInfo.RegionName = mapName; 180 regInfo.RegionName = mapName;
@@ -195,7 +186,7 @@ namespace OpenSim.Services.GridService
195 186
196 187
197 // From the command line and the 2 above 188 // From the command line and the 2 above
198 public bool TryCreateLink(int xloc, int yloc, 189 public bool TryCreateLink(UUID scopeID, int xloc, int yloc,
199 string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo, out string reason) 190 string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo, out string reason)
200 { 191 {
201 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); 192 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
@@ -207,6 +198,7 @@ namespace OpenSim.Services.GridService
207 regInfo.ExternalHostName = externalHostName; 198 regInfo.ExternalHostName = externalHostName;
208 regInfo.RegionLocX = xloc; 199 regInfo.RegionLocX = xloc;
209 regInfo.RegionLocY = yloc; 200 regInfo.RegionLocY = yloc;
201 regInfo.ScopeID = scopeID;
210 202
211 try 203 try
212 { 204 {
@@ -228,7 +220,16 @@ namespace OpenSim.Services.GridService
228 220
229 if (regionID != UUID.Zero) 221 if (regionID != UUID.Zero)
230 { 222 {
223 GridRegion r = m_GridService.GetRegionByUUID(scopeID, regionID);
224 if (r != null)
225 {
226 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize);
227 regInfo = r;
228 return true;
229 }
230
231 regInfo.RegionID = regionID; 231 regInfo.RegionID = regionID;
232 regInfo.RegionName = regInfo.ExternalHostName + ":" + regInfo.HttpPort + ":" + regInfo.RegionName;
232 // Try get the map image 233 // Try get the map image
233 regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL); 234 regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL);
234 // I need a texture that works for this... the one I tried doesn't seem to be working 235 // 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
451 xloc = xloc * (int)Constants.RegionSize; 452 xloc = xloc * (int)Constants.RegionSize;
452 yloc = yloc * (int)Constants.RegionSize; 453 yloc = yloc * (int)Constants.RegionSize;
453 string reason = string.Empty; 454 string reason = string.Empty;
454 if (TryLinkRegionToCoords(mapName, xloc, yloc, out reason) == null) 455 if (TryLinkRegionToCoords(UUID.Zero, mapName, xloc, yloc, out reason) == null)
455 MainConsole.Instance.Output("Failed to link region: " + reason); 456 MainConsole.Instance.Output("Failed to link region: " + reason);
456 MainConsole.Instance.Output("Hyperlink estalished"); 457 MainConsole.Instance.Output("Hyperlink established");
457 } 458 }
458 else 459 else
459 { 460 {
@@ -482,7 +483,7 @@ namespace OpenSim.Services.GridService
482 xloc = xloc * (int)Constants.RegionSize; 483 xloc = xloc * (int)Constants.RegionSize;
483 yloc = yloc * (int)Constants.RegionSize; 484 yloc = yloc * (int)Constants.RegionSize;
484 string reason = string.Empty; 485 string reason = string.Empty;
485 if (TryCreateLink(xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason)) 486 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason))
486 { 487 {
487 if (cmdparams.Length >= 5) 488 if (cmdparams.Length >= 5)
488 { 489 {
@@ -584,7 +585,7 @@ namespace OpenSim.Services.GridService
584 xloc = xloc * (int)Constants.RegionSize; 585 xloc = xloc * (int)Constants.RegionSize;
585 yloc = yloc * (int)Constants.RegionSize; 586 yloc = yloc * (int)Constants.RegionSize;
586 string reason = string.Empty; 587 string reason = string.Empty;
587 if (TryCreateLink(xloc, yloc, "", externalPort, 588 if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort,
588 externalHostName, out regInfo, out reason)) 589 externalHostName, out regInfo, out reason))
589 { 590 {
590 regInfo.RegionName = config.GetString("localName", ""); 591 regInfo.RegionName = config.GetString("localName", "");