aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs82
1 files changed, 42 insertions, 40 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
index c6ade15..0c2a835 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -36,6 +36,7 @@ using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.Framework.Scenes.Hypergrid; 37using OpenSim.Region.Framework.Scenes.Hypergrid;
38using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using OpenSim.Server.Base; 40using OpenSim.Server.Base;
40using OpenSim.Services.Connectors.Grid; 41using OpenSim.Services.Connectors.Grid;
41using OpenSim.Framework.Console; 42using OpenSim.Framework.Console;
@@ -59,13 +60,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
59 private HypergridServiceConnector m_HypergridServiceConnector; 60 private HypergridServiceConnector m_HypergridServiceConnector;
60 61
61 // Hyperlink regions are hyperlinks on the map 62 // Hyperlink regions are hyperlinks on the map
62 protected Dictionary<UUID, SimpleRegionInfo> m_HyperlinkRegions = new Dictionary<UUID, SimpleRegionInfo>(); 63 protected Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>();
63 64
64 // Known regions are home regions of visiting foreign users. 65 // Known regions are home regions of visiting foreign users.
65 // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when 66 // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when
66 // the visitor goes away. They are mapped to X=0 on the map. 67 // the visitor goes away. They are mapped to X=0 on the map.
67 // This is key-ed on agent ID 68 // This is key-ed on agent ID
68 protected Dictionary<UUID, SimpleRegionInfo> m_knownRegions = new Dictionary<UUID, SimpleRegionInfo>(); 69 protected Dictionary<UUID, GridRegion> m_knownRegions = new Dictionary<UUID, GridRegion>();
69 70
70 protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>(); 71 protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>();
71 72
@@ -184,7 +185,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
184 185
185 #region IGridService 186 #region IGridService
186 187
187 public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) 188 public bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
188 { 189 {
189 // Region doesn't exist here. Trying to link remote region 190 // Region doesn't exist here. Trying to link remote region
190 if (regionInfo.RegionID.Equals(UUID.Zero)) 191 if (regionInfo.RegionID.Equals(UUID.Zero))
@@ -222,7 +223,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
222 } 223 }
223 // Try the foreign users home collection 224 // Try the foreign users home collection
224 225
225 foreach (SimpleRegionInfo r in m_knownRegions.Values) 226 foreach (GridRegion r in m_knownRegions.Values)
226 if (r.RegionID == regionID) 227 if (r.RegionID == regionID)
227 { 228 {
228 RemoveHyperlinkHomeRegion(regionID); 229 RemoveHyperlinkHomeRegion(regionID);
@@ -233,21 +234,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
233 return m_GridServiceConnector.DeregisterRegion(regionID); 234 return m_GridServiceConnector.DeregisterRegion(regionID);
234 } 235 }
235 236
236 public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) 237 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
237 { 238 {
238 // No serving neighbours on hyperliked regions. 239 // No serving neighbours on hyperliked regions.
239 // Just the regular regions. 240 // Just the regular regions.
240 return m_GridServiceConnector.GetNeighbours(scopeID, regionID); 241 return m_GridServiceConnector.GetNeighbours(scopeID, regionID);
241 } 242 }
242 243
243 public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) 244 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
244 { 245 {
245 // Try the hyperlink collection 246 // Try the hyperlink collection
246 if (m_HyperlinkRegions.ContainsKey(regionID)) 247 if (m_HyperlinkRegions.ContainsKey(regionID))
247 return m_HyperlinkRegions[regionID]; 248 return m_HyperlinkRegions[regionID];
248 249
249 // Try the foreign users home collection 250 // Try the foreign users home collection
250 foreach (SimpleRegionInfo r in m_knownRegions.Values) 251 foreach (GridRegion r in m_knownRegions.Values)
251 if (r.RegionID == regionID) 252 if (r.RegionID == regionID)
252 return m_knownRegions[regionID]; 253 return m_knownRegions[regionID];
253 254
@@ -255,19 +256,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
255 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); 256 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
256 } 257 }
257 258
258 public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) 259 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
259 { 260 {
260 int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize; 261 int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize;
261 int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize; 262 int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize;
262 // Try the hyperlink collection 263 // Try the hyperlink collection
263 foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) 264 foreach (GridRegion r in m_HyperlinkRegions.Values)
264 { 265 {
265 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) 266 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
266 return r; 267 return r;
267 } 268 }
268 269
269 // Try the foreign users home collection 270 // Try the foreign users home collection
270 foreach (SimpleRegionInfo r in m_knownRegions.Values) 271 foreach (GridRegion r in m_knownRegions.Values)
271 { 272 {
272 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) 273 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
273 return r; 274 return r;
@@ -277,22 +278,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
277 return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); 278 return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y);
278 } 279 }
279 280
280 public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) 281 public GridRegion GetRegionByName(UUID scopeID, string regionName)
281 { 282 {
282 // Try normal grid first 283 // Try normal grid first
283 SimpleRegionInfo region = m_GridServiceConnector.GetRegionByName(scopeID, regionName); 284 GridRegion region = m_GridServiceConnector.GetRegionByName(scopeID, regionName);
284 if (region != null) 285 if (region != null)
285 return region; 286 return region;
286 287
287 // Try the hyperlink collection 288 // Try the hyperlink collection
288 foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) 289 foreach (GridRegion r in m_HyperlinkRegions.Values)
289 { 290 {
290 if (r.RegionName == regionName) 291 if (r.RegionName == regionName)
291 return r; 292 return r;
292 } 293 }
293 294
294 // Try the foreign users home collection 295 // Try the foreign users home collection
295 foreach (SimpleRegionInfo r in m_knownRegions.Values) 296 foreach (GridRegion r in m_knownRegions.Values)
296 { 297 {
297 if (r.RegionName == regionName) 298 if (r.RegionName == regionName)
298 return r; 299 return r;
@@ -300,9 +301,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
300 return null; 301 return null;
301 } 302 }
302 303
303 public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) 304 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
304 { 305 {
305 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 306 List<GridRegion> rinfos = new List<GridRegion>();
306 307
307 // Commenting until regionname exists 308 // Commenting until regionname exists
308 //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) 309 //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values)
@@ -313,15 +314,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
313 return rinfos; 314 return rinfos;
314 } 315 }
315 316
316 public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 317 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
317 { 318 {
318 int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; 319 int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
319 int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; 320 int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize;
320 int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; 321 int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize;
321 int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; 322 int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
322 323
323 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 324 List<GridRegion> rinfos = new List<GridRegion>();
324 foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) 325 foreach (GridRegion r in m_HyperlinkRegions.Values)
325 if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) && 326 if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) &&
326 (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax)) 327 (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax))
327 rinfos.Add(r); 328 rinfos.Add(r);
@@ -335,7 +336,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
335 336
336 #region Auxiliary 337 #region Auxiliary
337 338
338 private void AddHyperlinkRegion(SimpleRegionInfo regionInfo, ulong regionHandle) 339 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
339 { 340 {
340 m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); 341 m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo);
341 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); 342 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
@@ -347,7 +348,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
347 m_HyperlinkHandles.Remove(regionID); 348 m_HyperlinkHandles.Remove(regionID);
348 } 349 }
349 350
350 private void AddHyperlinkHomeRegion(UUID userID, SimpleRegionInfo regionInfo, ulong regionHandle) 351 private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle)
351 { 352 {
352 m_knownRegions.Add(userID, regionInfo); 353 m_knownRegions.Add(userID, regionInfo);
353 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); 354 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
@@ -355,7 +356,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
355 356
356 private void RemoveHyperlinkHomeRegion(UUID regionID) 357 private void RemoveHyperlinkHomeRegion(UUID regionID)
357 { 358 {
358 foreach (KeyValuePair<UUID, SimpleRegionInfo> kvp in m_knownRegions) 359 foreach (KeyValuePair<UUID, GridRegion> kvp in m_knownRegions)
359 { 360 {
360 if (kvp.Value.RegionID == regionID) 361 if (kvp.Value.RegionID == regionID)
361 { 362 {
@@ -370,7 +371,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
370 371
371 private static Random random = new Random(); 372 private static Random random = new Random();
372 373
373 public SimpleRegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc) 374 public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc)
374 { 375 {
375 string host = "127.0.0.1"; 376 string host = "127.0.0.1";
376 string portstr; 377 string portstr;
@@ -404,7 +405,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
404 if ((ipaddr != null) && 405 if ((ipaddr != null) &&
405 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port))) 406 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
406 { 407 {
407 SimpleRegionInfo regInfo; 408 GridRegion regInfo;
408 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); 409 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
409 if (success) 410 if (success)
410 { 411 {
@@ -417,18 +418,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
417 } 418 }
418 419
419 // From the map search and secondlife://blah 420 // From the map search and secondlife://blah
420 public SimpleRegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) 421 public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
421 { 422 {
422 uint xloc = (uint)(random.Next(0, Int16.MaxValue)); 423 int xloc = random.Next(0, Int16.MaxValue);
423 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); 424 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
424 } 425 }
425 426
426 public bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc, 427 public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc,
427 string externalRegionName, uint externalPort, string externalHostName, out SimpleRegionInfo regInfo) 428 string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo)
428 { 429 {
429 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); 430 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
430 431
431 regInfo = new SimpleRegionInfo(); 432 regInfo = new GridRegion();
432 regInfo.RegionName = externalRegionName; 433 regInfo.RegionName = externalRegionName;
433 regInfo.HttpPort = externalPort; 434 regInfo.HttpPort = externalPort;
434 regInfo.ExternalHostName = externalHostName; 435 regInfo.ExternalHostName = externalHostName;
@@ -456,7 +457,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
456 return false; 457 return false;
457 } 458 }
458 459
459 uint x, y; 460 int x, y;
460 if (!Check4096(m_scene, regInfo, out x, out y)) 461 if (!Check4096(m_scene, regInfo, out x, out y))
461 { 462 {
462 DeregisterRegion(regInfo.RegionID); 463 DeregisterRegion(regInfo.RegionID);
@@ -481,7 +482,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
481 482
482 public bool TryUnlinkRegion(Scene m_scene, string mapName) 483 public bool TryUnlinkRegion(Scene m_scene, string mapName)
483 { 484 {
484 SimpleRegionInfo regInfo = null; 485 GridRegion regInfo = null;
485 if (mapName.Contains(":")) 486 if (mapName.Contains(":"))
486 { 487 {
487 string host = "127.0.0.1"; 488 string host = "127.0.0.1";
@@ -504,13 +505,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
504 // { 505 // {
505 // regionName = parts[2]; 506 // regionName = parts[2];
506 // } 507 // }
507 foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) 508 foreach (GridRegion r in m_HyperlinkRegions.Values)
508 if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) 509 if (host.Equals(r.ExternalHostName) && (port == r.HttpPort))
509 regInfo = r; 510 regInfo = r;
510 } 511 }
511 else 512 else
512 { 513 {
513 foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) 514 foreach (GridRegion r in m_HyperlinkRegions.Values)
514 if (r.RegionName.Equals(mapName)) 515 if (r.RegionName.Equals(mapName))
515 regInfo = r; 516 regInfo = r;
516 } 517 }
@@ -530,22 +531,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
530 /// </summary> 531 /// </summary>
531 /// <param name="regInfo"></param> 532 /// <param name="regInfo"></param>
532 /// <returns></returns> 533 /// <returns></returns>
533 public bool Check4096(Scene m_scene, SimpleRegionInfo regInfo, out uint x, out uint y) 534 public bool Check4096(Scene m_scene, GridRegion regInfo, out int x, out int y)
534 { 535 {
535 ulong realHandle = m_HyperlinkHandles[regInfo.RegionID]; 536 ulong realHandle = m_HyperlinkHandles[regInfo.RegionID];
536 Utils.LongToUInts(realHandle, out x, out y); 537 uint ux = 0, uy = 0;
537 x = x / Constants.RegionSize; 538 Utils.LongToUInts(realHandle, out ux, out uy);
538 y = y / Constants.RegionSize; 539 x = (int)(ux / Constants.RegionSize);
540 y = (int)(uy / Constants.RegionSize);
539 541
540 if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) || 542 if ((Math.Abs((int)(m_scene.RegionInfo.RegionLocX / Constants.RegionSize) - x) >= 4096) ||
541 (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096)) 543 (Math.Abs((int)(m_scene.RegionInfo.RegionLocY / Constants.RegionSize) - y) >= 4096))
542 { 544 {
543 return false; 545 return false;
544 } 546 }
545 return true; 547 return true;
546 } 548 }
547 549
548 public bool CheckCoords(uint thisx, uint thisy, uint x, uint y) 550 public bool CheckCoords(uint thisx, uint thisy, int x, int y)
549 { 551 {
550 if ((thisx == x) && (thisy == y)) 552 if ((thisx == x) && (thisy == y))
551 return false; 553 return false;