aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/GridService
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/GridService')
-rw-r--r--OpenSim/Services/GridService/GridService.cs295
-rw-r--r--OpenSim/Services/GridService/GridServiceBase.cs2
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs113
-rw-r--r--OpenSim/Services/GridService/Properties/AssemblyInfo.cs10
4 files changed, 188 insertions, 232 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 0c502a2..e0500a6 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,29 @@ 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 m_log.WarnFormat("{0} Region location reserved for HG links coord Y should be higher than {1}.", LogHeader, (Constants.MaximumRegionSize/256).ToString());
202//// return "Region location reserved for HG links coord Y must be higher than " + (Constants.MaximumRegionSize/256).ToString();
203
204 String reason = "Region overlaps another region"; 204 String reason = "Region overlaps another region";
205 RegionData region = FindAnyConflictingRegion(regionInfos, scopeID, out reason); 205
206 // If there is a conflicting region, if it has the same ID and same coordinates 206 List<RegionData> rdatas = m_Database.Get(
207 // then it is a region re-registering (permissions and ownership checked later). 207 regionInfos.RegionLocX,
208 if ((region != null) 208 regionInfos.RegionLocY,
209 && ( (region.coordX != regionInfos.RegionCoordX) 209 regionInfos.RegionLocX + regionInfos.RegionSizeX - 1,
210 || (region.coordY != regionInfos.RegionCoordY) 210 regionInfos.RegionLocY + regionInfos.RegionSizeY - 1 ,
211 || (region.RegionID != regionInfos.RegionID) ) 211 scopeID);
212 ) 212
213 RegionData region = null;
214 if(rdatas.Count > 1)
215 {
216 m_log.WarnFormat("{0} Register region overlaps with {1} regions", LogHeader, scopeID, rdatas.Count);
217 return reason;
218 }
219 else if(rdatas.Count == 1)
220 region = rdatas[0];
221
222 if ((region != null) && (region.RegionID != regionInfos.RegionID))
213 { 223 {
214 // If not same ID and same coordinates, this new region has conflicts and can't be registered. 224 // 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); 225 m_log.WarnFormat("{0} Register region conflict in scope {1}. {2}", LogHeader, scopeID, reason);
@@ -263,7 +273,7 @@ namespace OpenSim.Services.GridService
263 { 273 {
264 if (d.RegionID != regionInfos.RegionID) 274 if (d.RegionID != regionInfos.RegionID)
265 { 275 {
266 m_log.WarnFormat("[GRID SERVICE]: Region tried to register using a duplicate name. New region: {0} ({1}), existing region: {2} ({3}).", 276 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); 277 regionInfos.RegionName, regionInfos.RegionID, d.RegionName, d.RegionID);
268 return "Duplicate region name"; 278 return "Duplicate region name";
269 } 279 }
@@ -273,7 +283,7 @@ namespace OpenSim.Services.GridService
273 283
274 // If there is an old record for us, delete it if it is elsewhere. 284 // If there is an old record for us, delete it if it is elsewhere.
275 region = m_Database.Get(regionInfos.RegionID, scopeID); 285 region = m_Database.Get(regionInfos.RegionID, scopeID);
276 if ((region != null) && (region.RegionID == regionInfos.RegionID) && 286 if ((region != null) && (region.RegionID == regionInfos.RegionID) &&
277 ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) 287 ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
278 { 288 {
279 if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.NoMove) != 0) 289 if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.NoMove) != 0)
@@ -284,7 +294,7 @@ namespace OpenSim.Services.GridService
284 294
285 // Region reregistering in other coordinates. Delete the old entry 295 // 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.", 296 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); 297 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY);
288 298
289 try 299 try
290 { 300 {
@@ -299,7 +309,7 @@ namespace OpenSim.Services.GridService
299 // Everything is ok, let's register 309 // Everything is ok, let's register
300 RegionData rdata = RegionInfo2RegionData(regionInfos); 310 RegionData rdata = RegionInfo2RegionData(regionInfos);
301 rdata.ScopeID = scopeID; 311 rdata.ScopeID = scopeID;
302 312
303 if (region != null) 313 if (region != null)
304 { 314 {
305 int oldFlags = Convert.ToInt32(region.Data["flags"]); 315 int oldFlags = Convert.ToInt32(region.Data["flags"]);
@@ -337,106 +347,14 @@ namespace OpenSim.Services.GridService
337 } 347 }
338 348
339 m_log.InfoFormat 349 m_log.InfoFormat
340 ("[GRID SERVICE]: Region {0} ({1}, {2}x{3}) registered at {4},{5} with flags {6}", 350 ("[GRID SERVICE]: Region {0} ({1}, {2}x{3}) registered at {4},{5} with flags {6}",
341 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionSizeX, regionInfos.RegionSizeY, 351 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionSizeX, regionInfos.RegionSizeY,
342 regionInfos.RegionCoordX, regionInfos.RegionCoordY, 352 regionInfos.RegionCoordX, regionInfos.RegionCoordY,
343 (OpenSim.Framework.RegionFlags)flags); 353 (OpenSim.Framework.RegionFlags)flags);
344 354
345 return String.Empty; 355 return String.Empty;
346 } 356 }
347 357
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 358 // String describing name and region location of passed region
441 private String RegionString(RegionData reg) 359 private String RegionString(RegionData reg)
442 { 360 {
@@ -457,13 +375,13 @@ namespace OpenSim.Services.GridService
457 if (region == null) 375 if (region == null)
458 return false; 376 return false;
459 377
460 m_log.DebugFormat( 378 m_log.InfoFormat(
461 "[GRID SERVICE]: Deregistering region {0} ({1}) at {2}-{3}", 379 "[GRID SERVICE]: Deregistering region {0} ({1}) at {2}-{3}",
462 region.RegionName, region.RegionID, region.coordX, region.coordY); 380 region.RegionName, region.RegionID, region.coordX, region.coordY);
463 381
464 int flags = Convert.ToInt32(region.Data["flags"]); 382 int flags = Convert.ToInt32(region.Data["flags"]);
465 383
466 if (!m_DeleteOnUnregister || (flags & (int)OpenSim.Framework.RegionFlags.Persistent) != 0) 384 if ((!m_DeleteOnUnregister) || ((flags & (int)OpenSim.Framework.RegionFlags.Persistent) != 0))
467 { 385 {
468 flags &= ~(int)OpenSim.Framework.RegionFlags.RegionOnline; 386 flags &= ~(int)OpenSim.Framework.RegionFlags.RegionOnline;
469 region.Data["flags"] = flags.ToString(); 387 region.Data["flags"] = flags.ToString();
@@ -478,7 +396,6 @@ namespace OpenSim.Services.GridService
478 } 396 }
479 397
480 return true; 398 return true;
481
482 } 399 }
483 400
484 return m_Database.Delete(regionID); 401 return m_Database.Delete(regionID);
@@ -488,13 +405,11 @@ namespace OpenSim.Services.GridService
488 { 405 {
489 List<GridRegion> rinfos = new List<GridRegion>(); 406 List<GridRegion> rinfos = new List<GridRegion>();
490 RegionData region = m_Database.Get(regionID, scopeID); 407 RegionData region = m_Database.Get(regionID, scopeID);
491 408
492 if (region != null) 409 if (region != null)
493 { 410 {
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( 411 List<RegionData> rdatas = m_Database.Get(
497 region.posX - region.sizeX - 1, region.posY - region.sizeY - 1, 412 region.posX - 1, region.posY - 1,
498 region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID); 413 region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID);
499 414
500 foreach (RegionData rdata in rdatas) 415 foreach (RegionData rdata in rdatas)
@@ -516,10 +431,10 @@ namespace OpenSim.Services.GridService
516 else 431 else
517 { 432 {
518 m_log.WarnFormat( 433 m_log.WarnFormat(
519 "[GRID SERVICE]: GetNeighbours() called for scope {0}, region {1} but no such region found", 434 "[GRID SERVICE]: GetNeighbours() called for scope {0}, region {1} but no such region found",
520 scopeID, regionID); 435 scopeID, regionID);
521 } 436 }
522 437
523 return rinfos; 438 return rinfos;
524 } 439 }
525 440
@@ -537,6 +452,7 @@ namespace OpenSim.Services.GridService
537 // be the base coordinate of the region. 452 // be the base coordinate of the region.
538 // The snapping is technically unnecessary but is harmless because regions are always 453 // The snapping is technically unnecessary but is harmless because regions are always
539 // multiples of the legacy region size (256). 454 // multiples of the legacy region size (256).
455
540 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 456 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
541 { 457 {
542 uint regionX = Util.WorldToRegionLoc((uint)x); 458 uint regionX = Util.WorldToRegionLoc((uint)x);
@@ -553,8 +469,8 @@ namespace OpenSim.Services.GridService
553 } 469 }
554 else 470 else
555 { 471 {
556 m_log.DebugFormat("{0} GetRegionByPosition. Did not find region in database. Pos=<{1},{2}>", 472// m_log.DebugFormat("{0} GetRegionByPosition. Did not find region in database. Pos=<{1},{2}>",
557 LogHeader, regionX, regionY); 473// LogHeader, regionX, regionY);
558 return null; 474 return null;
559 } 475 }
560 } 476 }
@@ -584,7 +500,78 @@ namespace OpenSim.Services.GridService
584 int count = 0; 500 int count = 0;
585 List<GridRegion> rinfos = new List<GridRegion>(); 501 List<GridRegion> rinfos = new List<GridRegion>();
586 502
587 if (rdatas != null) 503 if (count < maxNumber && m_AllowHypergridMapSearch && name.Contains("."))
504 {
505 string regionURI = "";
506 string regionName = "";
507 if(!Util.buildHGRegionURI(name, out regionURI, out regionName))
508 return null;
509
510 string mapname;
511 bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI);
512 if(localGrid)
513 mapname = regionName;
514 else
515 mapname = regionURI + regionName;
516
517 bool haveMatch = false;
518
519 if (rdatas != null && (rdatas.Count > 0))
520 {
521// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
522 foreach (RegionData rdata in rdatas)
523 {
524 if (count++ < maxNumber)
525 rinfos.Add(RegionData2RegionInfo(rdata));
526 if(rdata.RegionName == mapname)
527 {
528 haveMatch = true;
529 if(count == maxNumber)
530 {
531 rinfos.RemoveAt(count - 1);
532 rinfos.Add(RegionData2RegionInfo(rdata));
533 }
534 }
535 }
536 if(haveMatch)
537 return rinfos;
538 }
539
540 rdatas = m_Database.Get(Util.EscapeForLike(mapname)+ "%", scopeID);
541 if (rdatas != null && (rdatas.Count > 0))
542 {
543// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
544 foreach (RegionData rdata in rdatas)
545 {
546 if (count++ < maxNumber)
547 rinfos.Add(RegionData2RegionInfo(rdata));
548 if(rdata.RegionName == mapname)
549 {
550 haveMatch = true;
551 if(count == maxNumber)
552 {
553 rinfos.RemoveAt(count - 1);
554 rinfos.Add(RegionData2RegionInfo(rdata));
555 break;
556 }
557 }
558 }
559 if(haveMatch)
560 return rinfos;
561 }
562 if(!localGrid && !string.IsNullOrWhiteSpace(regionURI))
563 {
564 string HGname = regionURI +" "+ regionName; // include space for compatibility
565 GridRegion r = m_HypergridLinker.LinkRegion(scopeID, HGname);
566 if (r != null)
567 {
568 if( count == maxNumber)
569 rinfos.RemoveAt(count - 1);
570 rinfos.Add(r);
571 }
572 }
573 }
574 else if (rdatas != null && (rdatas.Count > 0))
588 { 575 {
589// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); 576// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
590 foreach (RegionData rdata in rdatas) 577 foreach (RegionData rdata in rdatas)
@@ -594,13 +581,6 @@ namespace OpenSim.Services.GridService
594 } 581 }
595 } 582 }
596 583
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; 584 return rinfos;
605 } 585 }
606 586
@@ -613,9 +593,30 @@ namespace OpenSim.Services.GridService
613 protected GridRegion GetHypergridRegionByName(UUID scopeID, string name) 593 protected GridRegion GetHypergridRegionByName(UUID scopeID, string name)
614 { 594 {
615 if (name.Contains(".")) 595 if (name.Contains("."))
616 return m_HypergridLinker.LinkRegion(scopeID, name); 596 {
617 else 597 string regionURI = "";
618 return null; 598 string regionName = "";
599 if(!Util.buildHGRegionURI(name, out regionURI, out regionName))
600 return null;
601
602 string mapname;
603 bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI);
604 if(localGrid)
605 mapname = regionName;
606 else
607 mapname = regionURI + regionName;
608
609 List<RegionData> rdatas = m_Database.Get(Util.EscapeForLike(mapname), scopeID);
610 if ((rdatas != null) && (rdatas.Count > 0))
611 return RegionData2RegionInfo(rdatas[0]); // get the first
612
613 if(!localGrid && !string.IsNullOrWhiteSpace(regionURI))
614 {
615 string HGname = regionURI +" "+ regionName;
616 return m_HypergridLinker.LinkRegion(scopeID, HGname);
617 }
618 }
619 return null;
619 } 620 }
620 621
621 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 622 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
@@ -666,7 +667,7 @@ namespace OpenSim.Services.GridService
666 return rinfo; 667 return rinfo;
667 } 668 }
668 669
669 #endregion 670 #endregion
670 671
671 public List<GridRegion> GetDefaultRegions(UUID scopeID) 672 public List<GridRegion> GetDefaultRegions(UUID scopeID)
672 { 673 {
@@ -705,7 +706,7 @@ namespace OpenSim.Services.GridService
705 int normalDefaultRegionsFoundOnline = ret.Count - hgDefaultRegionsFoundOnline; 706 int normalDefaultRegionsFoundOnline = ret.Count - hgDefaultRegionsFoundOnline;
706 707
707 m_log.DebugFormat( 708 m_log.DebugFormat(
708 "[GRID SERVICE]: GetDefaultHypergridRegions returning {0} hypergrid default and {1} normal default regions", 709 "[GRID SERVICE]: GetDefaultHypergridRegions returning {0} hypergrid default and {1} normal default regions",
709 hgDefaultRegionsFoundOnline, normalDefaultRegionsFoundOnline); 710 hgDefaultRegionsFoundOnline, normalDefaultRegionsFoundOnline);
710 711
711 return ret; 712 return ret;
@@ -742,7 +743,7 @@ namespace OpenSim.Services.GridService
742 m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count); 743 m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count);
743 return ret; 744 return ret;
744 } 745 }
745 746
746 public int GetRegionFlags(UUID scopeID, UUID regionID) 747 public int GetRegionFlags(UUID scopeID, UUID regionID)
747 { 748 {
748 RegionData region = m_Database.Get(regionID, scopeID); 749 RegionData region = m_Database.Get(regionID, scopeID);
@@ -804,14 +805,14 @@ namespace OpenSim.Services.GridService
804 return; 805 return;
805 } 806 }
806 807
807 List<RegionData> regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero); 808 List<RegionData> regions = m_Database.Get(0, 0, int.MaxValue, int.MaxValue, UUID.Zero);
808 809
809 OutputRegionsToConsoleSummary(regions); 810 OutputRegionsToConsoleSummary(regions);
810 } 811 }
811 812
812 private void HandleShowGridSize(string module, string[] cmd) 813 private void HandleShowGridSize(string module, string[] cmd)
813 { 814 {
814 List<RegionData> regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero); 815 List<RegionData> regions = m_Database.Get(0, 0, int.MaxValue, int.MaxValue, UUID.Zero);
815 816
816 double size = 0; 817 double size = 0;
817 818
@@ -872,7 +873,9 @@ namespace OpenSim.Services.GridService
872 return; 873 return;
873 } 874 }
874 875
876
875 RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero); 877 RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero);
878
876 if (region == null) 879 if (region == null)
877 { 880 {
878 MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y); 881 MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y);
@@ -889,7 +892,7 @@ namespace OpenSim.Services.GridService
889 ConsoleDisplayList dispList = new ConsoleDisplayList(); 892 ConsoleDisplayList dispList = new ConsoleDisplayList();
890 dispList.AddRow("Region Name", r.RegionName); 893 dispList.AddRow("Region Name", r.RegionName);
891 dispList.AddRow("Region ID", r.RegionID); 894 dispList.AddRow("Region ID", r.RegionID);
892 dispList.AddRow("Position", string.Format("{0},{1}", r.coordX, r.coordY)); 895 dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY));
893 dispList.AddRow("Size", string.Format("{0}x{1}", r.sizeX, r.sizeY)); 896 dispList.AddRow("Size", string.Format("{0}x{1}", r.sizeX, r.sizeY));
894 dispList.AddRow("URI", r.Data["serverURI"]); 897 dispList.AddRow("URI", r.Data["serverURI"]);
895 dispList.AddRow("Owner ID", r.Data["owner_uuid"]); 898 dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
@@ -907,9 +910,9 @@ namespace OpenSim.Services.GridService
907 private void OutputRegionsToConsoleSummary(List<RegionData> regions) 910 private void OutputRegionsToConsoleSummary(List<RegionData> regions)
908 { 911 {
909 ConsoleDisplayTable dispTable = new ConsoleDisplayTable(); 912 ConsoleDisplayTable dispTable = new ConsoleDisplayTable();
910 dispTable.AddColumn("Name", 44); 913 dispTable.AddColumn("Name", ConsoleDisplayUtil.RegionNameSize);
911 dispTable.AddColumn("ID", 36); 914 dispTable.AddColumn("ID", ConsoleDisplayUtil.UuidSize);
912 dispTable.AddColumn("Position", 11); 915 dispTable.AddColumn("Position", ConsoleDisplayUtil.CoordTupleSize);
913 dispTable.AddColumn("Size", 11); 916 dispTable.AddColumn("Size", 11);
914 dispTable.AddColumn("Flags", 60); 917 dispTable.AddColumn("Flags", 60);
915 918
@@ -992,7 +995,7 @@ namespace OpenSim.Services.GridService
992 } 995 }
993 996
994 /// <summary> 997 /// <summary>
995 /// Gets the grid extra service URls we wish for the region to send in OpenSimExtras to dynamically refresh 998 /// 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. 999 /// parameters in the viewer used to access services like map, search and destination guides.
997 /// <para>see "SimulatorFeaturesModule" </para> 1000 /// <para>see "SimulatorFeaturesModule" </para>
998 /// </summary> 1001 /// </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..7c384d5 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -119,13 +119,13 @@ namespace OpenSim.Services.GridService
119 if (scope != string.Empty) 119 if (scope != string.Empty)
120 UUID.TryParse(scope, out m_ScopeID); 120 UUID.TryParse(scope, out m_ScopeID);
121 121
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. 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_MapTileDirectory = "../caches/" + Path.GetFileName(gridConfig.GetString("MapTileDirectory", "maptiles")); 123 m_MapTileDirectory = Path.Combine(Util.cacheDir(), Path.GetFileName(gridConfig.GetString("MapTileDirectory", "maptiles")));
124 124
125 m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", 125 m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
126 new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); 126 new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty);
127 // Legacy. Remove soon! 127 // Legacy. Remove soon!
128 m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper); 128//// m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper);
129 try 129 try
130 { 130 {
131 m_ThisGatekeeperURI = new Uri(m_ThisGatekeeper); 131 m_ThisGatekeeperURI = new Uri(m_ThisGatekeeper);
@@ -135,6 +135,12 @@ namespace OpenSim.Services.GridService
135 m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper); 135 m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper);
136 } 136 }
137 137
138 m_ThisGatekeeper = m_ThisGatekeeperURI.AbsoluteUri;
139 if(m_ThisGatekeeperURI.Port == 80)
140 m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":80/";
141 else if(m_ThisGatekeeperURI.Port == 443)
142 m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":443/";
143
138 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); 144 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);
139 145
140 m_log.Debug("[HYPERGRID LINKER]: Loaded all services..."); 146 m_log.Debug("[HYPERGRID LINKER]: Loaded all services...");
@@ -186,85 +192,29 @@ namespace OpenSim.Services.GridService
186 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); 192 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
187 } 193 }
188 194
195 public bool IsLocalGrid(string serverURI)
196 {
197 return serverURI == m_ThisGatekeeper;
198 }
199
189 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) 200 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason)
190 { 201 {
191 reason = string.Empty; 202 reason = string.Empty;
192 GridRegion regInfo = null; 203 GridRegion regInfo = null;
193 204
194 mapName = mapName.Trim(); 205 string serverURI = string.Empty;
206 string regionName = string.Empty;
195 207
196 if (!mapName.StartsWith("http")) 208 if(!Util.buildHGRegionURI(mapName, out serverURI, out regionName))
197 { 209 {
198 // Formats: grid.example.com:8002:region name 210 reason = "Wrong URI format for link-region";
199 // grid.example.com:region name 211 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 } 212 }
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
247 string[] parts = mapName.Split(new char[] { ' ' });
248
249 if (parts.Length == 0)
250 {
251 reason = "Wrong format for link-region";
252 return null;
253 }
254 213
255 serverURI = parts[0]; 214 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason))
256 215 {
257 if (parts.Length >= 2) 216 regInfo.RegionName = serverURI + regionName;
258 { 217 return regInfo;
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 } 218 }
269 219
270 return null; 220 return null;
@@ -285,7 +235,7 @@ namespace OpenSim.Services.GridService
285 235
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) 236 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 { 237 {
288 m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>", 238 m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>",
289 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), 239 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
290 remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc)); 240 remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));
291 241
@@ -361,7 +311,9 @@ namespace OpenSim.Services.GridService
361 UUID regionID = UUID.Zero; 311 UUID regionID = UUID.Zero;
362 string externalName = string.Empty; 312 string externalName = string.Empty;
363 string imageURL = string.Empty; 313 string imageURL = string.Empty;
364 if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason)) 314 int sizeX = (int)Constants.RegionSize;
315 int sizeY = (int)Constants.RegionSize;
316 if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason, out sizeX, out sizeY))
365 return false; 317 return false;
366 318
367 if (regionID == UUID.Zero) 319 if (regionID == UUID.Zero)
@@ -374,13 +326,14 @@ namespace OpenSim.Services.GridService
374 region = m_GridService.GetRegionByUUID(scopeID, regionID); 326 region = m_GridService.GetRegionByUUID(scopeID, regionID);
375 if (region != null) 327 if (region != null)
376 { 328 {
377 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>", 329 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; 330 regInfo = region;
380 return true; 331 return true;
381 } 332 }
382 333
383 regInfo.RegionID = regionID; 334 regInfo.RegionID = regionID;
335 regInfo.RegionSizeX = sizeX;
336 regInfo.RegionSizeY = sizeY;
384 337
385 if (externalName == string.Empty) 338 if (externalName == string.Empty)
386 regInfo.RegionName = regInfo.ServerURI; 339 regInfo.RegionName = regInfo.ServerURI;
@@ -412,7 +365,7 @@ namespace OpenSim.Services.GridService
412 OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); 365 OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]);
413 if ((rflags & OpenSim.Framework.RegionFlags.Hyperlink) != 0) 366 if ((rflags & OpenSim.Framework.RegionFlags.Hyperlink) != 0)
414 { 367 {
415 regInfo = new GridRegion(); 368 regInfo = new GridRegion();
416 regInfo.RegionID = regions[0].RegionID; 369 regInfo.RegionID = regions[0].RegionID;
417 regInfo.ScopeID = m_ScopeID; 370 regInfo.ScopeID = m_ScopeID;
418 } 371 }
@@ -474,7 +427,7 @@ namespace OpenSim.Services.GridService
474 { 427 {
475 MainConsole.Instance.Output( 428 MainConsole.Instance.Output(
476 String.Format("{0}\n{2,-32} {1}\n", 429 String.Format("{0}\n{2,-32} {1}\n",
477 r.RegionName, r.RegionID, 430 r.RegionName, r.RegionID,
478 String.Format("{0},{1} ({2},{3})", r.posX, r.posY, 431 String.Format("{0},{1} ({2},{3})", r.posX, r.posY,
479 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY) 432 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY)
480 ) 433 )
@@ -556,7 +509,7 @@ namespace OpenSim.Services.GridService
556 if (cmdparams[2].StartsWith("http")) 509 if (cmdparams[2].StartsWith("http"))
557 { 510 {
558 RunLinkRegionCommand(cmdparams); 511 RunLinkRegionCommand(cmdparams);
559 } 512 }
560 else if (cmdparams[2].Contains(":")) 513 else if (cmdparams[2].Contains(":"))
561 { 514 {
562 // New format 515 // 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