diff options
author | Melanie | 2010-08-07 05:39:20 +0100 |
---|---|---|
committer | Melanie | 2010-08-07 05:39:20 +0100 |
commit | a04efe4a4df06c6d1e4adccc1e5d3d6f4842f067 (patch) | |
tree | b2e36a0e20227fc45465e8f12ddab83044408586 /OpenSim/Services | |
parent | Correct display of landmark about info. Also correct region maturity rating (diff) | |
parent | Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-a04efe4a4df06c6d1e4adccc1e5d3d6f4842f067.zip opensim-SC-a04efe4a4df06c6d1e4adccc1e5d3d6f4842f067.tar.gz opensim-SC-a04efe4a4df06c6d1e4adccc1e5d3d6f4842f067.tar.bz2 opensim-SC-a04efe4a4df06c6d1e4adccc1e5d3d6f4842f067.tar.xz |
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to 'OpenSim/Services')
5 files changed, 113 insertions, 5 deletions
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 1831533..80f0d2d 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | |||
@@ -556,6 +556,56 @@ namespace OpenSim.Services.Connectors | |||
556 | return rinfos; | 556 | return rinfos; |
557 | } | 557 | } |
558 | 558 | ||
559 | public List<GridRegion> GetHyperlinks(UUID scopeID) | ||
560 | { | ||
561 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
562 | |||
563 | sendData["SCOPEID"] = scopeID.ToString(); | ||
564 | |||
565 | sendData["METHOD"] = "get_hyperlinks"; | ||
566 | |||
567 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
568 | string reply = string.Empty; | ||
569 | try | ||
570 | { | ||
571 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
572 | m_ServerURI + "/grid", | ||
573 | ServerUtils.BuildQueryString(sendData)); | ||
574 | |||
575 | //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); | ||
576 | } | ||
577 | catch (Exception e) | ||
578 | { | ||
579 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); | ||
580 | return rinfos; | ||
581 | } | ||
582 | |||
583 | if (reply != string.Empty) | ||
584 | { | ||
585 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
586 | |||
587 | if (replyData != null) | ||
588 | { | ||
589 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; | ||
590 | foreach (object r in rinfosList) | ||
591 | { | ||
592 | if (r is Dictionary<string, object>) | ||
593 | { | ||
594 | GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); | ||
595 | rinfos.Add(rinfo); | ||
596 | } | ||
597 | } | ||
598 | } | ||
599 | else | ||
600 | m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks {0} received null response", | ||
601 | scopeID); | ||
602 | } | ||
603 | else | ||
604 | m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks received null reply"); | ||
605 | |||
606 | return rinfos; | ||
607 | } | ||
608 | |||
559 | public virtual int GetRegionFlags(UUID scopeID, UUID regionID) | 609 | public virtual int GetRegionFlags(UUID scopeID, UUID regionID) |
560 | { | 610 | { |
561 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | 611 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs index bea8172..fefdad6 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs | |||
@@ -357,6 +357,12 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
357 | return new List<GridRegion>(0); | 357 | return new List<GridRegion>(0); |
358 | } | 358 | } |
359 | 359 | ||
360 | public List<GridRegion> GetHyperlinks(UUID scopeID) | ||
361 | { | ||
362 | // Hypergrid/linked regions are not supported | ||
363 | return new List<GridRegion>(); | ||
364 | } | ||
365 | |||
360 | public int GetRegionFlags(UUID scopeID, UUID regionID) | 366 | public int GetRegionFlags(UUID scopeID, UUID regionID) |
361 | { | 367 | { |
362 | const int REGION_ONLINE = 4; | 368 | const int REGION_ONLINE = 4; |
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index ebaed42..ce6f64b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -426,6 +426,22 @@ namespace OpenSim.Services.GridService | |||
426 | return ret; | 426 | return ret; |
427 | } | 427 | } |
428 | 428 | ||
429 | public List<GridRegion> GetHyperlinks(UUID scopeID) | ||
430 | { | ||
431 | List<GridRegion> ret = new List<GridRegion>(); | ||
432 | |||
433 | List<RegionData> regions = m_Database.GetHyperlinks(scopeID); | ||
434 | |||
435 | foreach (RegionData r in regions) | ||
436 | { | ||
437 | if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) | ||
438 | ret.Add(RegionData2RegionInfo(r)); | ||
439 | } | ||
440 | |||
441 | m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count); | ||
442 | return ret; | ||
443 | } | ||
444 | |||
429 | public int GetRegionFlags(UUID scopeID, UUID regionID) | 445 | public int GetRegionFlags(UUID scopeID, UUID regionID) |
430 | { | 446 | { |
431 | RegionData region = m_Database.Get(regionID, scopeID); | 447 | RegionData region = m_Database.Get(regionID, scopeID); |
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 1f53007..b190f93 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs | |||
@@ -62,6 +62,7 @@ namespace OpenSim.Services.GridService | |||
62 | protected GatekeeperServiceConnector m_GatekeeperConnector; | 62 | protected GatekeeperServiceConnector m_GatekeeperConnector; |
63 | 63 | ||
64 | protected UUID m_ScopeID = UUID.Zero; | 64 | protected UUID m_ScopeID = UUID.Zero; |
65 | protected bool m_Check4096 = true; | ||
65 | 66 | ||
66 | // Hyperlink regions are hyperlinks on the map | 67 | // Hyperlink regions are hyperlinks on the map |
67 | public readonly Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>(); | 68 | public readonly Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>(); |
@@ -116,6 +117,8 @@ namespace OpenSim.Services.GridService | |||
116 | if (scope != string.Empty) | 117 | if (scope != string.Empty) |
117 | UUID.TryParse(scope, out m_ScopeID); | 118 | UUID.TryParse(scope, out m_ScopeID); |
118 | 119 | ||
120 | m_Check4096 = gridConfig.GetBoolean("Check4096", true); | ||
121 | |||
119 | m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); | 122 | m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); |
120 | 123 | ||
121 | m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services..."); | 124 | m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services..."); |
@@ -277,7 +280,7 @@ namespace OpenSim.Services.GridService | |||
277 | } | 280 | } |
278 | 281 | ||
279 | uint x, y; | 282 | uint x, y; |
280 | if (!Check4096(handle, out x, out y)) | 283 | if (m_Check4096 && !Check4096(handle, out x, out y)) |
281 | { | 284 | { |
282 | RemoveHyperlinkRegion(regInfo.RegionID); | 285 | RemoveHyperlinkRegion(regInfo.RegionID); |
283 | reason = "Region is too far (" + x + ", " + y + ")"; | 286 | reason = "Region is too far (" + x + ", " + y + ")"; |
@@ -332,18 +335,50 @@ namespace OpenSim.Services.GridService | |||
332 | /// <returns></returns> | 335 | /// <returns></returns> |
333 | public bool Check4096(ulong realHandle, out uint x, out uint y) | 336 | public bool Check4096(ulong realHandle, out uint x, out uint y) |
334 | { | 337 | { |
335 | GridRegion defRegion = DefaultRegion; | ||
336 | |||
337 | uint ux = 0, uy = 0; | 338 | uint ux = 0, uy = 0; |
338 | Utils.LongToUInts(realHandle, out ux, out uy); | 339 | Utils.LongToUInts(realHandle, out ux, out uy); |
339 | x = ux / Constants.RegionSize; | 340 | x = ux / Constants.RegionSize; |
340 | y = uy / Constants.RegionSize; | 341 | y = uy / Constants.RegionSize; |
341 | 342 | ||
342 | if ((Math.Abs((int)defRegion.RegionLocX - ux) >= 4096 * Constants.RegionSize) || | 343 | const uint limit = (4096 - 1) * Constants.RegionSize; |
343 | (Math.Abs((int)defRegion.RegionLocY - uy) >= 4096 * Constants.RegionSize)) | 344 | uint xmin = ux - limit; |
345 | uint xmax = ux + limit; | ||
346 | uint ymin = uy - limit; | ||
347 | uint ymax = uy + limit; | ||
348 | // World map boundary checks | ||
349 | if (xmin < 0 || xmin > ux) | ||
350 | xmin = 0; | ||
351 | if (xmax > int.MaxValue || xmax < ux) | ||
352 | xmax = int.MaxValue; | ||
353 | if (ymin < 0 || ymin > uy) | ||
354 | ymin = 0; | ||
355 | if (ymax > int.MaxValue || ymax < uy) | ||
356 | ymax = int.MaxValue; | ||
357 | |||
358 | // Check for any regions that are within the possible teleport range to the linked region | ||
359 | List<GridRegion> regions = m_GridService.GetRegionRange(m_ScopeID, (int)xmin, (int)xmax, (int)ymin, (int)ymax); | ||
360 | if (regions.Count == 0) | ||
344 | { | 361 | { |
345 | return false; | 362 | return false; |
346 | } | 363 | } |
364 | else | ||
365 | { | ||
366 | // Check for regions which are not linked regions | ||
367 | List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); | ||
368 | // would like to use .Except, but doesn't seem to exist | ||
369 | //IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks); | ||
370 | List<GridRegion> availableRegions = regions.FindAll(delegate(GridRegion region) | ||
371 | { | ||
372 | // Ewww! n^2 | ||
373 | if (hyperlinks.Find(delegate(GridRegion r) { return r.RegionID == region.RegionID; }) == null) // not hyperlink. good. | ||
374 | return true; | ||
375 | |||
376 | return false; | ||
377 | }); | ||
378 | if (availableRegions.Count == 0) | ||
379 | return false; | ||
380 | } | ||
381 | |||
347 | return true; | 382 | return true; |
348 | } | 383 | } |
349 | 384 | ||
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index e55b633..77230a3 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs | |||
@@ -92,6 +92,7 @@ namespace OpenSim.Services.Interfaces | |||
92 | 92 | ||
93 | List<GridRegion> GetDefaultRegions(UUID scopeID); | 93 | List<GridRegion> GetDefaultRegions(UUID scopeID); |
94 | List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y); | 94 | List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y); |
95 | List<GridRegion> GetHyperlinks(UUID scopeID); | ||
95 | 96 | ||
96 | int GetRegionFlags(UUID scopeID, UUID regionID); | 97 | int GetRegionFlags(UUID scopeID, UUID regionID); |
97 | } | 98 | } |