aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/GridService
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/GridService')
-rw-r--r--OpenSim/Services/GridService/GridService.cs264
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs141
-rw-r--r--OpenSim/Services/GridService/Properties/AssemblyInfo.cs2
3 files changed, 336 insertions, 71 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 6f610f8..8293c18 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -46,6 +46,7 @@ namespace OpenSim.Services.GridService
46 private static readonly ILog m_log = 46 private static readonly ILog m_log =
47 LogManager.GetLogger( 47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType); 48 MethodBase.GetCurrentMethod().DeclaringType);
49 private string LogHeader = "[GRID SERVICE]";
49 50
50 private bool m_DeleteOnUnregister = true; 51 private bool m_DeleteOnUnregister = true;
51 private static GridService m_RootInstance = null; 52 private static GridService m_RootInstance = null;
@@ -56,7 +57,13 @@ namespace OpenSim.Services.GridService
56 protected bool m_AllowDuplicateNames = false; 57 protected bool m_AllowDuplicateNames = false;
57 protected bool m_AllowHypergridMapSearch = false; 58 protected bool m_AllowHypergridMapSearch = false;
58 59
60<<<<<<< HEAD
61 protected bool m_SuppressVarregionOverlapCheckOnRegistration = false;
62
63 private static Dictionary<string,object> m_ExtraFeatures = new Dictionary<string, object>();
64=======
59 private static Dictionary<string, object> m_ExtraFeatures = new Dictionary<string, object>(); 65 private static Dictionary<string, object> m_ExtraFeatures = new Dictionary<string, object>();
66>>>>>>> avn/ubitvar
60 67
61 public GridService(IConfigSource config) 68 public GridService(IConfigSource config)
62 : base(config) 69 : base(config)
@@ -65,6 +72,9 @@ namespace OpenSim.Services.GridService
65 72
66 m_config = config; 73 m_config = config;
67 IConfig gridConfig = config.Configs["GridService"]; 74 IConfig gridConfig = config.Configs["GridService"];
75
76 bool suppressConsoleCommands = false;
77
68 if (gridConfig != null) 78 if (gridConfig != null)
69 { 79 {
70 m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true); 80 m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true);
@@ -78,13 +88,19 @@ namespace OpenSim.Services.GridService
78 } 88 }
79 m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); 89 m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
80 m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch); 90 m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch);
91
92 m_SuppressVarregionOverlapCheckOnRegistration = gridConfig.GetBoolean("SuppressVarregionOverlapCheckOnRegistration", m_SuppressVarregionOverlapCheckOnRegistration);
93
94 // This service is also used locally by a simulator running in grid mode. This switches prevents
95 // inappropriate console commands from being registered
96 suppressConsoleCommands = gridConfig.GetBoolean("SuppressConsoleCommands", suppressConsoleCommands);
81 } 97 }
82 98
83 if (m_RootInstance == null) 99 if (m_RootInstance == null)
84 { 100 {
85 m_RootInstance = this; 101 m_RootInstance = this;
86 102
87 if (MainConsole.Instance != null) 103 if (!suppressConsoleCommands && MainConsole.Instance != null)
88 { 104 {
89 MainConsole.Instance.Commands.AddCommand("Regions", true, 105 MainConsole.Instance.Commands.AddCommand("Regions", true,
90 "deregister region id", 106 "deregister region id",
@@ -93,17 +109,12 @@ namespace OpenSim.Services.GridService
93 String.Empty, 109 String.Empty,
94 HandleDeregisterRegion); 110 HandleDeregisterRegion);
95 111
96 // A messy way of stopping this command being added if we are in standalone (since the simulator 112 MainConsole.Instance.Commands.AddCommand("Regions", true,
97 // has an identically named command 113 "show regions",
98 // 114 "show regions",
99 // XXX: We're relying on the OpenSimulator version being registered first, which is not well defined. 115 "Show details on all regions",
100 if (MainConsole.Instance.Commands.Resolve(new string[] { "show", "regions" }).Length == 0) 116 String.Empty,
101 MainConsole.Instance.Commands.AddCommand("Regions", true, 117 HandleShowRegions);
102 "show regions",
103 "show regions",
104 "Show details on all regions",
105 String.Empty,
106 HandleShowRegions);
107 118
108 MainConsole.Instance.Commands.AddCommand("Regions", true, 119 MainConsole.Instance.Commands.AddCommand("Regions", true,
109 "show region name", 120 "show region name",
@@ -119,13 +130,24 @@ namespace OpenSim.Services.GridService
119 "For example, show region at 1000 1000", 130 "For example, show region at 1000 1000",
120 HandleShowRegionAt); 131 HandleShowRegionAt);
121 132
122 MainConsole.Instance.Commands.AddCommand("Regions", true, 133 MainConsole.Instance.Commands.AddCommand("General", true,
123 "set region flags", 134 "show grid size",
124 "set region flags <Region name> <flags>", 135 "show grid size",
125 "Set database flags for region", 136 "Show the current grid size (excluding hyperlink references)",
126 String.Empty, 137 String.Empty,
127 HandleSetFlags); 138 HandleShowGridSize);
139
140 MainConsole.Instance.Commands.AddCommand("Regions", true,
141 "set region flags",
142 "set region flags <Region name> <flags>",
143 "Set database flags for region",
144 String.Empty,
145 HandleSetFlags);
128 } 146 }
147
148 if (!suppressConsoleCommands)
149 SetExtraServiceURLs(config);
150
129 m_HypergridLinker = new HypergridLinker(m_config, this, m_Database); 151 m_HypergridLinker = new HypergridLinker(m_config, this, m_Database);
130 } 152 }
131 } 153 }
@@ -137,9 +159,15 @@ namespace OpenSim.Services.GridService
137 159
138 if (loginConfig == null || gridConfig == null) 160 if (loginConfig == null || gridConfig == null)
139 return; 161 return;
162<<<<<<< HEAD
163
164 string configVal;
165
166=======
140 167
141 string configVal; 168 string configVal;
142 169
170>>>>>>> avn/ubitvar
143 configVal = loginConfig.GetString("SearchURL", string.Empty); 171 configVal = loginConfig.GetString("SearchURL", string.Empty);
144 if (!string.IsNullOrEmpty(configVal)) 172 if (!string.IsNullOrEmpty(configVal))
145 m_ExtraFeatures["search-server-url"] = configVal; 173 m_ExtraFeatures["search-server-url"] = configVal;
@@ -183,14 +211,26 @@ namespace OpenSim.Services.GridService
183 if (regionInfos.RegionID == UUID.Zero) 211 if (regionInfos.RegionID == UUID.Zero)
184 return "Invalid RegionID - cannot be zero UUID"; 212 return "Invalid RegionID - cannot be zero UUID";
185 213
214<<<<<<< HEAD
215 String reason = "Region overlaps another region";
216 RegionData region = FindAnyConflictingRegion(regionInfos, scopeID, out reason);
217 // If there is a conflicting region, if it has the same ID and same coordinates
218 // then it is a region re-registering (permissions and ownership checked later).
219 if ((region != null)
220 && ( (region.coordX != regionInfos.RegionCoordX)
221 || (region.coordY != regionInfos.RegionCoordY)
222 || (region.RegionID != regionInfos.RegionID) )
223 )
224=======
186 // we should not need to check for overlaps 225 // we should not need to check for overlaps
187 226
188 RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); 227 RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
189 if ((region != null) && (region.RegionID != regionInfos.RegionID)) 228 if ((region != null) && (region.RegionID != regionInfos.RegionID))
229>>>>>>> avn/ubitvar
190 { 230 {
191 m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", 231 // If not same ID and same coordinates, this new region has conflicts and can't be registered.
192 regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); 232 m_log.WarnFormat("{0} Register region conflict in scope {1}. {2}", LogHeader, scopeID, reason);
193 return "Region overlaps another region"; 233 return reason;
194 } 234 }
195 235
196 if (region != null) 236 if (region != null)
@@ -313,13 +353,121 @@ namespace OpenSim.Services.GridService
313 m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); 353 m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e);
314 } 354 }
315 355
316 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3} with flags {4}", 356 m_log.DebugFormat
317 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY, 357 ("[GRID SERVICE]: Region {0} ({1}, {2}x{3}) registered at {4},{5} with flags {6}",
358 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionSizeX, regionInfos.RegionSizeY,
359 regionInfos.RegionCoordX, regionInfos.RegionCoordY,
318 (OpenSim.Framework.RegionFlags)flags); 360 (OpenSim.Framework.RegionFlags)flags);
319 361
320 return String.Empty; 362 return String.Empty;
321 } 363 }
322 364
365 /// <summary>
366 /// Search the region map for regions conflicting with this region.
367 /// The region to be added is passed and we look for any existing regions that are
368 /// in the requested location, that are large varregions that overlap this region, or
369 /// are previously defined regions that would lie under this new region.
370 /// </summary>
371 /// <param name="regionInfos">Information on region requested to be added to the world map</param>
372 /// <param name="scopeID">Grid id for region</param>
373 /// <param name="reason">The reason the returned region conflicts with passed region</param>
374 /// <returns></returns>
375 private RegionData FindAnyConflictingRegion(GridRegion regionInfos, UUID scopeID, out string reason)
376 {
377 reason = "Reregistration";
378 // First see if there is an existing region right where this region is trying to go
379 // (We keep this result so it can be returned if suppressing errors)
380 RegionData noErrorRegion = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
381 RegionData region = noErrorRegion;
382 if (region != null
383 && region.RegionID == regionInfos.RegionID
384 && region.sizeX == regionInfos.RegionSizeX
385 && region.sizeY == regionInfos.RegionSizeY)
386 {
387 // If this seems to be exactly the same region, return this as it could be
388 // a re-registration (permissions checked by calling routine).
389 m_log.DebugFormat("{0} FindAnyConflictingRegion: re-register of {1}",
390 LogHeader, RegionString(regionInfos));
391 return region;
392 }
393
394 // No region exactly there or we're resizing an existing region.
395 // Fetch regions that could be varregions overlapping requested location.
396 int xmin = regionInfos.RegionLocX - (int)Constants.MaximumRegionSize + 10;
397 int xmax = regionInfos.RegionLocX;
398 int ymin = regionInfos.RegionLocY - (int)Constants.MaximumRegionSize + 10;
399 int ymax = regionInfos.RegionLocY;
400 List<RegionData> rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID);
401 foreach (RegionData rdata in rdatas)
402 {
403 // m_log.DebugFormat("{0} FindAnyConflictingRegion: find existing. Checking {1}", LogHeader, RegionString(rdata) );
404 if ( (rdata.posX + rdata.sizeX > regionInfos.RegionLocX)
405 && (rdata.posY + rdata.sizeY > regionInfos.RegionLocY) )
406 {
407 region = rdata;
408 m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of {1} by existing varregion {2}",
409 LogHeader, RegionString(regionInfos), RegionString(region));
410 reason = String.Format("Region location is overlapped by existing varregion {0}",
411 RegionString(region));
412
413 if (m_SuppressVarregionOverlapCheckOnRegistration)
414 region = noErrorRegion;
415 return region;
416 }
417 }
418
419 // There isn't a region that overlaps this potential region.
420 // See if this potential region overlaps an existing region.
421 // First, a shortcut of not looking for overlap if new region is legacy region sized
422 // and connot overlap anything.
423 if (regionInfos.RegionSizeX != Constants.RegionSize
424 || regionInfos.RegionSizeY != Constants.RegionSize)
425 {
426 // trim range looked for so we don't pick up neighbor regions just off the edges
427 xmin = regionInfos.RegionLocX;
428 xmax = regionInfos.RegionLocX + regionInfos.RegionSizeX - 10;
429 ymin = regionInfos.RegionLocY;
430 ymax = regionInfos.RegionLocY + regionInfos.RegionSizeY - 10;
431 rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID);
432
433 // If the region is being resized, the found region could be ourself.
434 foreach (RegionData rdata in rdatas)
435 {
436 // m_log.DebugFormat("{0} FindAnyConflictingRegion: see if overlap. Checking {1}", LogHeader, RegionString(rdata) );
437 if (region == null || region.RegionID != regionInfos.RegionID)
438 {
439 region = rdata;
440 m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of varregion {1} overlaps existing region {2}",
441 LogHeader, RegionString(regionInfos), RegionString(region));
442 reason = String.Format("Region {0} would overlap existing region {1}",
443 RegionString(regionInfos), RegionString(region));
444
445 if (m_SuppressVarregionOverlapCheckOnRegistration)
446 region = noErrorRegion;
447 return region;
448 }
449 }
450 }
451
452 // If we get here, region is either null (nothing found here) or
453 // is the non-conflicting region found at the location being requested.
454 return region;
455 }
456
457 // String describing name and region location of passed region
458 private String RegionString(RegionData reg)
459 {
460 return String.Format("{0}/{1} at <{2},{3}>",
461 reg.RegionName, reg.RegionID, reg.coordX, reg.coordY);
462 }
463
464 // String describing name and region location of passed region
465 private String RegionString(GridRegion reg)
466 {
467 return String.Format("{0}/{1} at <{2},{3}>",
468 reg.RegionName, reg.RegionID, reg.RegionCoordX, reg.RegionCoordY);
469 }
470
323 public bool DeregisterRegion(UUID regionID) 471 public bool DeregisterRegion(UUID regionID)
324 { 472 {
325 RegionData region = m_Database.Get(regionID, UUID.Zero); 473 RegionData region = m_Database.Get(regionID, UUID.Zero);
@@ -360,7 +508,11 @@ namespace OpenSim.Services.GridService
360 if (region != null) 508 if (region != null)
361 { 509 {
362 // Not really? Maybe? 510 // Not really? Maybe?
511<<<<<<< HEAD
512 // The adjacent regions are presumed to be the same size as the current region
513=======
363/* this fails wiht var regions. My_sql db should now handle var regions 514/* this fails wiht var regions. My_sql db should now handle var regions
515>>>>>>> avn/ubitvar
364 List<RegionData> rdatas = m_Database.Get( 516 List<RegionData> rdatas = m_Database.Get(
365 region.posX - region.sizeX - 1, region.posY - region.sizeY - 1, 517 region.posX - region.sizeX - 1, region.posY - region.sizeY - 1,
366 region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID); 518 region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID);
@@ -380,7 +532,11 @@ namespace OpenSim.Services.GridService
380 } 532 }
381 } 533 }
382 534
383// m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighbours", region.RegionName, rinfos.Count); 535 // string rNames = "";
536 // foreach (GridRegion gr in rinfos)
537 // rNames += gr.RegionName + ",";
538 // m_log.DebugFormat("{0} region {1} has {2} neighbours ({3})",
539 // LogHeader, region.RegionName, rinfos.Count, rNames);
384 } 540 }
385 else 541 else
386 { 542 {
@@ -409,13 +565,24 @@ namespace OpenSim.Services.GridService
409 565
410 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 566 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
411 { 567 {
412 int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; 568 uint regionX = Util.WorldToRegionLoc((uint)x);
413 int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; 569 uint regionY = Util.WorldToRegionLoc((uint)y);
570 int snapX = (int)Util.RegionToWorldLoc(regionX);
571 int snapY = (int)Util.RegionToWorldLoc(regionY);
572
414 RegionData rdata = m_Database.Get(snapX, snapY, scopeID); 573 RegionData rdata = m_Database.Get(snapX, snapY, scopeID);
415 if (rdata != null) 574 if (rdata != null)
575 {
576 m_log.DebugFormat("{0} GetRegionByPosition. Found region {1} in database. Pos=<{2},{3}>",
577 LogHeader, rdata.RegionName, regionX, regionY);
416 return RegionData2RegionInfo(rdata); 578 return RegionData2RegionInfo(rdata);
417 579 }
418 return null; 580 else
581 {
582 m_log.DebugFormat("{0} GetRegionByPosition. Did not find region in database. Pos=<{1},{2}>",
583 LogHeader, regionX, regionY);
584 return null;
585 }
419 } 586 }
420 587
421 public GridRegion GetRegionByName(UUID scopeID, string name) 588 public GridRegion GetRegionByName(UUID scopeID, string name)
@@ -668,6 +835,27 @@ namespace OpenSim.Services.GridService
668 OutputRegionsToConsoleSummary(regions); 835 OutputRegionsToConsoleSummary(regions);
669 } 836 }
670 837
838 private void HandleShowGridSize(string module, string[] cmd)
839 {
840 List<RegionData> regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero);
841
842 double size = 0;
843
844 foreach (RegionData region in regions)
845 {
846 int flags = Convert.ToInt32(region.Data["flags"]);
847
848 if ((flags & (int)Framework.RegionFlags.Hyperlink) == 0)
849 size += region.sizeX * region.sizeY;
850 }
851
852 MainConsole.Instance.Output("This is a very rough approximation.");
853 MainConsole.Instance.Output("Although it will not count regions that are actually links to others over the Hypergrid, ");
854 MainConsole.Instance.Output("it will count regions that are inactive but were not deregistered from the grid service");
855 MainConsole.Instance.Output("(e.g. simulator crashed rather than shutting down cleanly).\n");
856
857 MainConsole.Instance.OutputFormat("Grid size: {0} km squared.", size / 1000000);
858 }
671 859
672 private void HandleShowRegion(string module, string[] cmd) 860 private void HandleShowRegion(string module, string[] cmd)
673 { 861 {
@@ -697,20 +885,24 @@ namespace OpenSim.Services.GridService
697 return; 885 return;
698 } 886 }
699 887
700 int x, y; 888 uint x, y;
701 if (!int.TryParse(cmd[3], out x)) 889 if (!uint.TryParse(cmd[3], out x))
702 { 890 {
703 MainConsole.Instance.Output("x-coord must be an integer"); 891 MainConsole.Instance.Output("x-coord must be an integer");
704 return; 892 return;
705 } 893 }
706 894
707 if (!int.TryParse(cmd[4], out y)) 895 if (!uint.TryParse(cmd[4], out y))
708 { 896 {
709 MainConsole.Instance.Output("y-coord must be an integer"); 897 MainConsole.Instance.Output("y-coord must be an integer");
710 return; 898 return;
711 } 899 }
712 900
901<<<<<<< HEAD
902 RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero);
903=======
713 RegionData region = m_Database.Get((int)Util.RegionToWorldLoc((uint)x), (int)Util.RegionToWorldLoc((uint)y), UUID.Zero); 904 RegionData region = m_Database.Get((int)Util.RegionToWorldLoc((uint)x), (int)Util.RegionToWorldLoc((uint)y), UUID.Zero);
905>>>>>>> avn/ubitvar
714 if (region == null) 906 if (region == null)
715 { 907 {
716 MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y); 908 MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y);
@@ -727,7 +919,11 @@ namespace OpenSim.Services.GridService
727 ConsoleDisplayList dispList = new ConsoleDisplayList(); 919 ConsoleDisplayList dispList = new ConsoleDisplayList();
728 dispList.AddRow("Region Name", r.RegionName); 920 dispList.AddRow("Region Name", r.RegionName);
729 dispList.AddRow("Region ID", r.RegionID); 921 dispList.AddRow("Region ID", r.RegionID);
922<<<<<<< HEAD
923 dispList.AddRow("Position", string.Format("{0},{1}", r.coordX, r.coordY));
924=======
730 dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY)); 925 dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY));
926>>>>>>> avn/ubitvar
731 dispList.AddRow("Size", string.Format("{0}x{1}", r.sizeX, r.sizeY)); 927 dispList.AddRow("Size", string.Format("{0}x{1}", r.sizeX, r.sizeY));
732 dispList.AddRow("URI", r.Data["serverURI"]); 928 dispList.AddRow("URI", r.Data["serverURI"]);
733 dispList.AddRow("Owner ID", r.Data["owner_uuid"]); 929 dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
@@ -745,10 +941,10 @@ namespace OpenSim.Services.GridService
745 private void OutputRegionsToConsoleSummary(List<RegionData> regions) 941 private void OutputRegionsToConsoleSummary(List<RegionData> regions)
746 { 942 {
747 ConsoleDisplayTable dispTable = new ConsoleDisplayTable(); 943 ConsoleDisplayTable dispTable = new ConsoleDisplayTable();
748 dispTable.AddColumn("Name", 16); 944 dispTable.AddColumn("Name", 44);
749 dispTable.AddColumn("ID", 36); 945 dispTable.AddColumn("ID", 36);
750 dispTable.AddColumn("Position", 11); 946 dispTable.AddColumn("Position", 11);
751 dispTable.AddColumn("Owner ID", 36); 947 dispTable.AddColumn("Size", 11);
752 dispTable.AddColumn("Flags", 60); 948 dispTable.AddColumn("Flags", 60);
753 949
754 foreach (RegionData r in regions) 950 foreach (RegionData r in regions)
@@ -758,7 +954,7 @@ namespace OpenSim.Services.GridService
758 r.RegionName, 954 r.RegionName,
759 r.RegionID.ToString(), 955 r.RegionID.ToString(),
760 string.Format("{0},{1}", r.coordX, r.coordY), 956 string.Format("{0},{1}", r.coordX, r.coordY),
761 r.Data["owner_uuid"].ToString(), 957 string.Format("{0}x{1}", r.sizeX, r.sizeY),
762 flags.ToString()); 958 flags.ToString());
763 } 959 }
764 960
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index 0448b54..b4577b0 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -47,7 +47,7 @@ using OpenMetaverse;
47 47
48namespace OpenSim.Services.GridService 48namespace OpenSim.Services.GridService
49{ 49{
50 public class HypergridLinker 50 public class HypergridLinker : IHypergridLinker
51 { 51 {
52 private static readonly ILog m_log = 52 private static readonly ILog m_log =
53 LogManager.GetLogger( 53 LogManager.GetLogger(
@@ -68,10 +68,6 @@ namespace OpenSim.Services.GridService
68 protected string m_ThisGatekeeper = string.Empty; 68 protected string m_ThisGatekeeper = string.Empty;
69 protected Uri m_ThisGatekeeperURI = null; 69 protected Uri m_ThisGatekeeperURI = null;
70 70
71 // Hyperlink regions are hyperlinks on the map
72 public readonly Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>();
73 protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>();
74
75 protected GridRegion m_DefaultRegion; 71 protected GridRegion m_DefaultRegion;
76 protected GridRegion DefaultRegion 72 protected GridRegion DefaultRegion
77 { 73 {
@@ -160,18 +156,18 @@ namespace OpenSim.Services.GridService
160 156
161 if (MainConsole.Instance != null) 157 if (MainConsole.Instance != null)
162 { 158 {
163 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", 159 MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
164 "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]", 160 "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]",
165 "Link a HyperGrid Region. Examples for <ServerURI>: http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand); 161 "Link a HyperGrid Region. Examples for <ServerURI>: http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand);
166 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", 162 MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
167 "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]", 163 "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]",
168 "Link a hypergrid region (deprecated)", RunCommand); 164 "Link a hypergrid region (deprecated)", RunCommand);
169 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region", 165 MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "unlink-region",
170 "unlink-region <local name>", 166 "unlink-region <local name>",
171 "Unlink a hypergrid region", RunCommand); 167 "Unlink a hypergrid region", RunCommand);
172 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>]", 168 MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-mapping", "link-mapping [<x> <y>]",
173 "Set local coordinate to map HG regions to", RunCommand); 169 "Set local coordinate to map HG regions to", RunCommand);
174 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks", 170 MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "show hyperlinks", "show hyperlinks",
175 "List the HG regions", HandleShow); 171 "List the HG regions", HandleShow);
176 } 172 }
177 } 173 }
@@ -190,7 +186,7 @@ namespace OpenSim.Services.GridService
190 private static Random random = new Random(); 186 private static Random random = new Random();
191 187
192 // From the command line link-region (obsolete) and the map 188 // From the command line link-region (obsolete) and the map
193 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason) 189 private GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason)
194 { 190 {
195 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); 191 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
196 } 192 }
@@ -200,24 +196,36 @@ namespace OpenSim.Services.GridService
200 reason = string.Empty; 196 reason = string.Empty;
201 GridRegion regInfo = null; 197 GridRegion regInfo = null;
202 198
199 mapName = mapName.Trim();
200
203 if (!mapName.StartsWith("http")) 201 if (!mapName.StartsWith("http"))
204 { 202 {
205 string host = "127.0.0.1"; 203 // Formats: grid.example.com:8002:region name
206 string portstr; 204 // grid.example.com:region name
205 // grid.example.com:8002
206 // grid.example.com
207
208 string host;
209 uint port = 80;
207 string regionName = ""; 210 string regionName = "";
208 uint port = 0; 211
209 string[] parts = mapName.Split(new char[] { ':' }); 212 string[] parts = mapName.Split(new char[] { ':' });
210 if (parts.Length >= 1) 213
214 if (parts.Length == 0)
211 { 215 {
212 host = parts[0]; 216 reason = "Wrong format for link-region";
217 return null;
213 } 218 }
219
220 host = parts[0];
221
214 if (parts.Length >= 2) 222 if (parts.Length >= 2)
215 { 223 {
216 portstr = parts[1]; 224 // If it's a number then assume it's a port. Otherwise, it's a region name.
217 //m_log.Debug("-- port = " + portstr); 225 if (!UInt32.TryParse(parts[1], out port))
218 if (!UInt32.TryParse(portstr, out port))
219 regionName = parts[1]; 226 regionName = parts[1];
220 } 227 }
228
221 // always take the last one 229 // always take the last one
222 if (parts.Length >= 3) 230 if (parts.Length >= 3)
223 { 231 {
@@ -234,14 +242,30 @@ namespace OpenSim.Services.GridService
234 } 242 }
235 else 243 else
236 { 244 {
237 string[] parts = mapName.Split(new char[] {' '}); 245 // Formats: http://grid.example.com region name
238 string regionName = String.Empty; 246 // http://grid.example.com "region name"
239 if (parts.Length > 1) 247 // http://grid.example.com
248
249 string serverURI;
250 string regionName = "";
251
252 string[] parts = mapName.Split(new char[] { ' ' });
253
254 if (parts.Length == 0)
240 { 255 {
241 regionName = mapName.Substring(parts[0].Length + 1); 256 reason = "Wrong format for link-region";
242 regionName = regionName.Trim(new char[] {'"'}); 257 return null;
243 } 258 }
244 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, parts[0], ownerID, out regInfo, out reason)) 259
260 serverURI = parts[0];
261
262 if (parts.Length >= 2)
263 {
264 regionName = mapName.Substring(serverURI.Length);
265 regionName = regionName.Trim(new char[] { '"', ' ' });
266 }
267
268 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason))
245 { 269 {
246 regInfo.RegionName = mapName; 270 regInfo.RegionName = mapName;
247 return regInfo; 271 return regInfo;
@@ -250,15 +274,23 @@ namespace OpenSim.Services.GridService
250 274
251 return null; 275 return null;
252 } 276 }
253 277
254 public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, UUID ownerID, out GridRegion regInfo, out string reason) 278 private bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, UUID ownerID, out GridRegion regInfo, out string reason)
255 { 279 {
256 return TryCreateLink(scopeID, xloc, yloc, remoteRegionName, externalPort, externalHostName, null, ownerID, out regInfo, out reason); 280 return TryCreateLink(scopeID, xloc, yloc, remoteRegionName, externalPort, externalHostName, null, ownerID, out regInfo, out reason);
257 } 281 }
258 282
259 public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) 283 private bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason)
284 {
285 lock (this)
286 {
287 return TryCreateLinkImpl(scopeID, xloc, yloc, remoteRegionName, externalPort, externalHostName, serverURI, ownerID, out regInfo, out reason);
288 }
289 }
290
291 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)
260 { 292 {
261 m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}", 293 m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>",
262 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), 294 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
263 remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc)); 295 remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));
264 296
@@ -266,15 +298,15 @@ namespace OpenSim.Services.GridService
266 Uri uri = null; 298 Uri uri = null;
267 299
268 regInfo = new GridRegion(); 300 regInfo = new GridRegion();
269 if ( externalPort > 0) 301 if (externalPort > 0)
270 regInfo.HttpPort = externalPort; 302 regInfo.HttpPort = externalPort;
271 else 303 else
272 regInfo.HttpPort = 0; 304 regInfo.HttpPort = 80;
273 if ( externalHostName != null) 305 if (externalHostName != null)
274 regInfo.ExternalHostName = externalHostName; 306 regInfo.ExternalHostName = externalHostName;
275 else 307 else
276 regInfo.ExternalHostName = "0.0.0.0"; 308 regInfo.ExternalHostName = "0.0.0.0";
277 if ( serverURI != null) 309 if (serverURI != null)
278 { 310 {
279 regInfo.ServerURI = serverURI; 311 regInfo.ServerURI = serverURI;
280 try 312 try
@@ -286,7 +318,7 @@ namespace OpenSim.Services.GridService
286 catch {} 318 catch {}
287 } 319 }
288 320
289 if ( remoteRegionName != string.Empty ) 321 if (remoteRegionName != string.Empty)
290 regInfo.RegionName = remoteRegionName; 322 regInfo.RegionName = remoteRegionName;
291 323
292 regInfo.RegionLocX = xloc; 324 regInfo.RegionLocX = xloc;
@@ -299,6 +331,7 @@ namespace OpenSim.Services.GridService
299 { 331 {
300 if (regInfo.ExternalHostName == m_ThisGatekeeperURI.Host && regInfo.HttpPort == m_ThisGatekeeperURI.Port) 332 if (regInfo.ExternalHostName == m_ThisGatekeeperURI.Host && regInfo.HttpPort == m_ThisGatekeeperURI.Port)
301 { 333 {
334 m_log.InfoFormat("[HYPERGRID LINKER]: Cannot hyperlink to regions on the same grid");
302 reason = "Cannot hyperlink to regions on the same grid"; 335 reason = "Cannot hyperlink to regions on the same grid";
303 return false; 336 return false;
304 } 337 }
@@ -310,7 +343,11 @@ namespace OpenSim.Services.GridService
310 GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY); 343 GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY);
311 if (region != null) 344 if (region != null)
312 { 345 {
346<<<<<<< HEAD
347 m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates <{0},{1}> are already occupied by region {2} with uuid {3}",
348=======
313 m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}", 349 m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}",
350>>>>>>> avn/ubitvar
314 Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY), 351 Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY),
315 region.RegionName, region.RegionID); 352 region.RegionName, region.RegionID);
316 reason = "Coordinates are already in use"; 353 reason = "Coordinates are already in use";
@@ -346,8 +383,13 @@ namespace OpenSim.Services.GridService
346 region = m_GridService.GetRegionByUUID(scopeID, regionID); 383 region = m_GridService.GetRegionByUUID(scopeID, regionID);
347 if (region != null) 384 if (region != null)
348 { 385 {
386<<<<<<< HEAD
387 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>",
388 Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
389=======
349 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", 390 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}",
350 Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY)); 391 Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY));
392>>>>>>> avn/ubitvar
351 regInfo = region; 393 regInfo = region;
352 return true; 394 return true;
353 } 395 }
@@ -381,7 +423,8 @@ namespace OpenSim.Services.GridService
381 regInfo.RegionSecret = handle.ToString(); 423 regInfo.RegionSecret = handle.ToString();
382 424
383 AddHyperlinkRegion(regInfo, handle); 425 AddHyperlinkRegion(regInfo, handle);
384 m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} with image {1}", regInfo.RegionName, regInfo.TerrainImage); 426 m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} at <{1},{2}> with image {3}",
427 regInfo.RegionName, Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY), regInfo.TerrainImage);
385 return true; 428 return true;
386 } 429 }
387 430
@@ -502,10 +545,21 @@ namespace OpenSim.Services.GridService
502 MainConsole.Instance.Output(new string('-', 72)); 545 MainConsole.Instance.Output(new string('-', 72));
503 foreach (RegionData r in regions) 546 foreach (RegionData r in regions)
504 { 547 {
548<<<<<<< HEAD
549 MainConsole.Instance.Output(
550 String.Format("{0}\n{2,-32} {1}\n",
551 r.RegionName, r.RegionID,
552 String.Format("{0},{1} ({2},{3})", r.posX, r.posY,
553 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY)
554 )
555 )
556 );
557=======
505 MainConsole.Instance.Output(String.Format("{0}\n{2,-32} {1}\n", 558 MainConsole.Instance.Output(String.Format("{0}\n{2,-32} {1}\n",
506 r.RegionName, r.RegionID, 559 r.RegionName, r.RegionID,
507 String.Format("{0},{1} ({2},{3})", r.posX, r.posY, 560 String.Format("{0},{1} ({2},{3})", r.posX, r.posY,
508 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY))) ); 561 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY))) );
562>>>>>>> avn/ubitvar
509 } 563 }
510 return; 564 return;
511 } 565 }
@@ -607,8 +661,13 @@ namespace OpenSim.Services.GridService
607 string externalHostName; 661 string externalHostName;
608 try 662 try
609 { 663 {
664<<<<<<< HEAD
665 xloc = Convert.ToUInt32(cmdparams[0]);
666 yloc = Convert.ToUInt32(cmdparams[1]);
667=======
610 xloc = (uint)Convert.ToInt32(cmdparams[0]); 668 xloc = (uint)Convert.ToInt32(cmdparams[0]);
611 yloc = (uint)Convert.ToInt32(cmdparams[1]); 669 yloc = (uint)Convert.ToInt32(cmdparams[1]);
670>>>>>>> avn/ubitvar
612 externalPort = Convert.ToUInt32(cmdparams[3]); 671 externalPort = Convert.ToUInt32(cmdparams[3]);
613 externalHostName = cmdparams[2]; 672 externalHostName = cmdparams[2];
614 //internalPort = Convert.ToUInt32(cmdparams[4]); 673 //internalPort = Convert.ToUInt32(cmdparams[4]);
@@ -711,8 +770,13 @@ namespace OpenSim.Services.GridService
711 string externalHostName; 770 string externalHostName;
712 uint realXLoc, realYLoc; 771 uint realXLoc, realYLoc;
713 772
773<<<<<<< HEAD
774 xloc = Convert.ToUInt32(config.GetString("xloc", "0"));
775 yloc = Convert.ToUInt32(config.GetString("yloc", "0"));
776=======
714 xloc = (uint)Convert.ToInt32(config.GetString("xloc", "0")); 777 xloc = (uint)Convert.ToInt32(config.GetString("xloc", "0"));
715 yloc = (uint)Convert.ToInt32(config.GetString("yloc", "0")); 778 yloc = (uint)Convert.ToInt32(config.GetString("yloc", "0"));
779>>>>>>> avn/ubitvar
716 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); 780 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
717 externalHostName = config.GetString("externalHostName", ""); 781 externalHostName = config.GetString("externalHostName", "");
718 realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); 782 realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
@@ -720,8 +784,13 @@ namespace OpenSim.Services.GridService
720 784
721 if (m_enableAutoMapping) 785 if (m_enableAutoMapping)
722 { 786 {
787<<<<<<< HEAD
788 xloc = (xloc % 100) + m_autoMappingX;
789 yloc = (yloc % 100) + m_autoMappingY;
790=======
723 xloc = (uint)((xloc % 100) + m_autoMappingX); 791 xloc = (uint)((xloc % 100) + m_autoMappingX);
724 yloc = (uint)((yloc % 100) + m_autoMappingY); 792 yloc = (uint)((yloc % 100) + m_autoMappingY);
793>>>>>>> avn/ubitvar
725 } 794 }
726 795
727 if (((realXLoc == 0) && (realYLoc == 0)) || 796 if (((realXLoc == 0) && (realYLoc == 0)) ||
diff --git a/OpenSim/Services/GridService/Properties/AssemblyInfo.cs b/OpenSim/Services/GridService/Properties/AssemblyInfo.cs
index bd84123..ebe3c44 100644
--- a/OpenSim/Services/GridService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/GridService/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.0.*")] 32[assembly: AssemblyVersion("0.8.2.*")]
33 33