aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs13
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs18
-rw-r--r--OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs208
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs13
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs32
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs6
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs293
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs54
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs52
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs19
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs63
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs9
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs3
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs26
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs30
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs98
20 files changed, 610 insertions, 353 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 49b2b5c..dd9b318 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -40,6 +40,7 @@ using OpenSim.Framework.Communications.Cache;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
43using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43 44
44namespace OpenSim.Region.CoreModules.Avatar.Friends 45namespace OpenSim.Region.CoreModules.Avatar.Friends
45{ 46{
@@ -108,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
108 private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>(); 109 private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>();
109 private IMessageTransferModule m_TransferModule = null; 110 private IMessageTransferModule m_TransferModule = null;
110 111
111 private IGridServices m_gridServices = null; 112 private IGridService m_gridServices = null;
112 113
113 #region IRegionModule Members 114 #region IRegionModule Members
114 115
@@ -142,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
142 if (m_scenes.Count > 0) 143 if (m_scenes.Count > 0)
143 { 144 {
144 m_TransferModule = m_initialScene.RequestModuleInterface<IMessageTransferModule>(); 145 m_TransferModule = m_initialScene.RequestModuleInterface<IMessageTransferModule>();
145 m_gridServices = m_initialScene.CommsManager.GridService; 146 m_gridServices = m_initialScene.GridService;
146 } 147 }
147 if (m_TransferModule == null) 148 if (m_TransferModule == null)
148 m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work"); 149 m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work");
@@ -171,7 +172,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
171 List<UUID> tpdAway = new List<UUID>(); 172 List<UUID> tpdAway = new List<UUID>();
172 173
173 // destRegionHandle is a region on another server 174 // destRegionHandle is a region on another server
174 RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle); 175 uint x = 0, y = 0;
176 Utils.LongToUInts(destRegionHandle, out x, out y);
177 GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y);
175 if (info != null) 178 if (info != null)
176 { 179 {
177 string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; 180 string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk";
@@ -223,7 +226,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
223 public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID) 226 public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID)
224 { 227 {
225 // destRegionHandle is a region on another server 228 // destRegionHandle is a region on another server
226 RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle); 229 uint x = 0, y = 0;
230 Utils.LongToUInts(destRegionHandle, out x, out y);
231 GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y);
227 if (info == null) 232 if (info == null)
228 { 233 {
229 m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle); 234 m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle);
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 4495303..e5159b3 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -36,6 +36,7 @@ using OpenMetaverse;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
40namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 41namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
41{ 42{
@@ -497,7 +498,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
497 { 498 {
498 if (upd.AgentOnline) 499 if (upd.AgentOnline)
499 { 500 {
500 RegionInfo reginfo = m_Scenes[0].SceneGridService.RequestNeighbouringRegionInfo(upd.Handle); 501 uint x = 0, y = 0;
502 Utils.LongToUInts(upd.Handle, out x, out y);
503 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByPosition(m_Scenes[0].RegionInfo.ScopeID,
504 (int)x, (int)y);
501 if (reginfo != null) 505 if (reginfo != null)
502 { 506 {
503 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); 507 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
@@ -559,7 +563,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
559 /// <param name="reginfo">RegionInfo we pull the data out of to send the request to</param> 563 /// <param name="reginfo">RegionInfo we pull the data out of to send the request to</param>
560 /// <param name="xmlrpcdata">The Instant Message data Hashtable</param> 564 /// <param name="xmlrpcdata">The Instant Message data Hashtable</param>
561 /// <returns>Bool if the message was successfully delivered at the other side.</returns> 565 /// <returns>Bool if the message was successfully delivered at the other side.</returns>
562 protected virtual bool doIMSending(RegionInfo reginfo, Hashtable xmlrpcdata) 566 protected virtual bool doIMSending(GridRegion reginfo, Hashtable xmlrpcdata)
563 { 567 {
564 568
565 ArrayList SendParams = new ArrayList(); 569 ArrayList SendParams = new ArrayList();
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
index ebd9a72..5a9b452 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
@@ -35,6 +35,7 @@ using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38 39
39namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 40namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
40{ 41{
@@ -171,7 +172,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
171 { 172 {
172 // TODO this is the old messaging-server protocol; only the regionHandle is available. 173 // TODO this is the old messaging-server protocol; only the regionHandle is available.
173 // Fetch region-info to get the id 174 // Fetch region-info to get the id
174 RegionInfo regionInfo = m_initialScene.RequestNeighbouringRegionInfo(info.regionHandle); 175 uint x = 0, y = 0;
176 Utils.LongToUInts(info.regionHandle, out x, out y);
177 GridRegion regionInfo = m_initialScene.GridService.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID,
178 (int)x, (int)y);
175 regionID = regionInfo.RegionID; 179 regionID = regionInfo.RegionID;
176 } 180 }
177 result[indices[i]] = new PresenceInfo(uuids[i], regionID); 181 result[indices[i]] = new PresenceInfo(uuids[i], regionID);
@@ -326,6 +330,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
326 330
327 private void NotifyMessageServerOfStartup(Scene scene) 331 private void NotifyMessageServerOfStartup(Scene scene)
328 { 332 {
333 if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
334 return;
335
329 Hashtable xmlrpcdata = new Hashtable(); 336 Hashtable xmlrpcdata = new Hashtable();
330 xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); 337 xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString();
331 ArrayList SendParams = new ArrayList(); 338 ArrayList SendParams = new ArrayList();
@@ -349,6 +356,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
349 356
350 private void NotifyMessageServerOfShutdown(Scene scene) 357 private void NotifyMessageServerOfShutdown(Scene scene)
351 { 358 {
359 if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
360 return;
361
352 Hashtable xmlrpcdata = new Hashtable(); 362 Hashtable xmlrpcdata = new Hashtable();
353 xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); 363 xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString();
354 ArrayList SendParams = new ArrayList(); 364 ArrayList SendParams = new ArrayList();
@@ -372,6 +382,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
372 382
373 private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle) 383 private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle)
374 { 384 {
385 if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
386 return;
387
375 Hashtable xmlrpcdata = new Hashtable(); 388 Hashtable xmlrpcdata = new Hashtable();
376 xmlrpcdata["AgentID"] = agentID.ToString(); 389 xmlrpcdata["AgentID"] = agentID.ToString();
377 xmlrpcdata["RegionUUID"] = region.ToString(); 390 xmlrpcdata["RegionUUID"] = region.ToString();
@@ -397,6 +410,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
397 410
398 private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle) 411 private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle)
399 { 412 {
413 if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
414 return;
415
400 Hashtable xmlrpcdata = new Hashtable(); 416 Hashtable xmlrpcdata = new Hashtable();
401 xmlrpcdata["AgentID"] = agentID.ToString(); 417 xmlrpcdata["AgentID"] = agentID.ToString();
402 xmlrpcdata["RegionUUID"] = region.ToString(); 418 xmlrpcdata["RegionUUID"] = region.ToString();
diff --git a/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs b/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs
deleted file mode 100644
index 8c92727..0000000
--- a/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs
+++ /dev/null
@@ -1,208 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using log4net;
34using Nini.Config;
35using OpenMetaverse;
36using OpenSim.Data;
37using OpenSim.Framework;
38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43
44using Nwc.XmlRpc;
45
46
47namespace OpenSim.Region.CoreModules.Framework.Services
48{
49 public class RegionMapService : IRegionModule
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 private static bool initialized = false;
53 private static bool enabled = false;
54
55 Scene m_scene;
56 //AssetService m_assetService;
57
58 #region IRegionModule interface
59
60 public void Initialise(Scene scene, IConfigSource config)
61 {
62 if (!initialized)
63 {
64 initialized = true;
65 m_scene = scene;
66
67 // This module is only on for hypergrid mode
68 enabled = config.Configs["Startup"].GetBoolean("hypergrid", false);
69 }
70 }
71
72 public void PostInitialise()
73 {
74 if (enabled)
75 {
76 m_log.Info("[RegionMapService]: Starting...");
77
78 //m_assetService = new AssetService(m_scene);
79 new GridService(m_scene);
80 }
81 }
82
83 public void Close()
84 {
85 }
86
87 public string Name
88 {
89 get { return "RegionMapService"; }
90 }
91
92 public bool IsSharedModule
93 {
94 get { return true; }
95 }
96
97 #endregion
98
99 }
100
101 public class GridService
102 {
103// private IUserService m_userService;
104 private IGridServices m_gridService;
105 private bool m_doLookup = false;
106
107 public bool DoLookup
108 {
109 get { return m_doLookup; }
110 set { m_doLookup = value; }
111 }
112 private static readonly ILog m_log
113 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
114
115 public GridService(Scene m_scene)
116 {
117 AddHandlers(m_scene);
118// m_userService = m_scene.CommsManager.UserService;
119 m_gridService = m_scene.CommsManager.GridService;
120 }
121
122 protected void AddHandlers(Scene m_scene)
123 {
124// IAssetDataPlugin m_assetProvider
125// = ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin;
126
127 IHttpServer httpServer = MainServer.Instance;
128 httpServer.AddXmlRPCHandler("simulator_data_request", XmlRpcSimulatorDataRequestMethod);
129 //m_httpServer.AddXmlRPCHandler("map_block", XmlRpcMapBlockMethod);
130 //m_httpServer.AddXmlRPCHandler("search_for_region_by_name", XmlRpcSearchForRegionMethod);
131
132 }
133
134 /// <summary>
135 /// Returns an XML RPC response to a simulator profile request
136 /// </summary>
137 /// <param name="request"></param>
138 /// <returns></returns>
139 public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request, IPEndPoint remoteClient)
140 {
141 Hashtable requestData = (Hashtable)request.Params[0];
142 Hashtable responseData = new Hashtable();
143 RegionInfo simData = null;
144 if (requestData.ContainsKey("region_UUID"))
145 {
146 UUID regionID = new UUID((string)requestData["region_UUID"]);
147 simData = m_gridService.RequestNeighbourInfo(regionID); //.GetRegion(regionID);
148 if (simData == null)
149 {
150 m_log.WarnFormat("[HGGridService] didn't find region for regionID {0} from {1}",
151 regionID, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
152 }
153 }
154 else if (requestData.ContainsKey("region_handle"))
155 {
156 //CFK: The if/else below this makes this message redundant.
157 //CFK: m_log.Info("requesting data for region " + (string) requestData["region_handle"]);
158 ulong regionHandle = Convert.ToUInt64((string)requestData["region_handle"]);
159 simData = m_gridService.RequestNeighbourInfo(regionHandle); //m_gridDBService.GetRegion(regionHandle);
160 if (simData == null)
161 {
162 m_log.WarnFormat("[HGGridService] didn't find region for regionHandle {0} from {1}",
163 regionHandle, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
164 }
165 }
166 else if (requestData.ContainsKey("region_name_search"))
167 {
168 string regionName = (string)requestData["region_name_search"];
169 List<RegionInfo> regInfos = m_gridService.RequestNamedRegions(regionName, 1);//m_gridDBService.GetRegion(regionName);
170 if (regInfos != null)
171 simData = regInfos[0];
172
173 if (simData == null)
174 {
175 m_log.WarnFormat("[HGGridService] didn't find region for regionName {0} from {1}",
176 regionName, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
177 }
178 }
179 else m_log.Warn("[HGGridService] regionlookup without regionID, regionHandle or regionHame");
180
181 if (simData == null)
182 {
183 //Sim does not exist
184 responseData["error"] = "Sim does not exist";
185 }
186 else
187 {
188 m_log.Debug("[HGGridService]: found " + (string)simData.RegionName + " regionHandle = " +
189 (string)requestData["region_handle"]);
190 responseData["sim_ip"] = simData.ExternalEndPoint.Address.ToString();
191 responseData["sim_port"] = simData.ExternalEndPoint.Port.ToString();
192 //responseData["server_uri"] = simData.serverURI;
193 responseData["http_port"] = simData.HttpPort.ToString();
194 //responseData["remoting_port"] = simData.remotingPort.ToString();
195 responseData["region_locx"] = simData.RegionLocX.ToString();
196 responseData["region_locy"] = simData.RegionLocY.ToString();
197 responseData["region_UUID"] = simData.RegionID.ToString();
198 responseData["region_name"] = simData.RegionName;
199 responseData["region_secret"] = simData.regionSecret;
200 }
201
202 XmlRpcResponse response = new XmlRpcResponse();
203 response.Value = responseData;
204 return response;
205 }
206
207 }
208}
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
index 6774060..a0ccdc7 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
@@ -34,6 +34,7 @@ using OpenSim.Framework;
34using OpenSim.Region.CoreModules.World.WorldMap; 34using OpenSim.Region.CoreModules.World.WorldMap;
35using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37 38
38namespace OpenSim.Region.CoreModules.Hypergrid 39namespace OpenSim.Region.CoreModules.Hypergrid
39{ 40{
@@ -59,7 +60,17 @@ namespace OpenSim.Region.CoreModules.Hypergrid
59 60
60 protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 61 protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
61 { 62 {
62 List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); 63 List<MapBlockData> mapBlocks = new List<MapBlockData>();
64 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
65 (minX - 4) * (int)Constants.RegionSize, (maxX + 4) * (int)Constants.RegionSize,
66 (minY - 4) * (int)Constants.RegionSize, (maxY + 4) * (int)Constants.RegionSize);
67
68 foreach (GridRegion r in regions)
69 {
70 MapBlockData block = new MapBlockData();
71 MapBlockFromGridRegion(block, r);
72 mapBlocks.Add(block);
73 }
63 74
64 // Different from super 75 // Different from super
65 FillInMap(mapBlocks, minX, minY, maxX, maxY); 76 FillInMap(mapBlocks, minX, minY, maxX, maxY);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
index 4fbee7f..9bf31a4 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
@@ -37,6 +37,8 @@ using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base; 37using OpenSim.Server.Base;
38using OpenSim.Server.Handlers.Base; 38using OpenSim.Server.Handlers.Base;
39using OpenSim.Server.Handlers.Grid; 39using OpenSim.Server.Handlers.Grid;
40using OpenSim.Services.Interfaces;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40 42
41namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid 43namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
42{ 44{
@@ -94,20 +96,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
94 if (!m_Enabled) 96 if (!m_Enabled)
95 return; 97 return;
96 98
97 if (!m_Registered)
98 {
99 m_Registered = true;
100
101 m_log.Info("[HypergridService]: Starting...");
102
103 Object[] args = new Object[] { m_Config, MainServer.Instance };
104
105 m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance);
106 //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
107 }
108
109 SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo);
110 m_HypergridHandler.AddRegion(rinfo);
111 } 99 }
112 100
113 public void RemoveRegion(Scene scene) 101 public void RemoveRegion(Scene scene)
@@ -115,12 +103,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
115 if (!m_Enabled) 103 if (!m_Enabled)
116 return; 104 return;
117 105
118 SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo); 106 GridRegion rinfo = new GridRegion(scene.RegionInfo);
119 m_HypergridHandler.RemoveRegion(rinfo); 107 m_HypergridHandler.RemoveRegion(rinfo);
120 } 108 }
121 109
122 public void RegionLoaded(Scene scene) 110 public void RegionLoaded(Scene scene)
123 { 111 {
112 if (!m_Registered)
113 {
114 m_Registered = true;
115
116 m_log.Info("[HypergridService]: Starting...");
117
118 Object[] args = new Object[] { m_Config, MainServer.Instance };
119
120 m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface<IHyperlinkService>());
121 //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
122 }
123
124 GridRegion rinfo = new GridRegion(scene.RegionInfo);
125 m_HypergridHandler.AddRegion(rinfo);
124 } 126 }
125 127
126 #endregion 128 #endregion
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
index a31ce8e..8a90370 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour
121 121
122 #region INeighbourService 122 #region INeighbourService
123 123
124 public bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) 124 public GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
125 { 125 {
126 m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}", 126 m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}",
127 thisRegion.RegionName, regionHandle, m_Scenes.Count); 127 thisRegion.RegionName, regionHandle, m_Scenes.Count);
@@ -134,7 +134,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour
134 } 134 }
135 } 135 }
136 m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: region handle {0} not found", regionHandle); 136 m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: region handle {0} not found", regionHandle);
137 return false; 137 return null;
138 } 138 }
139 139
140 #endregion INeighbourService 140 #endregion INeighbourService
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
index 36915ef..0974372 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
86 86
87 private void RunHGCommand(string command, string[] cmdparams) 87 private void RunHGCommand(string command, string[] cmdparams)
88 { 88 {
89 if (command.Equals("linkk-mapping")) 89 if (command.Equals("link-mapping"))
90 { 90 {
91 if (cmdparams.Length == 2) 91 if (cmdparams.Length == 2)
92 { 92 {
@@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
104 } 104 }
105 } 105 }
106 } 106 }
107 else if (command.Equals("linkk-region")) 107 else if (command.Equals("link-region"))
108 { 108 {
109 if (cmdparams.Length < 3) 109 if (cmdparams.Length < 3)
110 { 110 {
@@ -187,7 +187,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
187 } 187 }
188 return; 188 return;
189 } 189 }
190 else if (command.Equals("unlinkk-region")) 190 else if (command.Equals("unlink-region"))
191 { 191 {
192 if (cmdparams.Length < 1) 192 if (cmdparams.Length < 1)
193 { 193 {
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
index 0c2a835..c8062d7 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -31,6 +31,7 @@ using System.Net;
31using System.Reflection; 31using System.Reflection;
32using System.Xml; 32using System.Xml;
33 33
34using OpenSim.Framework.Communications.Cache;
34using OpenSim.Framework; 35using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
@@ -47,15 +48,19 @@ using Nini.Config;
47 48
48namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid 49namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
49{ 50{
50 public class HGGridConnector : ISharedRegionModule, IGridService 51 public class HGGridConnector : ISharedRegionModule, IGridService, IHyperlinkService
51 { 52 {
52 private static readonly ILog m_log = 53 private static readonly ILog m_log =
53 LogManager.GetLogger( 54 LogManager.GetLogger(
54 MethodBase.GetCurrentMethod().DeclaringType); 55 MethodBase.GetCurrentMethod().DeclaringType);
56 private static string LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI;
55 57
56 private bool m_Enabled = false; 58 private bool m_Enabled = false;
57 private bool m_Initialized = false; 59 private bool m_Initialized = false;
58 60
61 private Scene m_aScene;
62 private Dictionary<ulong, Scene> m_LocalScenes = new Dictionary<ulong, Scene>();
63
59 private IGridService m_GridServiceConnector; 64 private IGridService m_GridServiceConnector;
60 private HypergridServiceConnector m_HypergridServiceConnector; 65 private HypergridServiceConnector m_HypergridServiceConnector;
61 66
@@ -130,6 +135,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
130 135
131 public void PostInitialise() 136 public void PostInitialise()
132 { 137 {
138 ((ISharedRegionModule)m_GridServiceConnector).PostInitialise();
133 } 139 }
134 140
135 public void Close() 141 public void Close()
@@ -141,12 +147,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
141 if (!m_Enabled) 147 if (!m_Enabled)
142 return; 148 return;
143 149
150 m_LocalScenes[scene.RegionInfo.RegionHandle] = scene;
144 scene.RegisterModuleInterface<IGridService>(this); 151 scene.RegisterModuleInterface<IGridService>(this);
152 scene.RegisterModuleInterface<IHyperlinkService>(this);
153
154 ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene);
145 155
146 } 156 }
147 157
148 public void RemoveRegion(Scene scene) 158 public void RemoveRegion(Scene scene)
149 { 159 {
160 m_LocalScenes.Remove(scene.RegionInfo.RegionHandle);
161 ((ISharedRegionModule)m_GridServiceConnector).RemoveRegion(scene);
150 } 162 }
151 163
152 public void RegionLoaded(Scene scene) 164 public void RegionLoaded(Scene scene)
@@ -156,29 +168,28 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
156 168
157 if (!m_Initialized) 169 if (!m_Initialized)
158 { 170 {
171 m_aScene = scene;
172 LocalAssetServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL;
173 LocalInventoryServerURI = m_aScene.CommsManager.NetworkServersInfo.InventoryURL;
174 LocalUserServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL;
175
159 m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); 176 m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService);
177
160 HGCommands hgCommands = new HGCommands(this, scene); 178 HGCommands hgCommands = new HGCommands(this, scene);
161 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-region", 179 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region",
162 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", 180 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
163 "Link a hypergrid region", hgCommands.RunCommand); 181 "Link a hypergrid region", hgCommands.RunCommand);
164 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlinkk-region", 182 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlink-region",
165 "unlink-region <local name> or <HostName>:<HttpPort> <cr>", 183 "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
166 "Unlink a hypergrid region", hgCommands.RunCommand); 184 "Unlink a hypergrid region", hgCommands.RunCommand);
167 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-mapping", "link-mapping [<x> <y>] <cr>", 185 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
168 "Set local coordinate to map HG regions to", hgCommands.RunCommand); 186 "Set local coordinate to map HG regions to", hgCommands.RunCommand);
169 m_Initialized = true;
170 }
171
172 187
173 //scene.AddCommand("HGGridServicesConnector", "linkk-region", 188 // Yikes!! Remove this as soon as user services get refactored
174 // "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", 189 HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI);
175 // "Link a hypergrid region", hgCommands.RunCommand);
176 //scene.AddCommand("HGGridServicesConnector", "unlinkk-region",
177 // "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
178 // "Unlink a hypergrid region", hgCommands.RunCommand);
179 //scene.AddCommand("HGGridServicesConnector", "linkk-mapping", "link-mapping [<x> <y>] <cr>",
180 // "Set local coordinate to map HG regions to", hgCommands.RunCommand);
181 190
191 m_Initialized = true;
192 }
182 } 193 }
183 194
184 #endregion 195 #endregion
@@ -250,7 +261,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
250 // Try the foreign users home collection 261 // Try the foreign users home collection
251 foreach (GridRegion r in m_knownRegions.Values) 262 foreach (GridRegion r in m_knownRegions.Values)
252 if (r.RegionID == regionID) 263 if (r.RegionID == regionID)
253 return m_knownRegions[regionID]; 264 return r;
254 265
255 // Finally, try the normal route 266 // Finally, try the normal route
256 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); 267 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
@@ -271,7 +282,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
271 foreach (GridRegion r in m_knownRegions.Values) 282 foreach (GridRegion r in m_knownRegions.Values)
272 { 283 {
273 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) 284 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
285 {
274 return r; 286 return r;
287 }
275 } 288 }
276 289
277 // Finally, try the normal route 290 // Finally, try the normal route
@@ -338,8 +351,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
338 351
339 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) 352 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
340 { 353 {
341 m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); 354 m_HyperlinkRegions[regionInfo.RegionID] = regionInfo;
342 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); 355 m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
343 } 356 }
344 357
345 private void RemoveHyperlinkRegion(UUID regionID) 358 private void RemoveHyperlinkRegion(UUID regionID)
@@ -350,8 +363,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
350 363
351 private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle) 364 private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle)
352 { 365 {
353 m_knownRegions.Add(userID, regionInfo); 366 m_knownRegions[userID] = regionInfo;
354 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); 367 m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
355 } 368 }
356 369
357 private void RemoveHyperlinkHomeRegion(UUID regionID) 370 private void RemoveHyperlinkHomeRegion(UUID regionID)
@@ -367,10 +380,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
367 } 380 }
368 #endregion 381 #endregion
369 382
370 #region Hyperlinks 383 #region IHyperlinkService
371 384
372 private static Random random = new Random(); 385 private static Random random = new Random();
373 386
387
374 public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc) 388 public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc)
375 { 389 {
376 string host = "127.0.0.1"; 390 string host = "127.0.0.1";
@@ -417,10 +431,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
417 return null; 431 return null;
418 } 432 }
419 433
434
420 // From the map search and secondlife://blah 435 // From the map search and secondlife://blah
421 public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) 436 public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
422 { 437 {
423 int xloc = random.Next(0, Int16.MaxValue); 438 int xloc = random.Next(0, Int16.MaxValue) * (int) Constants.RegionSize;
424 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); 439 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
425 } 440 }
426 441
@@ -447,15 +462,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
447 } 462 }
448 463
449 // Finally, link it 464 // Finally, link it
450 try 465 if (!RegisterRegion(UUID.Zero, regInfo))
451 { 466 {
452 RegisterRegion(UUID.Zero, regInfo); 467 m_log.Warn("[HGrid]: Unable to link region");
453 } 468 return false;
454 catch (Exception e) 469 }
455 {
456 m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
457 return false;
458 }
459 470
460 int x, y; 471 int x, y;
461 if (!Check4096(m_scene, regInfo, out x, out y)) 472 if (!Check4096(m_scene, regInfo, out x, out y))
@@ -554,7 +565,227 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
554 return true; 565 return true;
555 } 566 }
556 567
568 public GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor)
569 {
570 return TryLinkRegion((Scene)client.Scene, client, regionDescriptor);
571 }
572
573 public GridRegion GetHyperlinkRegion(ulong handle)
574 {
575 foreach (GridRegion r in m_HyperlinkRegions.Values)
576 if (r.RegionHandle == handle)
577 return r;
578 foreach (GridRegion r in m_knownRegions.Values)
579 if (r.RegionHandle == handle)
580 return r;
581 return null;
582 }
583
584 public ulong FindRegionHandle(ulong handle)
585 {
586 foreach (GridRegion r in m_HyperlinkRegions.Values)
587 if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
588 return m_HyperlinkHandles[r.RegionID];
589
590 foreach (GridRegion r in m_knownRegions.Values)
591 if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
592 return m_HyperlinkHandles[r.RegionID];
593
594 return handle;
595 }
596
597 public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData)
598 {
599 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
600
601 if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) ||
602 (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo)))
603 {
604 m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere");
605
606 // Set the position of the region on the remote grid
607 ulong realHandle = FindRegionHandle(regInfo.RegionHandle);
608 uint x = 0, y = 0;
609 Utils.LongToUInts(regInfo.RegionHandle, out x, out y);
610 GridRegion clonedRegion = new GridRegion(regInfo);
611 clonedRegion.RegionLocX = (int)x;
612 clonedRegion.RegionLocY = (int)y;
613
614 // Get the user's home region information
615 GridRegion home = m_aScene.GridService.GetRegionByUUID(m_aScene.RegionInfo.ScopeID, uinfo.UserProfile.HomeRegionID);
616
617 // Get the user's service URLs
618 string serverURI = "";
619 if (uinfo.UserProfile is ForeignUserProfileData)
620 serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
621 string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI;
622
623 string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI);
624 if ((assetServer == null) || (assetServer == ""))
625 assetServer = LocalAssetServerURI;
626
627 string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
628 if ((inventoryServer == null) || (inventoryServer == ""))
629 inventoryServer = LocalInventoryServerURI;
630
631 if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer))
632 {
633 m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
634 return false;
635 }
636 }
637 //if ((uinfo == null) || !IsGoingHome(uinfo, regInfo))
638 //{
639 // m_log.Info("[HGrid]: User seems to be going to foreign region.");
640 // if (!InformRegionOfUser(regInfo, agentData))
641 // {
642 // m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
643 // return false;
644 // }
645 //}
646 //else
647 // m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
648
649 // May need to change agent's name
650 if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null))
651 {
652 agentData.firstname = agentData.firstname + "." + agentData.lastname;
653 agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI;
654 }
655
656 return true;
657 }
658
659 public void AdjustUserInformation(AgentCircuitData agentData)
660 {
661 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
662 if ((uinfo != null) && (uinfo.UserProfile != null) &&
663 (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData)))
664 {
665 //m_log.Debug("---------------> Local User!");
666 string[] parts = agentData.firstname.Split(new char[] { '.' });
667 if (parts.Length == 2)
668 {
669 agentData.firstname = parts[0];
670 agentData.lastname = parts[1];
671 }
672 }
673 //else
674 // m_log.Debug("---------------> Foreign User!");
675 }
676
677 // Check if a local user exists with the same UUID as the incoming foreign user
678 public bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome)
679 {
680 comingHome = false;
681 if (!m_aScene.SceneGridService.RegionLoginsEnabled)
682 return false;
683
684 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
685 if (uinfo != null)
686 {
687 // uh-oh we have a potential intruder
688 if (uinfo.SessionID != sessionID)
689 // can't have a foreigner with a local UUID
690 return false;
691 else
692 // oh, so it's you! welcome back
693 comingHome = true;
694 }
695
696 // OK, user can come in
697 return true;
698 }
699
700 public void AcceptUser(ForeignUserProfileData user, GridRegion home)
701 {
702 m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user);
703 ulong realHandle = home.RegionHandle;
704 // Change the local coordinates
705 // X=0 on the map
706 home.RegionLocX = 0;
707 home.RegionLocY = random.Next(0, 10000) * (int)Constants.RegionSize;
708
709 AddHyperlinkHomeRegion(user.ID, home, realHandle);
710
711 DumpUserData(user);
712 DumpRegionData(home);
713
714 }
715
716 public bool IsLocalUser(UUID userID)
717 {
718 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
719 return IsLocalUser(uinfo);
720 }
721
722 #endregion
723
724 #region IHyperlink Misc
725
726 protected bool IsComingHome(ForeignUserProfileData userData)
727 {
728 return (userData.UserServerURI == LocalUserServerURI);
729 }
730
731 // Is the user going back to the home region or the home grid?
732 protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo)
733 {
734 if (uinfo.UserProfile == null)
735 return false;
736
737 if (!(uinfo.UserProfile is ForeignUserProfileData))
738 // it's a home user, can't be outside to return home
739 return false;
740
741 // OK, it's a foreign user with a ForeignUserProfileData
742 // and is going back to exactly the home region.
743 // We can't check if it's going back to a non-home region
744 // of the home grid. That will be dealt with in the
745 // receiving end
746 return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID);
747 }
748
749 protected bool IsLocalUser(CachedUserInfo uinfo)
750 {
751 if (uinfo == null)
752 return false;
753
754 return !(uinfo.UserProfile is ForeignUserProfileData);
755
756 }
757
758 protected bool IsLocalRegion(ulong handle)
759 {
760 return m_LocalScenes.ContainsKey(handle);
761 }
762
763 private void DumpUserData(ForeignUserProfileData userData)
764 {
765 m_log.Info(" ------------ User Data Dump ----------");
766 m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName);
767 m_log.Info(" >> HomeID: " + userData.HomeRegionID);
768 m_log.Info(" >> UserServer: " + userData.UserServerURI);
769 m_log.Info(" >> InvServer: " + userData.UserInventoryURI);
770 m_log.Info(" >> AssetServer: " + userData.UserAssetURI);
771 m_log.Info(" ------------ -------------- ----------");
772 }
773
774 private void DumpRegionData(GridRegion rinfo)
775 {
776 m_log.Info(" ------------ Region Data Dump ----------");
777 m_log.Info(" >> handle: " + rinfo.RegionHandle);
778 m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY);
779 m_log.Info(" >> external host name: " + rinfo.ExternalHostName);
780 m_log.Info(" >> http port: " + rinfo.HttpPort);
781 m_log.Info(" >> external EP address: " + rinfo.ExternalEndPoint.Address);
782 m_log.Info(" >> external EP port: " + rinfo.ExternalEndPoint.Port);
783 m_log.Info(" ------------ -------------- ----------");
784 }
785
786
557 #endregion 787 #endregion
558 788
789
559 } 790 }
560} 791}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index 743d3b9..6c2928a 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -31,6 +31,7 @@ using System;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Console;
34using OpenSim.Server.Base; 35using OpenSim.Server.Base;
35using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
@@ -47,7 +48,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
47 LogManager.GetLogger( 48 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType); 49 MethodBase.GetCurrentMethod().DeclaringType);
49 50
51 private static LocalGridServicesConnector m_MainInstance;
52
50 private IGridService m_GridService; 53 private IGridService m_GridService;
54 private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>();
51 55
52 private bool m_Enabled = false; 56 private bool m_Enabled = false;
53 57
@@ -58,6 +62,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
58 public LocalGridServicesConnector(IConfigSource source) 62 public LocalGridServicesConnector(IConfigSource source)
59 { 63 {
60 m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated"); 64 m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated");
65 m_MainInstance = this;
61 InitialiseService(source); 66 InitialiseService(source);
62 } 67 }
63 68
@@ -82,6 +87,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
82 if (name == Name) 87 if (name == Name)
83 { 88 {
84 InitialiseService(source); 89 InitialiseService(source);
90 m_MainInstance = this;
85 m_Enabled = true; 91 m_Enabled = true;
86 m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled"); 92 m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled");
87 } 93 }
@@ -120,6 +126,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
120 126
121 public void PostInitialise() 127 public void PostInitialise()
122 { 128 {
129 if (m_MainInstance == this)
130 {
131 MainConsole.Instance.Commands.AddCommand("LocalGridConnector", false, "show neighbours",
132 "show neighbours",
133 "Shows the local regions' neighbours", NeighboursCommand);
134 }
123 } 135 }
124 136
125 public void Close() 137 public void Close()
@@ -128,14 +140,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
128 140
129 public void AddRegion(Scene scene) 141 public void AddRegion(Scene scene)
130 { 142 {
131 if (!m_Enabled) 143 if (m_Enabled)
132 return; 144 scene.RegisterModuleInterface<IGridService>(this);
145
146 if (m_MainInstance == this)
147 {
148 if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID))
149 m_log.ErrorFormat("[LOCAL GRID CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!");
150 else
151 m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene));
133 152
134 scene.RegisterModuleInterface<IGridService>(this); 153 }
135 } 154 }
136 155
137 public void RemoveRegion(Scene scene) 156 public void RemoveRegion(Scene scene)
138 { 157 {
158 if (m_MainInstance == this)
159 {
160 m_LocalCache[scene.RegionInfo.RegionID].Clear();
161 m_LocalCache.Remove(scene.RegionInfo.RegionID);
162 }
139 } 163 }
140 164
141 public void RegionLoaded(Scene scene) 165 public void RegionLoaded(Scene scene)
@@ -158,7 +182,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
158 182
159 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) 183 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
160 { 184 {
161 return m_GridService.GetNeighbours(scopeID, regionID); 185 if (m_LocalCache.ContainsKey(regionID))
186 {
187 return m_LocalCache[regionID].GetNeighbours();
188 }
189 else
190 {
191 m_log.WarnFormat("[LOCAL GRID CONNECTOR]: GetNeighbours: Requested region {0} is not on this sim", regionID);
192 return new List<GridRegion>();
193 }
194
195 // Don't go to the DB
196 //return m_GridService.GetNeighbours(scopeID, regionID);
162 } 197 }
163 198
164 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) 199 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
@@ -187,5 +222,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
187 } 222 }
188 223
189 #endregion 224 #endregion
225
226 public void NeighboursCommand(string module, string[] cmdparams)
227 {
228 foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache)
229 {
230 m_log.InfoFormat("*** Neighbours of {0} {1} ***", kvp.Key, kvp.Value.RegionName);
231 List<GridRegion> regions = kvp.Value.GetNeighbours();
232 foreach (GridRegion r in regions)
233 m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize);
234 }
235 }
190 } 236 }
191} 237}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
new file mode 100644
index 0000000..ea205a2
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
@@ -0,0 +1,52 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4
5using OpenSim.Region.Framework.Scenes;
6using OpenSim.Services.Interfaces;
7using GridRegion = OpenSim.Services.Interfaces.GridRegion;
8
9using log4net;
10
11namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
12{
13 public class RegionCache
14 {
15 private static readonly ILog m_log =
16 LogManager.GetLogger(
17 MethodBase.GetCurrentMethod().DeclaringType);
18
19 private Scene m_scene;
20 private Dictionary<ulong, GridRegion> m_neighbours = new Dictionary<ulong, GridRegion>();
21
22 public string RegionName
23 {
24 get { return m_scene.RegionInfo.RegionName; }
25 }
26
27 public RegionCache(Scene s)
28 {
29 m_scene = s;
30 m_scene.EventManager.OnRegionUp += OnRegionUp;
31 }
32
33 private void OnRegionUp(GridRegion otherRegion)
34 {
35 m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}",
36 m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
37
38 m_neighbours[otherRegion.RegionHandle] = otherRegion;
39 }
40
41 public void Clear()
42 {
43 m_scene.EventManager.OnRegionUp -= OnRegionUp;
44 m_neighbours.Clear();
45 }
46
47 public List<GridRegion> GetNeighbours()
48 {
49 return new List<GridRegion>(m_neighbours.Values);
50 }
51 }
52}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
index 91a808b..72c00fc 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -104,6 +104,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
104 104
105 public void PostInitialise() 105 public void PostInitialise()
106 { 106 {
107 if (m_LocalGridService != null)
108 ((ISharedRegionModule)m_LocalGridService).PostInitialise();
107 } 109 }
108 110
109 public void Close() 111 public void Close()
@@ -112,14 +114,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
112 114
113 public void AddRegion(Scene scene) 115 public void AddRegion(Scene scene)
114 { 116 {
115 if (!m_Enabled) 117 if (m_Enabled)
116 return; 118 scene.RegisterModuleInterface<IGridService>(this);
117 119
118 scene.RegisterModuleInterface<IGridService>(this); 120 if (m_LocalGridService != null)
121 ((ISharedRegionModule)m_LocalGridService).AddRegion(scene);
119 } 122 }
120 123
121 public void RemoveRegion(Scene scene) 124 public void RemoveRegion(Scene scene)
122 { 125 {
126 if (m_LocalGridService != null)
127 ((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene);
123 } 128 }
124 129
125 public void RegionLoaded(Scene scene) 130 public void RegionLoaded(Scene scene)
@@ -146,7 +151,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
146 return false; 151 return false;
147 } 152 }
148 153
149 // Let's not override GetNeighbours -- let's get them all from the grid server 154 // Let's override GetNeighbours completely -- never go to the grid server
155 // Neighbours are/should be cached locally
156 // For retrieval from the DB, caller should call GetRegionByPosition
157 public override List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
158 {
159 return m_LocalGridService.GetNeighbours(scopeID, regionID);
160 }
150 161
151 public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) 162 public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
152 { 163 {
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
index 9519e23..696225c 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
@@ -42,6 +42,8 @@ using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Hypergrid; 43using OpenSim.Region.Framework.Scenes.Hypergrid;
44using OpenSim.Region.Framework.Scenes.Serialization; 44using OpenSim.Region.Framework.Scenes.Serialization;
45using OpenSim.Services.Interfaces;
46using GridRegion = OpenSim.Services.Interfaces.GridRegion;
45 47
46namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion 48namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
47{ 49{
@@ -59,6 +61,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
59 61
60 protected RegionToRegionClient m_regionClient; 62 protected RegionToRegionClient m_regionClient;
61 63
64 protected IHyperlinkService m_hyperlinkService;
65
62 protected bool m_safemode; 66 protected bool m_safemode;
63 protected IPAddress m_thisIP; 67 protected IPAddress m_thisIP;
64 68
@@ -134,7 +138,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
134 m_localBackend = new LocalInterregionComms(); 138 m_localBackend = new LocalInterregionComms();
135 m_commsManager = scene.CommsManager; 139 m_commsManager = scene.CommsManager;
136 m_aScene = scene; 140 m_aScene = scene;
137 m_regionClient = new RegionToRegionClient(m_aScene); 141 m_hyperlinkService = m_aScene.RequestModuleInterface<IHyperlinkService>();
142 m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService);
138 m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); 143 m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName);
139 } 144 }
140 145
@@ -161,7 +166,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
161 // else do the remote thing 166 // else do the remote thing
162 if (!m_localBackend.IsLocalRegion(regionHandle)) 167 if (!m_localBackend.IsLocalRegion(regionHandle))
163 { 168 {
164 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 169 uint x = 0, y = 0;
170 Utils.LongToUInts(regionHandle, out x, out y);
171 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
165 if (regInfo != null) 172 if (regInfo != null)
166 { 173 {
167 m_regionClient.SendUserInformation(regInfo, aCircuit); 174 m_regionClient.SendUserInformation(regInfo, aCircuit);
@@ -183,7 +190,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
183 // else do the remote thing 190 // else do the remote thing
184 if (!m_localBackend.IsLocalRegion(regionHandle)) 191 if (!m_localBackend.IsLocalRegion(regionHandle))
185 { 192 {
186 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 193 uint x = 0, y = 0;
194 Utils.LongToUInts(regionHandle, out x, out y);
195 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
187 if (regInfo != null) 196 if (regInfo != null)
188 { 197 {
189 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); 198 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
@@ -204,7 +213,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
204 // else do the remote thing 213 // else do the remote thing
205 if (!m_localBackend.IsLocalRegion(regionHandle)) 214 if (!m_localBackend.IsLocalRegion(regionHandle))
206 { 215 {
207 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 216 uint x = 0, y = 0;
217 Utils.LongToUInts(regionHandle, out x, out y);
218 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
208 if (regInfo != null) 219 if (regInfo != null)
209 { 220 {
210 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); 221 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
@@ -225,7 +236,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
225 // else do the remote thing 236 // else do the remote thing
226 if (!m_localBackend.IsLocalRegion(regionHandle)) 237 if (!m_localBackend.IsLocalRegion(regionHandle))
227 { 238 {
228 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 239 uint x = 0, y = 0;
240 Utils.LongToUInts(regionHandle, out x, out y);
241 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
229 if (regInfo != null) 242 if (regInfo != null)
230 { 243 {
231 return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent); 244 return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent);
@@ -257,7 +270,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
257 // else do the remote thing 270 // else do the remote thing
258 if (!m_localBackend.IsLocalRegion(regionHandle)) 271 if (!m_localBackend.IsLocalRegion(regionHandle))
259 { 272 {
260 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 273 uint x = 0, y = 0;
274 Utils.LongToUInts(regionHandle, out x, out y);
275 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
261 if (regInfo != null) 276 if (regInfo != null)
262 { 277 {
263 return m_regionClient.DoCloseAgentCall(regInfo, id); 278 return m_regionClient.DoCloseAgentCall(regInfo, id);
@@ -284,7 +299,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
284 // else do the remote thing 299 // else do the remote thing
285 if (!m_localBackend.IsLocalRegion(regionHandle)) 300 if (!m_localBackend.IsLocalRegion(regionHandle))
286 { 301 {
287 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 302 uint x = 0, y = 0;
303 Utils.LongToUInts(regionHandle, out x, out y);
304 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
288 if (regInfo != null) 305 if (regInfo != null)
289 { 306 {
290 return m_regionClient.DoCreateObjectCall( 307 return m_regionClient.DoCreateObjectCall(
@@ -776,16 +793,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
776 protected class RegionToRegionClient : RegionClient 793 protected class RegionToRegionClient : RegionClient
777 { 794 {
778 Scene m_aScene = null; 795 Scene m_aScene = null;
796 IHyperlinkService m_hyperlinkService;
779 797
780 public RegionToRegionClient(Scene s) 798 public RegionToRegionClient(Scene s, IHyperlinkService hyperService)
781 { 799 {
782 m_aScene = s; 800 m_aScene = s;
801 m_hyperlinkService = hyperService;
783 } 802 }
784 803
785 public override ulong GetRegionHandle(ulong handle) 804 public override ulong GetRegionHandle(ulong handle)
786 { 805 {
787 if (m_aScene.SceneGridService is HGSceneCommunicationService) 806 if (m_aScene.SceneGridService is HGSceneCommunicationService)
788 return ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.FindRegionHandle(handle); 807 {
808 if (m_hyperlinkService != null)
809 return m_hyperlinkService.FindRegionHandle(handle);
810 }
789 811
790 return handle; 812 return handle;
791 } 813 }
@@ -793,29 +815,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
793 public override bool IsHyperlink(ulong handle) 815 public override bool IsHyperlink(ulong handle)
794 { 816 {
795 if (m_aScene.SceneGridService is HGSceneCommunicationService) 817 if (m_aScene.SceneGridService is HGSceneCommunicationService)
796 return ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.IsHyperlinkRegion(handle); 818 {
797 819 if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null))
820 return true;
821 }
798 return false; 822 return false;
799 } 823 }
800 824
801 public override void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) 825 public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
802 { 826 {
803 try 827 if (m_hyperlinkService != null)
804 { 828 m_hyperlinkService.SendUserInformation(regInfo, aCircuit);
805 if (m_aScene.SceneGridService is HGSceneCommunicationService)
806 {
807 ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(regInfo, aCircuit);
808 }
809 }
810 catch // Bad cast
811 { }
812 829
813 } 830 }
814 831
815 public override void AdjustUserInformation(AgentCircuitData aCircuit) 832 public override void AdjustUserInformation(AgentCircuitData aCircuit)
816 { 833 {
817 if (m_aScene.SceneGridService is HGSceneCommunicationService) 834 if (m_hyperlinkService != null)
818 ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.AdjustUserInformation(aCircuit); 835 m_hyperlinkService.AdjustUserInformation(aCircuit);
819 } 836 }
820 } 837 }
821 838
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index 1c66254..fd1a759 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -525,7 +525,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
525 return true; 525 return true;
526 } 526 }
527 527
528 string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); 528 if ((uinfo.UserProfile.UserInventoryURI == null) || (uinfo.UserProfile.UserInventoryURI == ""))
529 // this happens in standalone profiles, apparently
530 return true;
531
532 string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
533
529 string uri = m_LocalGridInventoryURI.TrimEnd('/'); 534 string uri = m_LocalGridInventoryURI.TrimEnd('/');
530 535
531 if ((userInventoryServerURI == uri) || (userInventoryServerURI == "")) 536 if ((userInventoryServerURI == uri) || (userInventoryServerURI == ""))
@@ -544,7 +549,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
544 if ((uinfo == null) || (uinfo.UserProfile == null)) 549 if ((uinfo == null) || (uinfo.UserProfile == null))
545 return invURI; 550 return invURI;
546 551
547 string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); 552 string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
548 553
549 if ((userInventoryServerURI != null) && 554 if ((userInventoryServerURI != null) &&
550 (userInventoryServerURI != "")) 555 (userInventoryServerURI != ""))
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
index a52c70b..b0ace39 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
@@ -37,6 +37,7 @@ using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using OpenSim.Server.Base; 38using OpenSim.Server.Base;
39 39
40
40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land 41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
41{ 42{
42 public class RemoteLandServicesConnector : 43 public class RemoteLandServicesConnector :
@@ -89,7 +90,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
89 if (!m_Enabled) 90 if (!m_Enabled)
90 return; 91 return;
91 92
92 m_MapService = scene.CommsManager.GridService; 93 m_GridService = scene.GridService;
93 m_LocalService.AddRegion(scene); 94 m_LocalService.AddRegion(scene);
94 scene.RegisterModuleInterface<ILandService>(this); 95 scene.RegisterModuleInterface<ILandService>(this);
95 } 96 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
index 61bf481..daba0b3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
@@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
119 119
120 #region INeighbourService 120 #region INeighbourService
121 121
122 public bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) 122 public GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
123 { 123 {
124 m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}", 124 m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}",
125 thisRegion.RegionName, regionHandle, m_Scenes.Count); 125 thisRegion.RegionName, regionHandle, m_Scenes.Count);
@@ -132,7 +132,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
132 } 132 }
133 } 133 }
134 m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: region handle {0} not found", regionHandle); 134 m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: region handle {0} not found", regionHandle);
135 return false; 135 return null;
136 } 136 }
137 137
138 #endregion INeighbourService 138 #endregion INeighbourService
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs
index c5bc03b..c6fc2a1 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs
@@ -118,7 +118,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
118 if (!m_Enabled) 118 if (!m_Enabled)
119 return; 119 return;
120 120
121 m_MapService = scene.CommsManager.GridService;
122 m_LocalService.AddRegion(scene); 121 m_LocalService.AddRegion(scene);
123 scene.RegisterModuleInterface<INeighbourService>(this); 122 scene.RegisterModuleInterface<INeighbourService>(this);
124 } 123 }
@@ -134,16 +133,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
134 if (!m_Enabled) 133 if (!m_Enabled)
135 return; 134 return;
136 135
136 m_GridService = scene.GridService;
137
137 m_log.InfoFormat("[NEIGHBOUR CONNECTOR]: Enabled remote neighbours for region {0}", scene.RegionInfo.RegionName); 138 m_log.InfoFormat("[NEIGHBOUR CONNECTOR]: Enabled remote neighbours for region {0}", scene.RegionInfo.RegionName);
138 139
139 } 140 }
140 141
141 #region INeighbourService 142 #region INeighbourService
142 143
143 public override bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) 144 public override GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
144 { 145 {
145 if (m_LocalService.HelloNeighbour(regionHandle, thisRegion)) 146 GridRegion region = m_LocalService.HelloNeighbour(regionHandle, thisRegion);
146 return true; 147 if (region != null)
148 return region;
147 149
148 return base.HelloNeighbour(regionHandle, thisRegion); 150 return base.HelloNeighbour(regionHandle, thisRegion);
149 } 151 }
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 76ff6da..fdff61e 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -36,10 +36,12 @@ using OpenSim.Framework;
36using OpenSim.Framework.Capabilities; 36using OpenSim.Framework.Capabilities;
37using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
39using OpenSim.Services.Interfaces;
39using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.Physics.Manager; 42using OpenSim.Region.Physics.Manager;
42using Caps=OpenSim.Framework.Capabilities.Caps; 43using Caps=OpenSim.Framework.Capabilities.Caps;
44using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43 45
44namespace OpenSim.Region.CoreModules.World.Land 46namespace OpenSim.Region.CoreModules.World.Land
45{ 47{
@@ -1301,7 +1303,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1301 else 1303 else
1302 { 1304 {
1303 // a parcel request for a parcel in another region. Ask the grid about the region 1305 // a parcel request for a parcel in another region. Ask the grid about the region
1304 RegionInfo info = m_scene.CommsManager.GridService.RequestNeighbourInfo(regionID); 1306 GridRegion info = m_scene.GridService.GetRegionByUUID(UUID.Zero, regionID);
1305 if (info != null) 1307 if (info != null)
1306 parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y); 1308 parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y);
1307 } 1309 }
@@ -1359,9 +1361,10 @@ namespace OpenSim.Region.CoreModules.World.Land
1359 } 1361 }
1360 else 1362 else
1361 { 1363 {
1362 extLandData.landData = m_scene.CommsManager.GridService.RequestLandData(extLandData.regionHandle, 1364 ILandService landService = m_scene.RequestModuleInterface<ILandService>();
1363 extLandData.x, 1365 extLandData.landData = landService.GetLandData(extLandData.regionHandle,
1364 extLandData.y); 1366 extLandData.x,
1367 extLandData.y);
1365 if (extLandData.landData == null) 1368 if (extLandData.landData == null)
1366 { 1369 {
1367 // we didn't find the region/land => don't cache 1370 // we didn't find the region/land => don't cache
@@ -1373,20 +1376,27 @@ namespace OpenSim.Region.CoreModules.World.Land
1373 1376
1374 if (data != null) // if we found some data, send it 1377 if (data != null) // if we found some data, send it
1375 { 1378 {
1376 RegionInfo info; 1379 GridRegion info;
1377 if (data.regionHandle == m_scene.RegionInfo.RegionHandle) 1380 if (data.regionHandle == m_scene.RegionInfo.RegionHandle)
1378 { 1381 {
1379 info = m_scene.RegionInfo; 1382 info = new GridRegion(m_scene.RegionInfo);
1380 } 1383 }
1381 else 1384 else
1382 { 1385 {
1383 // most likely still cached from building the extLandData entry 1386 // most likely still cached from building the extLandData entry
1384 info = m_scene.CommsManager.GridService.RequestNeighbourInfo(data.regionHandle); 1387 uint x = 0, y = 0;
1388 Utils.LongToUInts(data.regionHandle, out x, out y);
1389 info = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
1385 } 1390 }
1386 // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark. 1391 // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark.
1387 m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...", 1392 m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...",
1388 data.landData.Name, data.regionHandle); 1393 data.landData.Name, data.regionHandle);
1389 remoteClient.SendParcelInfo(info, data.landData, parcelID, data.x, data.y); 1394 // HACK for now
1395 RegionInfo r = new RegionInfo();
1396 r.RegionName = info.RegionName;
1397 r.RegionLocX = (uint)info.RegionLocX;
1398 r.RegionLocY = (uint)info.RegionLocY;
1399 remoteClient.SendParcelInfo(r, data.landData, parcelID, data.x, data.y);
1390 } 1400 }
1391 else 1401 else
1392 m_log.Debug("[LAND] got no parcelinfo; not sending"); 1402 m_log.Debug("[LAND] got no parcelinfo; not sending");
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 4783b35..436f332 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -33,6 +33,8 @@ using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Region.Framework.Scenes.Hypergrid; 35using OpenSim.Region.Framework.Scenes.Hypergrid;
36using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
36 38
37namespace OpenSim.Region.CoreModules.World.WorldMap 39namespace OpenSim.Region.CoreModules.World.WorldMap
38{ 40{
@@ -92,13 +94,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
92 } 94 }
93 95
94 // try to fetch from GridServer 96 // try to fetch from GridServer
95 List<RegionInfo> regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20); 97 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(UUID.Zero, mapName, 20);
96 if (regionInfos == null) 98 if (regionInfos == null)
97 { 99 {
98 m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?"); 100 m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?");
99 // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region 101 // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region
100 regionInfos = new List<RegionInfo>(); 102 regionInfos = new List<GridRegion>();
101 RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName); 103 GridRegion info = m_scene.GridService.GetRegionByName(UUID.Zero, mapName);
102 if (info != null) regionInfos.Add(info); 104 if (info != null) regionInfos.Add(info);
103 } 105 }
104 106
@@ -109,11 +111,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
109 if (mapName.Contains(".") && mapName.Contains(":")) 111 if (mapName.Contains(".") && mapName.Contains(":"))
110 { 112 {
111 // It probably is a domain name. Try to link to it. 113 // It probably is a domain name. Try to link to it.
112 RegionInfo regInfo; 114 GridRegion regInfo;
113 Scene cScene = GetClientScene(remoteClient); 115 Scene cScene = GetClientScene(remoteClient);
114 regInfo = HGHyperlink.TryLinkRegion(cScene, remoteClient, mapName); 116 IHyperlinkService hyperService = cScene.RequestModuleInterface<IHyperlinkService>();
115 if (regInfo != null) 117 if (hyperService != null)
116 regionInfos.Add(regInfo); 118 {
119 regInfo = hyperService.TryLinkRegion(remoteClient, mapName);
120 if (regInfo != null)
121 regionInfos.Add(regInfo);
122 }
117 } 123 }
118 } 124 }
119 125
@@ -122,17 +128,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
122 MapBlockData data; 128 MapBlockData data;
123 if (regionInfos.Count > 0) 129 if (regionInfos.Count > 0)
124 { 130 {
125 foreach (RegionInfo info in regionInfos) 131 foreach (GridRegion info in regionInfos)
126 { 132 {
127 data = new MapBlockData(); 133 data = new MapBlockData();
128 data.Agents = 0; 134 data.Agents = 0;
129 data.Access = info.AccessLevel; 135 data.Access = info.Access;
130 data.MapImageId = info.RegionSettings.TerrainImageID; 136 data.MapImageId = info.TerrainImage;
131 data.Name = info.RegionName; 137 data.Name = info.RegionName;
132 data.RegionFlags = 0; // TODO not used? 138 data.RegionFlags = 0; // TODO not used?
133 data.WaterHeight = 0; // not used 139 data.WaterHeight = 0; // not used
134 data.X = (ushort)info.RegionLocX; 140 data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
135 data.Y = (ushort)info.RegionLocY; 141 data.Y = (ushort)(info.RegionLocY / Constants.RegionSize);
136 blocks.Add(data); 142 blocks.Add(data);
137 } 143 }
138 } 144 }
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 1f25f28..05ed70a 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -48,6 +48,7 @@ using OpenSim.Region.Framework.Scenes;
48using Caps=OpenSim.Framework.Capabilities.Caps; 48using Caps=OpenSim.Framework.Capabilities.Caps;
49using OSDArray=OpenMetaverse.StructuredData.OSDArray; 49using OSDArray=OpenMetaverse.StructuredData.OSDArray;
50using OSDMap=OpenMetaverse.StructuredData.OSDMap; 50using OSDMap=OpenMetaverse.StructuredData.OSDMap;
51using GridRegion = OpenSim.Services.Interfaces.GridRegion;
51 52
52namespace OpenSim.Region.CoreModules.World.WorldMap 53namespace OpenSim.Region.CoreModules.World.WorldMap
53{ 54{
@@ -232,10 +233,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
232 } 233 }
233 if (lookup) 234 if (lookup)
234 { 235 {
235 List<MapBlockData> mapBlocks; 236 List<MapBlockData> mapBlocks = new List<MapBlockData>(); ;
236 237
237 mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)m_scene.RegionInfo.RegionLocX - 8, (int)m_scene.RegionInfo.RegionLocY - 8, (int)m_scene.RegionInfo.RegionLocX + 8, (int)m_scene.RegionInfo.RegionLocY + 8); 238 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
238 avatarPresence.ControllingClient.SendMapBlock(mapBlocks,0); 239 (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize,
240 (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize,
241 (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize,
242 (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize);
243 foreach (GridRegion r in regions)
244 {
245 MapBlockData block = new MapBlockData();
246 MapBlockFromGridRegion(block, r);
247 mapBlocks.Add(block);
248 }
249 avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0);
239 250
240 lock (cachedMapBlocks) 251 lock (cachedMapBlocks)
241 cachedMapBlocks = mapBlocks; 252 cachedMapBlocks = mapBlocks;
@@ -579,7 +590,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
579 } 590 }
580 if (httpserver.Length == 0) 591 if (httpserver.Length == 0)
581 { 592 {
582 RegionInfo mreg = m_scene.SceneGridService.RequestNeighbouringRegionInfo(regionhandle); 593 uint x = 0, y = 0;
594 Utils.LongToUInts(regionhandle, out x, out y);
595 GridRegion mreg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
583 596
584 if (mreg != null) 597 if (mreg != null)
585 { 598 {
@@ -719,15 +732,25 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
719 { 732 {
720 List<MapBlockData> response = new List<MapBlockData>(); 733 List<MapBlockData> response = new List<MapBlockData>();
721 734
722 // this should return one mapblock at most. But make sure: Look whether the one we requested is in there 735 // this should return one mapblock at most.
723 List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); 736 // (diva note: why?? in that case we should GetRegionByPosition)
724 if (mapBlocks != null) 737 // But make sure: Look whether the one we requested is in there
738 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
739 minX * (int)Constants.RegionSize,
740 maxX * (int)Constants.RegionSize,
741 minY * (int)Constants.RegionSize,
742 maxY * (int)Constants.RegionSize);
743
744 if (regions != null)
725 { 745 {
726 foreach (MapBlockData block in mapBlocks) 746 foreach (GridRegion r in regions)
727 { 747 {
728 if (block.X == minX && block.Y == minY) 748 if ((r.RegionLocX == minX * (int)Constants.RegionSize) &&
749 (r.RegionLocY == minY * (int)Constants.RegionSize))
729 { 750 {
730 // found it => add it to response 751 // found it => add it to response
752 MapBlockData block = new MapBlockData();
753 MapBlockFromGridRegion(block, r);
731 response.Add(block); 754 response.Add(block);
732 break; 755 break;
733 } 756 }
@@ -754,10 +777,30 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
754 777
755 protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 778 protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
756 { 779 {
757 List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); 780 List<MapBlockData> mapBlocks = new List<MapBlockData>();
781 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
782 (minX - 4) * (int)Constants.RegionSize,
783 (maxX + 4) * (int)Constants.RegionSize,
784 (minY - 4) * (int)Constants.RegionSize,
785 (maxY + 4) * (int)Constants.RegionSize);
786 foreach (GridRegion r in regions)
787 {
788 MapBlockData block = new MapBlockData();
789 MapBlockFromGridRegion(block, r);
790 mapBlocks.Add(block);
791 }
758 remoteClient.SendMapBlock(mapBlocks, flag); 792 remoteClient.SendMapBlock(mapBlocks, flag);
759 } 793 }
760 794
795 protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r)
796 {
797 block.Access = r.Access;
798 block.MapImageId = r.TerrainImage;
799 block.Name = r.RegionName;
800 block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
801 block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
802 }
803
761 public Hashtable OnHTTPGetMapImage(Hashtable keysvals) 804 public Hashtable OnHTTPGetMapImage(Hashtable keysvals)
762 { 805 {
763 m_log.Debug("[WORLD MAP]: Sending map image jpeg"); 806 m_log.Debug("[WORLD MAP]: Sending map image jpeg");
@@ -874,31 +917,34 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
874 m_log.InfoFormat( 917 m_log.InfoFormat(
875 "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath); 918 "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath);
876 919
877 List<MapBlockData> mapBlocks = 920 List<MapBlockData> mapBlocks = new List<MapBlockData>();
878 m_scene.CommsManager.GridService.RequestNeighbourMapBlocks( 921 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
879 (int)(m_scene.RegionInfo.RegionLocX - 9), 922 (int)(m_scene.RegionInfo.RegionLocX - 9) * (int)Constants.RegionSize,
880 (int)(m_scene.RegionInfo.RegionLocY - 9), 923 (int)(m_scene.RegionInfo.RegionLocX + 9) * (int)Constants.RegionSize,
881 (int)(m_scene.RegionInfo.RegionLocX + 9), 924 (int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize,
882 (int)(m_scene.RegionInfo.RegionLocY + 9)); 925 (int)(m_scene.RegionInfo.RegionLocY + 9) * (int)Constants.RegionSize);
883 List<AssetBase> textures = new List<AssetBase>(); 926 List<AssetBase> textures = new List<AssetBase>();
884 List<Image> bitImages = new List<Image>(); 927 List<Image> bitImages = new List<Image>();
885 928
886 foreach (MapBlockData mapBlock in mapBlocks) 929 foreach (GridRegion r in regions)
887 { 930 {
931 MapBlockData mapBlock = new MapBlockData();
932 MapBlockFromGridRegion(mapBlock, r);
888 AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); 933 AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
889 934
890 if (texAsset != null) 935 if (texAsset != null)
891 { 936 {
892 textures.Add(texAsset); 937 textures.Add(texAsset);
893 } 938 }
894 else 939 //else
895 { 940 //{
896 texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); 941 // // WHAT?!? This doesn't seem right. Commenting (diva)
897 if (texAsset != null) 942 // texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
898 { 943 // if (texAsset != null)
899 textures.Add(texAsset); 944 // {
900 } 945 // textures.Add(texAsset);
901 } 946 // }
947 //}
902 } 948 }
903 949
904 foreach (AssetBase asset in textures) 950 foreach (AssetBase asset in textures)