aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/GridService
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/GridService/GridService.cs294
-rw-r--r--OpenSim/Services/GridService/GridServiceBase.cs2
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs189
-rw-r--r--OpenSim/Services/GridService/Properties/AssemblyInfo.cs10
4 files changed, 257 insertions, 238 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 0c502a2..a5c7d34 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -57,8 +57,6 @@ namespace OpenSim.Services.GridService
57 protected bool m_AllowDuplicateNames = false; 57 protected bool m_AllowDuplicateNames = false;
58 protected bool m_AllowHypergridMapSearch = false; 58 protected bool m_AllowHypergridMapSearch = false;
59 59
60 protected bool m_SuppressVarregionOverlapCheckOnRegistration = false;
61
62 private static Dictionary<string,object> m_ExtraFeatures = new Dictionary<string, object>(); 60 private static Dictionary<string,object> m_ExtraFeatures = new Dictionary<string, object>();
63 61
64 public GridService(IConfigSource config) 62 public GridService(IConfigSource config)
@@ -74,7 +72,7 @@ namespace OpenSim.Services.GridService
74 if (gridConfig != null) 72 if (gridConfig != null)
75 { 73 {
76 m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true); 74 m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true);
77 75
78 string authService = gridConfig.GetString("AuthenticationService", String.Empty); 76 string authService = gridConfig.GetString("AuthenticationService", String.Empty);
79 77
80 if (authService != String.Empty) 78 if (authService != String.Empty)
@@ -85,8 +83,6 @@ namespace OpenSim.Services.GridService
85 m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); 83 m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
86 m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch); 84 m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch);
87 85
88 m_SuppressVarregionOverlapCheckOnRegistration = gridConfig.GetBoolean("SuppressVarregionOverlapCheckOnRegistration", m_SuppressVarregionOverlapCheckOnRegistration);
89
90 // This service is also used locally by a simulator running in grid mode. This switches prevents 86 // This service is also used locally by a simulator running in grid mode. This switches prevents
91 // inappropriate console commands from being registered 87 // inappropriate console commands from being registered
92 suppressConsoleCommands = gridConfig.GetBoolean("SuppressConsoleCommands", suppressConsoleCommands); 88 suppressConsoleCommands = gridConfig.GetBoolean("SuppressConsoleCommands", suppressConsoleCommands);
@@ -155,9 +151,9 @@ namespace OpenSim.Services.GridService
155 151
156 if (loginConfig == null || gridConfig == null) 152 if (loginConfig == null || gridConfig == null)
157 return; 153 return;
158 154
159 string configVal; 155 string configVal;
160 156
161 configVal = loginConfig.GetString("SearchURL", string.Empty); 157 configVal = loginConfig.GetString("SearchURL", string.Empty);
162 if (!string.IsNullOrEmpty(configVal)) 158 if (!string.IsNullOrEmpty(configVal))
163 m_ExtraFeatures["search-server-url"] = configVal; 159 m_ExtraFeatures["search-server-url"] = configVal;
@@ -201,15 +197,28 @@ namespace OpenSim.Services.GridService
201 if (regionInfos.RegionID == UUID.Zero) 197 if (regionInfos.RegionID == UUID.Zero)
202 return "Invalid RegionID - cannot be zero UUID"; 198 return "Invalid RegionID - cannot be zero UUID";
203 199
200 if (regionInfos.RegionLocY <= Constants.MaximumRegionSize)
201 return "Region location reserved for HG links coord Y must be higher than " + (Constants.MaximumRegionSize/256).ToString();
202
204 String reason = "Region overlaps another region"; 203 String reason = "Region overlaps another region";
205 RegionData region = FindAnyConflictingRegion(regionInfos, scopeID, out reason); 204
206 // If there is a conflicting region, if it has the same ID and same coordinates 205 List<RegionData> rdatas = m_Database.Get(
207 // then it is a region re-registering (permissions and ownership checked later). 206 regionInfos.RegionLocX,
208 if ((region != null) 207 regionInfos.RegionLocY,
209 && ( (region.coordX != regionInfos.RegionCoordX) 208 regionInfos.RegionLocX + regionInfos.RegionSizeX - 1,
210 || (region.coordY != regionInfos.RegionCoordY) 209 regionInfos.RegionLocY + regionInfos.RegionSizeY - 1 ,
211 || (region.RegionID != regionInfos.RegionID) ) 210 scopeID);
212 ) 211
212 RegionData region = null;
213 if(rdatas.Count > 1)
214 {
215 m_log.WarnFormat("{0} Register region overlaps with {1} regions", LogHeader, scopeID, rdatas.Count);
216 return reason;
217 }
218 else if(rdatas.Count == 1)
219 region = rdatas[0];
220
221 if ((region != null) && (region.RegionID != regionInfos.RegionID))
213 { 222 {
214 // If not same ID and same coordinates, this new region has conflicts and can't be registered. 223 // If not same ID and same coordinates, this new region has conflicts and can't be registered.
215 m_log.WarnFormat("{0} Register region conflict in scope {1}. {2}", LogHeader, scopeID, reason); 224 m_log.WarnFormat("{0} Register region conflict in scope {1}. {2}", LogHeader, scopeID, reason);
@@ -263,7 +272,7 @@ namespace OpenSim.Services.GridService
263 { 272 {
264 if (d.RegionID != regionInfos.RegionID) 273 if (d.RegionID != regionInfos.RegionID)
265 { 274 {
266 m_log.WarnFormat("[GRID SERVICE]: Region tried to register using a duplicate name. New region: {0} ({1}), existing region: {2} ({3}).", 275 m_log.WarnFormat("[GRID SERVICE]: Region tried to register using a duplicate name. New region: {0} ({1}), existing region: {2} ({3}).",
267 regionInfos.RegionName, regionInfos.RegionID, d.RegionName, d.RegionID); 276 regionInfos.RegionName, regionInfos.RegionID, d.RegionName, d.RegionID);
268 return "Duplicate region name"; 277 return "Duplicate region name";
269 } 278 }
@@ -273,7 +282,7 @@ namespace OpenSim.Services.GridService
273 282
274 // If there is an old record for us, delete it if it is elsewhere. 283 // If there is an old record for us, delete it if it is elsewhere.
275 region = m_Database.Get(regionInfos.RegionID, scopeID); 284 region = m_Database.Get(regionInfos.RegionID, scopeID);
276 if ((region != null) && (region.RegionID == regionInfos.RegionID) && 285 if ((region != null) && (region.RegionID == regionInfos.RegionID) &&
277 ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) 286 ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
278 { 287 {
279 if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.NoMove) != 0) 288 if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.NoMove) != 0)
@@ -284,7 +293,7 @@ namespace OpenSim.Services.GridService
284 293
285 // Region reregistering in other coordinates. Delete the old entry 294 // Region reregistering in other coordinates. Delete the old entry
286 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", 295 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.",
287 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); 296 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY);
288 297
289 try 298 try
290 { 299 {
@@ -299,7 +308,7 @@ namespace OpenSim.Services.GridService
299 // Everything is ok, let's register 308 // Everything is ok, let's register
300 RegionData rdata = RegionInfo2RegionData(regionInfos); 309 RegionData rdata = RegionInfo2RegionData(regionInfos);
301 rdata.ScopeID = scopeID; 310 rdata.ScopeID = scopeID;
302 311
303 if (region != null) 312 if (region != null)
304 { 313 {
305 int oldFlags = Convert.ToInt32(region.Data["flags"]); 314 int oldFlags = Convert.ToInt32(region.Data["flags"]);
@@ -336,107 +345,15 @@ namespace OpenSim.Services.GridService
336 m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); 345 m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e);
337 } 346 }
338 347
339 m_log.InfoFormat 348 m_log.DebugFormat
340 ("[GRID SERVICE]: Region {0} ({1}, {2}x{3}) registered at {4},{5} with flags {6}", 349 ("[GRID SERVICE]: Region {0} ({1}, {2}x{3}) registered at {4},{5} with flags {6}",
341 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionSizeX, regionInfos.RegionSizeY, 350 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionSizeX, regionInfos.RegionSizeY,
342 regionInfos.RegionCoordX, regionInfos.RegionCoordY, 351 regionInfos.RegionCoordX, regionInfos.RegionCoordY,
343 (OpenSim.Framework.RegionFlags)flags); 352 (OpenSim.Framework.RegionFlags)flags);
344 353
345 return String.Empty; 354 return String.Empty;
346 } 355 }
347 356
348 /// <summary>
349 /// Search the region map for regions conflicting with this region.
350 /// The region to be added is passed and we look for any existing regions that are
351 /// in the requested location, that are large varregions that overlap this region, or
352 /// are previously defined regions that would lie under this new region.
353 /// </summary>
354 /// <param name="regionInfos">Information on region requested to be added to the world map</param>
355 /// <param name="scopeID">Grid id for region</param>
356 /// <param name="reason">The reason the returned region conflicts with passed region</param>
357 /// <returns></returns>
358 private RegionData FindAnyConflictingRegion(GridRegion regionInfos, UUID scopeID, out string reason)
359 {
360 reason = "Reregistration";
361 // First see if there is an existing region right where this region is trying to go
362 // (We keep this result so it can be returned if suppressing errors)
363 RegionData noErrorRegion = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
364 RegionData region = noErrorRegion;
365 if (region != null
366 && region.RegionID == regionInfos.RegionID
367 && region.sizeX == regionInfos.RegionSizeX
368 && region.sizeY == regionInfos.RegionSizeY)
369 {
370 // If this seems to be exactly the same region, return this as it could be
371 // a re-registration (permissions checked by calling routine).
372 m_log.DebugFormat("{0} FindAnyConflictingRegion: re-register of {1}",
373 LogHeader, RegionString(regionInfos));
374 return region;
375 }
376
377 // No region exactly there or we're resizing an existing region.
378 // Fetch regions that could be varregions overlapping requested location.
379 int xmin = regionInfos.RegionLocX - (int)Constants.MaximumRegionSize + 10;
380 int xmax = regionInfos.RegionLocX;
381 int ymin = regionInfos.RegionLocY - (int)Constants.MaximumRegionSize + 10;
382 int ymax = regionInfos.RegionLocY;
383 List<RegionData> rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID);
384 foreach (RegionData rdata in rdatas)
385 {
386 // m_log.DebugFormat("{0} FindAnyConflictingRegion: find existing. Checking {1}", LogHeader, RegionString(rdata) );
387 if ( (rdata.posX + rdata.sizeX > regionInfos.RegionLocX)
388 && (rdata.posY + rdata.sizeY > regionInfos.RegionLocY) )
389 {
390 region = rdata;
391 m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of {1} by existing varregion {2}",
392 LogHeader, RegionString(regionInfos), RegionString(region));
393 reason = String.Format("Region location is overlapped by existing varregion {0}",
394 RegionString(region));
395
396 if (m_SuppressVarregionOverlapCheckOnRegistration)
397 region = noErrorRegion;
398 return region;
399 }
400 }
401
402 // There isn't a region that overlaps this potential region.
403 // See if this potential region overlaps an existing region.
404 // First, a shortcut of not looking for overlap if new region is legacy region sized
405 // and connot overlap anything.
406 if (regionInfos.RegionSizeX != Constants.RegionSize
407 || regionInfos.RegionSizeY != Constants.RegionSize)
408 {
409 // trim range looked for so we don't pick up neighbor regions just off the edges
410 xmin = regionInfos.RegionLocX;
411 xmax = regionInfos.RegionLocX + regionInfos.RegionSizeX - 10;
412 ymin = regionInfos.RegionLocY;
413 ymax = regionInfos.RegionLocY + regionInfos.RegionSizeY - 10;
414 rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID);
415
416 // If the region is being resized, the found region could be ourself.
417 foreach (RegionData rdata in rdatas)
418 {
419 // m_log.DebugFormat("{0} FindAnyConflictingRegion: see if overlap. Checking {1}", LogHeader, RegionString(rdata) );
420 if (region == null || region.RegionID != regionInfos.RegionID)
421 {
422 region = rdata;
423 m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of varregion {1} overlaps existing region {2}",
424 LogHeader, RegionString(regionInfos), RegionString(region));
425 reason = String.Format("Region {0} would overlap existing region {1}",
426 RegionString(regionInfos), RegionString(region));
427
428 if (m_SuppressVarregionOverlapCheckOnRegistration)
429 region = noErrorRegion;
430 return region;
431 }
432 }
433 }
434
435 // If we get here, region is either null (nothing found here) or
436 // is the non-conflicting region found at the location being requested.
437 return region;
438 }
439
440 // String describing name and region location of passed region 357 // String describing name and region location of passed region
441 private String RegionString(RegionData reg) 358 private String RegionString(RegionData reg)
442 { 359 {
@@ -463,7 +380,7 @@ namespace OpenSim.Services.GridService
463 380
464 int flags = Convert.ToInt32(region.Data["flags"]); 381 int flags = Convert.ToInt32(region.Data["flags"]);
465 382
466 if (!m_DeleteOnUnregister || (flags & (int)OpenSim.Framework.RegionFlags.Persistent) != 0) 383 if ((!m_DeleteOnUnregister) || ((flags & (int)OpenSim.Framework.RegionFlags.Persistent) != 0))
467 { 384 {
468 flags &= ~(int)OpenSim.Framework.RegionFlags.RegionOnline; 385 flags &= ~(int)OpenSim.Framework.RegionFlags.RegionOnline;
469 region.Data["flags"] = flags.ToString(); 386 region.Data["flags"] = flags.ToString();
@@ -478,7 +395,6 @@ namespace OpenSim.Services.GridService
478 } 395 }
479 396
480 return true; 397 return true;
481
482 } 398 }
483 399
484 return m_Database.Delete(regionID); 400 return m_Database.Delete(regionID);
@@ -488,13 +404,11 @@ namespace OpenSim.Services.GridService
488 { 404 {
489 List<GridRegion> rinfos = new List<GridRegion>(); 405 List<GridRegion> rinfos = new List<GridRegion>();
490 RegionData region = m_Database.Get(regionID, scopeID); 406 RegionData region = m_Database.Get(regionID, scopeID);
491 407
492 if (region != null) 408 if (region != null)
493 { 409 {
494 // Not really? Maybe?
495 // The adjacent regions are presumed to be the same size as the current region
496 List<RegionData> rdatas = m_Database.Get( 410 List<RegionData> rdatas = m_Database.Get(
497 region.posX - region.sizeX - 1, region.posY - region.sizeY - 1, 411 region.posX - 1, region.posY - 1,
498 region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID); 412 region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID);
499 413
500 foreach (RegionData rdata in rdatas) 414 foreach (RegionData rdata in rdatas)
@@ -516,10 +430,10 @@ namespace OpenSim.Services.GridService
516 else 430 else
517 { 431 {
518 m_log.WarnFormat( 432 m_log.WarnFormat(
519 "[GRID SERVICE]: GetNeighbours() called for scope {0}, region {1} but no such region found", 433 "[GRID SERVICE]: GetNeighbours() called for scope {0}, region {1} but no such region found",
520 scopeID, regionID); 434 scopeID, regionID);
521 } 435 }
522 436
523 return rinfos; 437 return rinfos;
524 } 438 }
525 439
@@ -537,6 +451,7 @@ namespace OpenSim.Services.GridService
537 // be the base coordinate of the region. 451 // be the base coordinate of the region.
538 // The snapping is technically unnecessary but is harmless because regions are always 452 // The snapping is technically unnecessary but is harmless because regions are always
539 // multiples of the legacy region size (256). 453 // multiples of the legacy region size (256).
454
540 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 455 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
541 { 456 {
542 uint regionX = Util.WorldToRegionLoc((uint)x); 457 uint regionX = Util.WorldToRegionLoc((uint)x);
@@ -553,8 +468,8 @@ namespace OpenSim.Services.GridService
553 } 468 }
554 else 469 else
555 { 470 {
556 m_log.DebugFormat("{0} GetRegionByPosition. Did not find region in database. Pos=<{1},{2}>", 471// m_log.DebugFormat("{0} GetRegionByPosition. Did not find region in database. Pos=<{1},{2}>",
557 LogHeader, regionX, regionY); 472// LogHeader, regionX, regionY);
558 return null; 473 return null;
559 } 474 }
560 } 475 }
@@ -584,7 +499,78 @@ namespace OpenSim.Services.GridService
584 int count = 0; 499 int count = 0;
585 List<GridRegion> rinfos = new List<GridRegion>(); 500 List<GridRegion> rinfos = new List<GridRegion>();
586 501
587 if (rdatas != null) 502 if (count < maxNumber && m_AllowHypergridMapSearch && name.Contains("."))
503 {
504 string regionURI = "";
505 string regionName = "";
506 if(!Util.buildHGRegionURI(name, out regionURI, out regionName))
507 return null;
508
509 string mapname;
510 bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI);
511 if(localGrid)
512 mapname = regionName;
513 else
514 mapname = regionURI + regionName;
515
516 bool haveMatch = false;
517
518 if (rdatas != null && (rdatas.Count > 0))
519 {
520// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
521 foreach (RegionData rdata in rdatas)
522 {
523 if (count++ < maxNumber)
524 rinfos.Add(RegionData2RegionInfo(rdata));
525 if(rdata.RegionName == mapname)
526 {
527 haveMatch = true;
528 if(count == maxNumber)
529 {
530 rinfos.RemoveAt(count - 1);
531 rinfos.Add(RegionData2RegionInfo(rdata));
532 }
533 }
534 }
535 if(haveMatch)
536 return rinfos;
537 }
538
539 rdatas = m_Database.Get(Util.EscapeForLike(mapname)+ "%", scopeID);
540 if (rdatas != null && (rdatas.Count > 0))
541 {
542// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
543 foreach (RegionData rdata in rdatas)
544 {
545 if (count++ < maxNumber)
546 rinfos.Add(RegionData2RegionInfo(rdata));
547 if(rdata.RegionName == mapname)
548 {
549 haveMatch = true;
550 if(count == maxNumber)
551 {
552 rinfos.RemoveAt(count - 1);
553 rinfos.Add(RegionData2RegionInfo(rdata));
554 break;
555 }
556 }
557 }
558 if(haveMatch)
559 return rinfos;
560 }
561 if(!localGrid && !string.IsNullOrWhiteSpace(regionURI))
562 {
563 string HGname = regionURI +" "+ regionName; // include space for compatibility
564 GridRegion r = m_HypergridLinker.LinkRegion(scopeID, HGname);
565 if (r != null)
566 {
567 if( count == maxNumber)
568 rinfos.RemoveAt(count - 1);
569 rinfos.Add(r);
570 }
571 }
572 }
573 else if (rdatas != null && (rdatas.Count > 0))
588 { 574 {
589// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); 575// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
590 foreach (RegionData rdata in rdatas) 576 foreach (RegionData rdata in rdatas)
@@ -594,13 +580,6 @@ namespace OpenSim.Services.GridService
594 } 580 }
595 } 581 }
596 582
597 if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0)))
598 {
599 GridRegion r = GetHypergridRegionByName(scopeID, name);
600 if (r != null)
601 rinfos.Add(r);
602 }
603
604 return rinfos; 583 return rinfos;
605 } 584 }
606 585
@@ -613,9 +592,30 @@ namespace OpenSim.Services.GridService
613 protected GridRegion GetHypergridRegionByName(UUID scopeID, string name) 592 protected GridRegion GetHypergridRegionByName(UUID scopeID, string name)
614 { 593 {
615 if (name.Contains(".")) 594 if (name.Contains("."))
616 return m_HypergridLinker.LinkRegion(scopeID, name); 595 {
617 else 596 string regionURI = "";
618 return null; 597 string regionName = "";
598 if(!Util.buildHGRegionURI(name, out regionURI, out regionName))
599 return null;
600
601 string mapname;
602 bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI);
603 if(localGrid)
604 mapname = regionName;
605 else
606 mapname = regionURI + regionName;
607
608 List<RegionData> rdatas = m_Database.Get(Util.EscapeForLike(mapname), scopeID);
609 if ((rdatas != null) && (rdatas.Count > 0))
610 return RegionData2RegionInfo(rdatas[0]); // get the first
611
612 if(!localGrid && !string.IsNullOrWhiteSpace(regionURI))
613 {
614 string HGname = regionURI +" "+ regionName;
615 return m_HypergridLinker.LinkRegion(scopeID, HGname);
616 }
617 }
618 return null;
619 } 619 }
620 620
621 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 621 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
@@ -666,7 +666,7 @@ namespace OpenSim.Services.GridService
666 return rinfo; 666 return rinfo;
667 } 667 }
668 668
669 #endregion 669 #endregion
670 670
671 public List<GridRegion> GetDefaultRegions(UUID scopeID) 671 public List<GridRegion> GetDefaultRegions(UUID scopeID)
672 { 672 {
@@ -705,7 +705,7 @@ namespace OpenSim.Services.GridService
705 int normalDefaultRegionsFoundOnline = ret.Count - hgDefaultRegionsFoundOnline; 705 int normalDefaultRegionsFoundOnline = ret.Count - hgDefaultRegionsFoundOnline;
706 706
707 m_log.DebugFormat( 707 m_log.DebugFormat(
708 "[GRID SERVICE]: GetDefaultHypergridRegions returning {0} hypergrid default and {1} normal default regions", 708 "[GRID SERVICE]: GetDefaultHypergridRegions returning {0} hypergrid default and {1} normal default regions",
709 hgDefaultRegionsFoundOnline, normalDefaultRegionsFoundOnline); 709 hgDefaultRegionsFoundOnline, normalDefaultRegionsFoundOnline);
710 710
711 return ret; 711 return ret;
@@ -742,7 +742,7 @@ namespace OpenSim.Services.GridService
742 m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count); 742 m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count);
743 return ret; 743 return ret;
744 } 744 }
745 745
746 public int GetRegionFlags(UUID scopeID, UUID regionID) 746 public int GetRegionFlags(UUID scopeID, UUID regionID)
747 { 747 {
748 RegionData region = m_Database.Get(regionID, scopeID); 748 RegionData region = m_Database.Get(regionID, scopeID);
@@ -804,14 +804,14 @@ namespace OpenSim.Services.GridService
804 return; 804 return;
805 } 805 }
806 806
807 List<RegionData> regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero); 807 List<RegionData> regions = m_Database.Get(0, 0, int.MaxValue, int.MaxValue, UUID.Zero);
808 808
809 OutputRegionsToConsoleSummary(regions); 809 OutputRegionsToConsoleSummary(regions);
810 } 810 }
811 811
812 private void HandleShowGridSize(string module, string[] cmd) 812 private void HandleShowGridSize(string module, string[] cmd)
813 { 813 {
814 List<RegionData> regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero); 814 List<RegionData> regions = m_Database.Get(0, 0, int.MaxValue, int.MaxValue, UUID.Zero);
815 815
816 double size = 0; 816 double size = 0;
817 817
@@ -872,7 +872,9 @@ namespace OpenSim.Services.GridService
872 return; 872 return;
873 } 873 }
874 874
875
875 RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero); 876 RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero);
877
876 if (region == null) 878 if (region == null)
877 { 879 {
878 MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y); 880 MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y);
@@ -889,7 +891,7 @@ namespace OpenSim.Services.GridService
889 ConsoleDisplayList dispList = new ConsoleDisplayList(); 891 ConsoleDisplayList dispList = new ConsoleDisplayList();
890 dispList.AddRow("Region Name", r.RegionName); 892 dispList.AddRow("Region Name", r.RegionName);
891 dispList.AddRow("Region ID", r.RegionID); 893 dispList.AddRow("Region ID", r.RegionID);
892 dispList.AddRow("Position", string.Format("{0},{1}", r.coordX, r.coordY)); 894 dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY));
893 dispList.AddRow("Size", string.Format("{0}x{1}", r.sizeX, r.sizeY)); 895 dispList.AddRow("Size", string.Format("{0}x{1}", r.sizeX, r.sizeY));
894 dispList.AddRow("URI", r.Data["serverURI"]); 896 dispList.AddRow("URI", r.Data["serverURI"]);
895 dispList.AddRow("Owner ID", r.Data["owner_uuid"]); 897 dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
@@ -907,9 +909,9 @@ namespace OpenSim.Services.GridService
907 private void OutputRegionsToConsoleSummary(List<RegionData> regions) 909 private void OutputRegionsToConsoleSummary(List<RegionData> regions)
908 { 910 {
909 ConsoleDisplayTable dispTable = new ConsoleDisplayTable(); 911 ConsoleDisplayTable dispTable = new ConsoleDisplayTable();
910 dispTable.AddColumn("Name", 44); 912 dispTable.AddColumn("Name", ConsoleDisplayUtil.RegionNameSize);
911 dispTable.AddColumn("ID", 36); 913 dispTable.AddColumn("ID", ConsoleDisplayUtil.UuidSize);
912 dispTable.AddColumn("Position", 11); 914 dispTable.AddColumn("Position", ConsoleDisplayUtil.CoordTupleSize);
913 dispTable.AddColumn("Size", 11); 915 dispTable.AddColumn("Size", 11);
914 dispTable.AddColumn("Flags", 60); 916 dispTable.AddColumn("Flags", 60);
915 917
@@ -992,7 +994,7 @@ namespace OpenSim.Services.GridService
992 } 994 }
993 995
994 /// <summary> 996 /// <summary>
995 /// Gets the grid extra service URls we wish for the region to send in OpenSimExtras to dynamically refresh 997 /// Gets the grid extra service URls we wish for the region to send in OpenSimExtras to dynamically refresh
996 /// parameters in the viewer used to access services like map, search and destination guides. 998 /// parameters in the viewer used to access services like map, search and destination guides.
997 /// <para>see "SimulatorFeaturesModule" </para> 999 /// <para>see "SimulatorFeaturesModule" </para>
998 /// </summary> 1000 /// </summary>
diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs
index 444f79b..7522e64 100644
--- a/OpenSim/Services/GridService/GridServiceBase.cs
+++ b/OpenSim/Services/GridService/GridServiceBase.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Services.GridService
68 connString = gridConfig.GetString("ConnectionString", connString); 68 connString = gridConfig.GetString("ConnectionString", connString);
69 realm = gridConfig.GetString("Realm", realm); 69 realm = gridConfig.GetString("Realm", realm);
70 } 70 }
71 71
72 // 72 //
73 // We tried, but this doesn't exist. We can't proceed. 73 // We tried, but this doesn't exist. We can't proceed.
74 // 74 //
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index aebbf7c..dabfd3b 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -63,6 +63,7 @@ namespace OpenSim.Services.GridService
63 protected GatekeeperServiceConnector m_GatekeeperConnector; 63 protected GatekeeperServiceConnector m_GatekeeperConnector;
64 64
65 protected UUID m_ScopeID = UUID.Zero; 65 protected UUID m_ScopeID = UUID.Zero;
66// protected bool m_Check4096 = true;
66 protected string m_MapTileDirectory = string.Empty; 67 protected string m_MapTileDirectory = string.Empty;
67 protected string m_ThisGatekeeper = string.Empty; 68 protected string m_ThisGatekeeper = string.Empty;
68 protected Uri m_ThisGatekeeperURI = null; 69 protected Uri m_ThisGatekeeperURI = null;
@@ -119,8 +120,9 @@ namespace OpenSim.Services.GridService
119 if (scope != string.Empty) 120 if (scope != string.Empty)
120 UUID.TryParse(scope, out m_ScopeID); 121 UUID.TryParse(scope, out m_ScopeID);
121 122
122// TODO OpenSim is crazy, this is called from Robust and OpenSim, Robust needs the ../caches bit, OpenSim somehow adds a path already. I can't tell why. So strip the path. 123// m_Check4096 = gridConfig.GetBoolean("Check4096", true);
123 m_MapTileDirectory = "../caches/" + Path.GetFileName(gridConfig.GetString("MapTileDirectory", "maptiles")); 124
125 m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles");
124 126
125 m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", 127 m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
126 new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); 128 new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty);
@@ -135,18 +137,27 @@ namespace OpenSim.Services.GridService
135 m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper); 137 m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper);
136 } 138 }
137 139
140 m_ThisGatekeeper = m_ThisGatekeeperURI.AbsoluteUri;
141 if(m_ThisGatekeeperURI.Port == 80)
142 m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":80/";
143 else if(m_ThisGatekeeperURI.Port == 443)
144 m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":443/";
145
138 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); 146 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);
139 147
140 m_log.Debug("[HYPERGRID LINKER]: Loaded all services..."); 148 m_log.Debug("[HYPERGRID LINKER]: Loaded all services...");
141 149
142 try 150 if (!string.IsNullOrEmpty(m_MapTileDirectory))
143 {
144 Directory.CreateDirectory(m_MapTileDirectory);
145 }
146 catch (Exception e)
147 { 151 {
148 m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e); 152 try
149 m_MapTileDirectory = string.Empty; 153 {
154 Directory.CreateDirectory(m_MapTileDirectory);
155 }
156 catch (Exception e)
157 {
158 m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e);
159 m_MapTileDirectory = string.Empty;
160 }
150 } 161 }
151 162
152 if (MainConsole.Instance != null) 163 if (MainConsole.Instance != null)
@@ -186,85 +197,29 @@ namespace OpenSim.Services.GridService
186 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); 197 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
187 } 198 }
188 199
200 public bool IsLocalGrid(string serverURI)
201 {
202 return serverURI == m_ThisGatekeeper;
203 }
204
189 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) 205 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason)
190 { 206 {
191 reason = string.Empty; 207 reason = string.Empty;
192 GridRegion regInfo = null; 208 GridRegion regInfo = null;
193 209
194 mapName = mapName.Trim(); 210 string serverURI = string.Empty;
211 string regionName = string.Empty;
195 212
196 if (!mapName.StartsWith("http")) 213 if(!Util.buildHGRegionURI(mapName, out serverURI, out regionName))
197 { 214 {
198 // Formats: grid.example.com:8002:region name 215 reason = "Wrong URI format for link-region";
199 // grid.example.com:region name 216 return null;
200 // grid.example.com:8002
201 // grid.example.com
202
203 string host;
204 uint port = 80;
205 string regionName = "";
206
207 string[] parts = mapName.Split(new char[] { ':' });
208
209 if (parts.Length == 0)
210 {
211 reason = "Wrong format for link-region";
212 return null;
213 }
214
215 host = parts[0];
216
217 if (parts.Length >= 2)
218 {
219 // If it's a number then assume it's a port. Otherwise, it's a region name.
220 if (!UInt32.TryParse(parts[1], out port))
221 regionName = parts[1];
222 }
223
224 // always take the last one
225 if (parts.Length >= 3)
226 {
227 regionName = parts[2];
228 }
229
230
231 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason);
232 if (success)
233 {
234 regInfo.RegionName = mapName;
235 return regInfo;
236 }
237 } 217 }
238 else
239 {
240 // Formats: http://grid.example.com region name
241 // http://grid.example.com "region name"
242 // http://grid.example.com
243
244 string serverURI;
245 string regionName = "";
246 218
247 string[] parts = mapName.Split(new char[] { ' ' }); 219 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason))
248 220 {
249 if (parts.Length == 0) 221 regInfo.RegionName = serverURI + regionName;
250 { 222 return regInfo;
251 reason = "Wrong format for link-region";
252 return null;
253 }
254
255 serverURI = parts[0];
256
257 if (parts.Length >= 2)
258 {
259 regionName = mapName.Substring(serverURI.Length);
260 regionName = regionName.Trim(new char[] { '"', ' ' });
261 }
262
263 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason))
264 {
265 regInfo.RegionName = mapName;
266 return regInfo;
267 }
268 } 223 }
269 224
270 return null; 225 return null;
@@ -285,7 +240,7 @@ namespace OpenSim.Services.GridService
285 240
286 private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) 241 private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason)
287 { 242 {
288 m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>", 243 m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>",
289 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), 244 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
290 remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc)); 245 remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));
291 246
@@ -361,7 +316,9 @@ namespace OpenSim.Services.GridService
361 UUID regionID = UUID.Zero; 316 UUID regionID = UUID.Zero;
362 string externalName = string.Empty; 317 string externalName = string.Empty;
363 string imageURL = string.Empty; 318 string imageURL = string.Empty;
364 if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason)) 319 int sizeX = (int)Constants.RegionSize;
320 int sizeY = (int)Constants.RegionSize;
321 if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason, out sizeX, out sizeY))
365 return false; 322 return false;
366 323
367 if (regionID == UUID.Zero) 324 if (regionID == UUID.Zero)
@@ -374,13 +331,27 @@ namespace OpenSim.Services.GridService
374 region = m_GridService.GetRegionByUUID(scopeID, regionID); 331 region = m_GridService.GetRegionByUUID(scopeID, regionID);
375 if (region != null) 332 if (region != null)
376 { 333 {
377 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>", 334 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>", Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
378 Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
379 regInfo = region; 335 regInfo = region;
380 return true; 336 return true;
381 } 337 }
382 338
339 // We are now performing this check for each individual teleport in the EntityTransferModule instead. This
340 // allows us to give better feedback when teleports fail because of the distance reason (which can't be
341 // done here) and it also hypergrid teleports that are within range (possibly because the source grid
342 // itself has regions that are very far apart).
343// uint x, y;
344// if (m_Check4096 && !Check4096(handle, out x, out y))
345// {
346// //RemoveHyperlinkRegion(regInfo.RegionID);
347// reason = "Region is too far (" + x + ", " + y + ")";
348// m_log.Info("[HYPERGRID LINKER]: Unable to link, region is too far (" + x + ", " + y + ")");
349// //return false;
350// }
351
383 regInfo.RegionID = regionID; 352 regInfo.RegionID = regionID;
353 regInfo.RegionSizeX = sizeX;
354 regInfo.RegionSizeY = sizeY;
384 355
385 if (externalName == string.Empty) 356 if (externalName == string.Empty)
386 regInfo.RegionName = regInfo.ServerURI; 357 regInfo.RegionName = regInfo.ServerURI;
@@ -412,7 +383,7 @@ namespace OpenSim.Services.GridService
412 OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); 383 OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]);
413 if ((rflags & OpenSim.Framework.RegionFlags.Hyperlink) != 0) 384 if ((rflags & OpenSim.Framework.RegionFlags.Hyperlink) != 0)
414 { 385 {
415 regInfo = new GridRegion(); 386 regInfo = new GridRegion();
416 regInfo.RegionID = regions[0].RegionID; 387 regInfo.RegionID = regions[0].RegionID;
417 regInfo.ScopeID = m_ScopeID; 388 regInfo.ScopeID = m_ScopeID;
418 } 389 }
@@ -430,6 +401,52 @@ namespace OpenSim.Services.GridService
430 } 401 }
431 } 402 }
432 403
404// Not currently used
405// /// <summary>
406// /// Cope with this viewer limitation.
407// /// </summary>
408// /// <param name="regInfo"></param>
409// /// <returns></returns>
410// public bool Check4096(ulong realHandle, out uint x, out uint y)
411// {
412// uint ux = 0, uy = 0;
413// Utils.LongToUInts(realHandle, out ux, out uy);
414// x = Util.WorldToRegionLoc(ux);
415// y = Util.WorldToRegionLoc(uy);
416//
417// const uint limit = Util.RegionToWorldLoc(4096 - 1);
418// uint xmin = ux - limit;
419// uint xmax = ux + limit;
420// uint ymin = uy - limit;
421// uint ymax = uy + limit;
422// // World map boundary checks
423// if (xmin < 0 || xmin > ux)
424// xmin = 0;
425// if (xmax > int.MaxValue || xmax < ux)
426// xmax = int.MaxValue;
427// if (ymin < 0 || ymin > uy)
428// ymin = 0;
429// if (ymax > int.MaxValue || ymax < uy)
430// ymax = int.MaxValue;
431//
432// // Check for any regions that are within the possible teleport range to the linked region
433// List<GridRegion> regions = m_GridService.GetRegionRange(m_ScopeID, (int)xmin, (int)xmax, (int)ymin, (int)ymax);
434// if (regions.Count == 0)
435// {
436// return false;
437// }
438// else
439// {
440// // Check for regions which are not linked regions
441// List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID);
442// IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks);
443// if (availableRegions.Count() == 0)
444// return false;
445// }
446//
447// return true;
448// }
449
433 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) 450 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
434 { 451 {
435 RegionData rdata = m_GridService.RegionInfo2RegionData(regionInfo); 452 RegionData rdata = m_GridService.RegionInfo2RegionData(regionInfo);
@@ -474,7 +491,7 @@ namespace OpenSim.Services.GridService
474 { 491 {
475 MainConsole.Instance.Output( 492 MainConsole.Instance.Output(
476 String.Format("{0}\n{2,-32} {1}\n", 493 String.Format("{0}\n{2,-32} {1}\n",
477 r.RegionName, r.RegionID, 494 r.RegionName, r.RegionID,
478 String.Format("{0},{1} ({2},{3})", r.posX, r.posY, 495 String.Format("{0},{1} ({2},{3})", r.posX, r.posY,
479 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY) 496 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY)
480 ) 497 )
@@ -556,7 +573,7 @@ namespace OpenSim.Services.GridService
556 if (cmdparams[2].StartsWith("http")) 573 if (cmdparams[2].StartsWith("http"))
557 { 574 {
558 RunLinkRegionCommand(cmdparams); 575 RunLinkRegionCommand(cmdparams);
559 } 576 }
560 else if (cmdparams[2].Contains(":")) 577 else if (cmdparams[2].Contains(":"))
561 { 578 {
562 // New format 579 // New format
diff --git a/OpenSim/Services/GridService/Properties/AssemblyInfo.cs b/OpenSim/Services/GridService/Properties/AssemblyInfo.cs
index 0841e5a..69a3c44 100644
--- a/OpenSim/Services/GridService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/GridService/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.GridService")] 8[assembly: AssemblyTitle("OpenSim.Services.GridService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33