aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Communications/Local/LocalBackEndServices.cs15
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1GridServices.cs119
-rw-r--r--OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs57
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs6
4 files changed, 129 insertions, 68 deletions
diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
index a861ceb..9034e49 100644
--- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
+++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
@@ -514,5 +514,20 @@ namespace OpenSim.Region.Communications.Local
514 m_log.Debug("[INTERREGION STANDALONE] didn't find land data locally."); 514 m_log.Debug("[INTERREGION STANDALONE] didn't find land data locally.");
515 return null; 515 return null;
516 } 516 }
517
518 public List<RegionInfo> RequestNamedRegions (string name, int maxNumber)
519 {
520 List<RegionInfo> regions = new List<RegionInfo>();
521 foreach (RegionInfo info in m_regions.Values)
522 {
523 if (info.RegionName.StartsWith(name))
524 {
525 regions.Add(info);
526 if (regions.Count >= maxNumber) break;
527 }
528 }
529
530 return regions;
531 }
517 } 532 }
518} 533}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
index a2d3823..397062b 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
@@ -352,27 +352,7 @@ namespace OpenSim.Region.Communications.OGS1
352 return null; 352 return null;
353 } 353 }
354 354
355 uint regX = Convert.ToUInt32((string) responseData["region_locx"]); 355 regionInfo = buildRegionInfo(responseData, String.Empty);
356 uint regY = Convert.ToUInt32((string) responseData["region_locy"]);
357 string internalIpStr = (string) responseData["sim_ip"];
358 uint port = Convert.ToUInt32(responseData["sim_port"]);
359 // string externalUri = (string) responseData["sim_uri"];
360
361 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port);
362 // string neighbourExternalUri = externalUri;
363 regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
364
365 regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
366 regionInfo.RemotingAddress = internalIpStr;
367
368 if (responseData.ContainsKey("http_port"))
369 {
370 regionInfo.HttpPort = Convert.ToUInt32((string) responseData["http_port"]);
371 }
372
373 regionInfo.RegionID = new UUID((string) responseData["region_UUID"]);
374 regionInfo.RegionName = (string) responseData["region_name"];
375
376 if (requestData.ContainsKey("regionHandle")) 356 if (requestData.ContainsKey("regionHandle"))
377 { 357 {
378 m_remoteRegionInfoCache.Add(Convert.ToUInt64((string) requestData["regionHandle"]), regionInfo); 358 m_remoteRegionInfoCache.Add(Convert.ToUInt64((string) requestData["regionHandle"]), regionInfo);
@@ -479,30 +459,11 @@ namespace OpenSim.Region.Communications.OGS1
479 459
480 if (responseData.ContainsKey("error")) 460 if (responseData.ContainsKey("error"))
481 { 461 {
482 m_log.Error("[OGS1 GRID SERVICES]: Error received from grid server" + responseData["error"]); 462 m_log.ErrorFormat("[OGS1 GRID SERVICES]: Error received from grid server: ", responseData["error"]);
483 return null; 463 return null;
484 } 464 }
485 465
486 uint regX = Convert.ToUInt32((string) responseData["region_locx"]); 466 regionInfo = buildRegionInfo(responseData, "");
487 uint regY = Convert.ToUInt32((string) responseData["region_locy"]);
488 string internalIpStr = (string) responseData["sim_ip"];
489 uint port = Convert.ToUInt32(responseData["sim_port"]);
490 // string externalUri = (string) responseData["sim_uri"];
491
492 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port);
493 // string neighbourExternalUri = externalUri;
494 regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
495
496 regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
497 regionInfo.RemotingAddress = internalIpStr;
498
499 if (responseData.ContainsKey("http_port"))
500 {
501 regionInfo.HttpPort = Convert.ToUInt32((string) responseData["http_port"]);
502 }
503
504 regionInfo.RegionID = new UUID((string) responseData["region_UUID"]);
505 regionInfo.RegionName = (string) responseData["region_name"];
506 467
507 if (!m_remoteRegionInfoCache.ContainsKey(regionInfo.RegionHandle)) 468 if (!m_remoteRegionInfoCache.ContainsKey(regionInfo.RegionHandle))
508 m_remoteRegionInfoCache.Add(regionInfo.RegionHandle, regionInfo); 469 m_remoteRegionInfoCache.Add(regionInfo.RegionHandle, regionInfo);
@@ -1676,7 +1637,8 @@ namespace OpenSim.Region.Communications.OGS1
1676 else 1637 else
1677 { 1638 {
1678 hash = (Hashtable)response.Value; 1639 hash = (Hashtable)response.Value;
1679 try { 1640 try
1641 {
1680 landData = new LandData(); 1642 landData = new LandData();
1681 landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]); 1643 landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]);
1682 landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]); 1644 landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]);
@@ -1745,5 +1707,76 @@ namespace OpenSim.Region.Communications.OGS1
1745 response.Value = hash; 1707 response.Value = hash;
1746 return response; 1708 return response;
1747 } 1709 }
1710
1711 public List<RegionInfo> RequestNamedRegions (string name, int maxNumber)
1712 {
1713 // no asking of the local backend first, here, as we have to ask the gridserver anyway.
1714 Hashtable hash = new Hashtable();
1715 hash["name"] = name;
1716 hash["maxNumber"] = maxNumber.ToString();
1717
1718 IList paramList = new ArrayList();
1719 paramList.Add(hash);
1720
1721 Hashtable result = XmlRpcSearchForRegionByName(paramList);
1722 if (result == null) return null;
1723
1724 uint numberFound = Convert.ToUInt32(result["numFound"]);
1725 List<RegionInfo> infos = new List<RegionInfo>();
1726 for (int i = 0; i < numberFound; ++i)
1727 {
1728 string prefix = "region" + i + ".";
1729 RegionInfo info = buildRegionInfo(result, prefix);
1730 infos.Add(info);
1731 }
1732 return infos;
1733 }
1734
1735 private RegionInfo buildRegionInfo(Hashtable responseData, string prefix)
1736 {
1737 uint regX = Convert.ToUInt32((string) responseData[prefix + "region_locx"]);
1738 uint regY = Convert.ToUInt32((string) responseData[prefix + "region_locy"]);
1739 string internalIpStr = (string) responseData[prefix + "sim_ip"];
1740 uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]);
1741
1742 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int) port);
1743
1744 RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
1745 regionInfo.RemotingPort = Convert.ToUInt32((string) responseData[prefix + "remoting_port"]);
1746 regionInfo.RemotingAddress = internalIpStr;
1747
1748 if (responseData.ContainsKey(prefix + "http_port"))
1749 {
1750 regionInfo.HttpPort = Convert.ToUInt32((string) responseData[prefix + "http_port"]);
1751 }
1752
1753 regionInfo.RegionID = new UUID((string) responseData[prefix + "region_UUID"]);
1754 regionInfo.RegionName = (string) responseData[prefix + "region_name"];
1755
1756 regionInfo.RegionSettings.TerrainImageID = new UUID((string) responseData[prefix + "map_UUID"]);
1757 return regionInfo;
1758 }
1759
1760 private Hashtable XmlRpcSearchForRegionByName(IList parameters)
1761 {
1762 try
1763 {
1764 XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters);
1765 XmlRpcResponse resp = request.Send(serversInfo.GridURL, 10000);
1766 Hashtable respData = (Hashtable) resp.Value;
1767 if (respData != null && respData.Contains("faultCode"))
1768 {
1769 m_log.WarnFormat("[OGS1 GRID SERVICES]: Got an error while contacting GridServer: {0}", respData["faultString"]);
1770 return null;
1771 }
1772
1773 return respData;
1774 }
1775 catch (Exception e)
1776 {
1777 m_log.Error("[OGS1 GRID SERVICES]: MapBlockQuery XMLRPC failure: ", e);
1778 return null;
1779 }
1780 }
1748 } 1781 }
1749} \ No newline at end of file 1782} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs
index 1a15585..8cc707c 100644
--- a/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs
@@ -78,35 +78,44 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
78 78
79 private void OnMapNameRequest(IClientAPI remoteClient, string mapName) 79 private void OnMapNameRequest(IClientAPI remoteClient, string mapName)
80 { 80 {
81 m_log.DebugFormat("[MAPSEARCH]: looking for region {0}", mapName); 81 if (mapName.Length < 3)
82 82 {
83 // TODO currently, this only returns one region per name. LL servers will return all starting with the provided name. 83 remoteClient.SendAlertMessage("Use a search string with at least 3 characters");
84 RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName); 84 return;
85 // fetch the mapblock of the named sim. We need this anyway (we have the map open, and just jumped to the sim), 85 }
86 // so there shouldn't be any penalty for that. 86
87 if (info == null) 87 // try to fetch from GridServer
88 { 88 List<RegionInfo> regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20);
89 m_log.Warn("[MAPSEARCHMODULE]: Got Null Region Question!"); 89 if (regionInfos == null)
90 return; 90 {
91 m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?");
92 // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region
93 regionInfos = new List<RegionInfo>();
94 RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName);
95 if (info != null) regionInfos.Add(info);
91 } 96 }
92 List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)info.RegionLocX,
93 (int)info.RegionLocY,
94 (int)info.RegionLocX,
95 (int)info.RegionLocY);
96 97
97 List<MapBlockData> blocks = new List<MapBlockData>(); 98 List<MapBlockData> blocks = new List<MapBlockData>();
98 99
99 MapBlockData data = new MapBlockData(); 100 MapBlockData data;
100 data.Agents = 3; // TODO set to number of agents in region 101 if (regionInfos.Count > 0)
101 data.Access = 21; // TODO what's this? 102 {
102 data.MapImageId = mapBlocks.Count == 0 ? UUID.Zero : mapBlocks[0].MapImageId; 103 foreach (RegionInfo info in regionInfos)
103 data.Name = info.RegionName; 104 {
104 data.RegionFlags = 0; // TODO fix this 105 data = new MapBlockData();
105 data.WaterHeight = 0; // not used 106 data.Agents = 0;
106 data.X = (ushort)info.RegionLocX; 107 data.Access = 21; // TODO what's this?
107 data.Y = (ushort)info.RegionLocY; 108 data.MapImageId = info.RegionSettings.TerrainImageID;
108 blocks.Add(data); 109 data.Name = info.RegionName;
110 data.RegionFlags = 0; // TODO not used?
111 data.WaterHeight = 0; // not used
112 data.X = (ushort)info.RegionLocX;
113 data.Y = (ushort)info.RegionLocY;
114 blocks.Add(data);
115 }
116 }
109 117
118 // final block, closing the search result
110 data = new MapBlockData(); 119 data = new MapBlockData();
111 data.Agents = 0; 120 data.Agents = 0;
112 data.Access = 255; 121 data.Access = 255;
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
index c33c777..08793d9 100644
--- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
@@ -806,6 +806,10 @@ namespace OpenSim.Region.Environment.Scenes
806 { 806 {
807 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); 807 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
808 } 808 }
809 809
810 public List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
811 {
812 return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber);
813 }
810 } 814 }
811} 815}