aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDiva Canto2009-09-26 07:48:21 -0700
committerDiva Canto2009-09-26 07:48:21 -0700
commit5757afe7665543e8b3ed4a322a7d6e095dafcdb3 (patch)
treebed3c7ab11459e84baa5a0fbd98dde4a81fd5e16 /OpenSim
parentMore small changes to FlotsamAssetCache as per mcortez' request. (diff)
downloadopensim-SC_OLD-5757afe7665543e8b3ed4a322a7d6e095dafcdb3.zip
opensim-SC_OLD-5757afe7665543e8b3ed4a322a7d6e095dafcdb3.tar.gz
opensim-SC_OLD-5757afe7665543e8b3ed4a322a7d6e095dafcdb3.tar.bz2
opensim-SC_OLD-5757afe7665543e8b3ed4a322a7d6e095dafcdb3.tar.xz
First pass at the heart surgery for grid services. Compiles and runs minimally. A few bugs to catch now.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Communications/Clients/RegionClient.cs16
-rw-r--r--OpenSim/Region/Application/HGCommands.cs212
-rw-r--r--OpenSim/Region/Application/OpenSim.cs5
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs2
-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.cs6
-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/ServiceConnectorsOut/Grid/HGGridConnector.cs28
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs36
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs3
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs3
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs26
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs26
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs94
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs232
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs114
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs275
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs11
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs25
-rw-r--r--OpenSim/Services/Connectors/Land/LandServiceConnector.cs13
-rw-r--r--OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs16
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs27
27 files changed, 444 insertions, 983 deletions
diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs
index 73e2db0..3419ce2 100644
--- a/OpenSim/Framework/Communications/Clients/RegionClient.cs
+++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs
@@ -35,6 +35,8 @@ using System.Text;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenMetaverse.StructuredData; 36using OpenMetaverse.StructuredData;
37 37
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39
38using log4net; 40using log4net;
39 41
40namespace OpenSim.Framework.Communications.Clients 42namespace OpenSim.Framework.Communications.Clients
@@ -43,7 +45,7 @@ namespace OpenSim.Framework.Communications.Clients
43 { 45 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 47
46 public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey, out string reason) 48 public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, out string reason)
47 { 49 {
48 reason = String.Empty; 50 reason = String.Empty;
49 51
@@ -166,7 +168,7 @@ namespace OpenSim.Framework.Communications.Clients
166 168
167 } 169 }
168 170
169 public bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData) 171 public bool DoChildAgentUpdateCall(GridRegion region, IAgentData cAgentData)
170 { 172 {
171 // Eventually, we want to use a caps url instead of the agentID 173 // Eventually, we want to use a caps url instead of the agentID
172 string uri = string.Empty; 174 string uri = string.Empty;
@@ -260,7 +262,7 @@ namespace OpenSim.Framework.Communications.Clients
260 return true; 262 return true;
261 } 263 }
262 264
263 public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent) 265 public bool DoRetrieveRootAgentCall(GridRegion region, UUID id, out IAgentData agent)
264 { 266 {
265 agent = null; 267 agent = null;
266 // Eventually, we want to use a caps url instead of the agentID 268 // Eventually, we want to use a caps url instead of the agentID
@@ -348,7 +350,7 @@ namespace OpenSim.Framework.Communications.Clients
348 } 350 }
349 351
350 352
351 public bool DoCloseAgentCall(RegionInfo region, UUID id) 353 public bool DoCloseAgentCall(GridRegion region, UUID id)
352 { 354 {
353 string uri = string.Empty; 355 string uri = string.Empty;
354 try 356 try
@@ -391,7 +393,7 @@ namespace OpenSim.Framework.Communications.Clients
391 return true; 393 return true;
392 } 394 }
393 395
394 public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, string sogXml2, bool allowScriptCrossing) 396 public bool DoCreateObjectCall(GridRegion region, ISceneObject sog, string sogXml2, bool allowScriptCrossing)
395 { 397 {
396 ulong regionHandle = GetRegionHandle(region.RegionHandle); 398 ulong regionHandle = GetRegionHandle(region.RegionHandle);
397 string uri 399 string uri
@@ -474,7 +476,7 @@ namespace OpenSim.Framework.Communications.Clients
474 476
475 } 477 }
476 478
477 public bool DoCreateObjectCall(RegionInfo region, UUID userID, UUID itemID) 479 public bool DoCreateObjectCall(GridRegion region, UUID userID, UUID itemID)
478 { 480 {
479 ulong regionHandle = GetRegionHandle(region.RegionHandle); 481 ulong regionHandle = GetRegionHandle(region.RegionHandle);
480 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; 482 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/";
@@ -646,7 +648,7 @@ namespace OpenSim.Framework.Communications.Clients
646 return false; 648 return false;
647 } 649 }
648 650
649 public virtual void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) 651 public virtual void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
650 { 652 {
651 } 653 }
652 654
diff --git a/OpenSim/Region/Application/HGCommands.cs b/OpenSim/Region/Application/HGCommands.cs
index 1786e54..f99c1a5 100644
--- a/OpenSim/Region/Application/HGCommands.cs
+++ b/OpenSim/Region/Application/HGCommands.cs
@@ -45,10 +45,6 @@ namespace OpenSim
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 public static IHyperlink HGServices = null; 46 public static IHyperlink HGServices = null;
47 47
48 private static uint m_autoMappingX = 0;
49 private static uint m_autoMappingY = 0;
50 private static bool m_enableAutoMapping = false;
51
52 public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, 48 public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
53 StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) 49 StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
54 { 50 {
@@ -61,213 +57,5 @@ namespace OpenSim
61 m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); 57 m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
62 } 58 }
63 59
64 public static void RunHGCommand(string command, string[] cmdparams, Scene scene)
65 {
66 if (command.Equals("link-mapping"))
67 {
68 if (cmdparams.Length == 2)
69 {
70 try
71 {
72 m_autoMappingX = Convert.ToUInt32(cmdparams[0]);
73 m_autoMappingY = Convert.ToUInt32(cmdparams[1]);
74 m_enableAutoMapping = true;
75 }
76 catch (Exception)
77 {
78 m_autoMappingX = 0;
79 m_autoMappingY = 0;
80 m_enableAutoMapping = false;
81 }
82 }
83 }
84 else if (command.Equals("link-region"))
85 {
86 if (cmdparams.Length < 3)
87 {
88 if ((cmdparams.Length == 1) || (cmdparams.Length == 2))
89 {
90 LoadXmlLinkFile(cmdparams, scene);
91 }
92 else
93 {
94 LinkRegionCmdUsage();
95 }
96 return;
97 }
98
99 if (cmdparams[2].Contains(":"))
100 {
101 // New format
102 uint xloc, yloc;
103 string mapName;
104 try
105 {
106 xloc = Convert.ToUInt32(cmdparams[0]);
107 yloc = Convert.ToUInt32(cmdparams[1]);
108 mapName = cmdparams[2];
109 if (cmdparams.Length > 3)
110 for (int i = 3; i < cmdparams.Length; i++)
111 mapName += " " + cmdparams[i];
112
113 m_log.Info(">> MapName: " + mapName);
114 //internalPort = Convert.ToUInt32(cmdparams[4]);
115 //remotingPort = Convert.ToUInt32(cmdparams[5]);
116 }
117 catch (Exception e)
118 {
119 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
120 LinkRegionCmdUsage();
121 return;
122 }
123
124 HGHyperlink.TryLinkRegionToCoords(scene, null, mapName, xloc, yloc);
125 }
126 else
127 {
128 // old format
129 RegionInfo regInfo;
130 uint xloc, yloc;
131 uint externalPort;
132 string externalHostName;
133 try
134 {
135 xloc = Convert.ToUInt32(cmdparams[0]);
136 yloc = Convert.ToUInt32(cmdparams[1]);
137 externalPort = Convert.ToUInt32(cmdparams[3]);
138 externalHostName = cmdparams[2];
139 //internalPort = Convert.ToUInt32(cmdparams[4]);
140 //remotingPort = Convert.ToUInt32(cmdparams[5]);
141 }
142 catch (Exception e)
143 {
144 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
145 LinkRegionCmdUsage();
146 return;
147 }
148
149 //if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
150 if (HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
151 {
152 if (cmdparams.Length >= 5)
153 {
154 regInfo.RegionName = "";
155 for (int i = 4; i < cmdparams.Length; i++)
156 regInfo.RegionName += cmdparams[i] + " ";
157 }
158 }
159 }
160 return;
161 }
162 else if (command.Equals("unlink-region"))
163 {
164 if (cmdparams.Length < 1)
165 {
166 UnlinkRegionCmdUsage();
167 return;
168 }
169 if (HGHyperlink.TryUnlinkRegion(scene, cmdparams[0]))
170 m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]);
171 else
172 m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]);
173 }
174 }
175
176 private static void LoadXmlLinkFile(string[] cmdparams, Scene scene)
177 {
178 //use http://www.hgurl.com/hypergrid.xml for test
179 try
180 {
181 XmlReader r = XmlReader.Create(cmdparams[0]);
182 XmlConfigSource cs = new XmlConfigSource(r);
183 string[] excludeSections = null;
184
185 if (cmdparams.Length == 2)
186 {
187 if (cmdparams[1].ToLower().StartsWith("excludelist:"))
188 {
189 string excludeString = cmdparams[1].ToLower();
190 excludeString = excludeString.Remove(0, 12);
191 char[] splitter = {';'};
192
193 excludeSections = excludeString.Split(splitter);
194 }
195 }
196
197 for (int i = 0; i < cs.Configs.Count; i++)
198 {
199 bool skip = false;
200 if ((excludeSections != null) && (excludeSections.Length > 0))
201 {
202 for (int n = 0; n < excludeSections.Length; n++)
203 {
204 if (excludeSections[n] == cs.Configs[i].Name.ToLower())
205 {
206 skip = true;
207 break;
208 }
209 }
210 }
211 if (!skip)
212 {
213 ReadLinkFromConfig(cs.Configs[i], scene);
214 }
215 }
216 }
217 catch (Exception e)
218 {
219 m_log.Error(e.ToString());
220 }
221 }
222
223
224 private static void ReadLinkFromConfig(IConfig config, Scene scene)
225 {
226 RegionInfo regInfo;
227 uint xloc, yloc;
228 uint externalPort;
229 string externalHostName;
230 uint realXLoc, realYLoc;
231
232 xloc = Convert.ToUInt32(config.GetString("xloc", "0"));
233 yloc = Convert.ToUInt32(config.GetString("yloc", "0"));
234 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
235 externalHostName = config.GetString("externalHostName", "");
236 realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
237 realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0"));
238
239 if (m_enableAutoMapping)
240 {
241 xloc = (uint) ((xloc%100) + m_autoMappingX);
242 yloc = (uint) ((yloc%100) + m_autoMappingY);
243 }
244
245 if (((realXLoc == 0) && (realYLoc == 0)) ||
246 (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
247 ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
248 {
249 if (
250 HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort,
251 externalHostName, out regInfo))
252 {
253 regInfo.RegionName = config.GetString("localName", "");
254 }
255 }
256 }
257
258
259 private static void LinkRegionCmdUsage()
260 {
261 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
262 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
263 m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]");
264 }
265
266 private static void UnlinkRegionCmdUsage()
267 {
268 m_log.Info("Usage: unlink-region <HostName>:<HttpPort>");
269 m_log.Info("Usage: unlink-region <LocalName>");
270 }
271
272 } 60 }
273} 61}
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index e9c9dc1..c0bdc1e 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -755,11 +755,6 @@ namespace OpenSim
755 } 755 }
756 break; 756 break;
757 757
758 case "link-region":
759 case "unlink-region":
760 case "link-mapping":
761 HGCommands.RunHGCommand(command, cmdparams, m_sceneManager.CurrentOrFirstScene);
762 break;
763 } 758 }
764 } 759 }
765 760
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 4d13e83..821de35 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -399,7 +399,7 @@ namespace OpenSim
399 } 399 }
400 catch (Exception e) 400 catch (Exception e)
401 { 401 {
402 m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e); 402 m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e.StackTrace);
403 403
404 // Carrying on now causes a lot of confusion down the 404 // Carrying on now causes a lot of confusion down the
405 // line - we need to get the user's attention 405 // line - we need to get the user's attention
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..6daab44 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);
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..9957e46 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, (minY - 4) * (int)Constants.RegionSize,
66 (maxX + 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/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
index 0c2a835..b5bade6 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -47,7 +47,7 @@ using Nini.Config;
47 47
48namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid 48namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
49{ 49{
50 public class HGGridConnector : ISharedRegionModule, IGridService 50 public class HGGridConnector : ISharedRegionModule, IGridService, IHyperlinkService
51 { 51 {
52 private static readonly ILog m_log = 52 private static readonly ILog m_log =
53 LogManager.GetLogger( 53 LogManager.GetLogger(
@@ -142,6 +142,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
142 return; 142 return;
143 143
144 scene.RegisterModuleInterface<IGridService>(this); 144 scene.RegisterModuleInterface<IGridService>(this);
145 scene.RegisterModuleInterface<IHyperlinkService>(this);
145 146
146 } 147 }
147 148
@@ -367,10 +368,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
367 } 368 }
368 #endregion 369 #endregion
369 370
370 #region Hyperlinks 371 #region IHyperlinkService
371 372
372 private static Random random = new Random(); 373 private static Random random = new Random();
373 374
375
374 public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc) 376 public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc)
375 { 377 {
376 string host = "127.0.0.1"; 378 string host = "127.0.0.1";
@@ -417,6 +419,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
417 return null; 419 return null;
418 } 420 }
419 421
422
420 // From the map search and secondlife://blah 423 // From the map search and secondlife://blah
421 public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) 424 public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
422 { 425 {
@@ -554,6 +557,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
554 return true; 557 return true;
555 } 558 }
556 559
560 public GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor)
561 {
562 return TryLinkRegion((Scene)client.Scene, client, regionDescriptor);
563 }
564
565 public GridRegion GetHyperlinkRegion(ulong handle)
566 {
567 foreach (GridRegion r in m_HyperlinkRegions.Values)
568 if (r.RegionHandle == handle)
569 return r;
570 return null;
571 }
572
573 public ulong FindRegionHandle(ulong handle)
574 {
575 foreach (GridRegion r in m_HyperlinkRegions.Values)
576 if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
577 return m_HyperlinkHandles[r.RegionID];
578 return 0;
579 }
580
557 #endregion 581 #endregion
558 582
559 } 583 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
index 9519e23..f27b2f9 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
@@ -42,6 +42,7 @@ 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 GridRegion = OpenSim.Services.Interfaces.GridRegion;
45 46
46namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion 47namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
47{ 48{
@@ -161,7 +162,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
161 // else do the remote thing 162 // else do the remote thing
162 if (!m_localBackend.IsLocalRegion(regionHandle)) 163 if (!m_localBackend.IsLocalRegion(regionHandle))
163 { 164 {
164 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 165 uint x = 0, y = 0;
166 Utils.LongToUInts(regionHandle, out x, out y);
167 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
165 if (regInfo != null) 168 if (regInfo != null)
166 { 169 {
167 m_regionClient.SendUserInformation(regInfo, aCircuit); 170 m_regionClient.SendUserInformation(regInfo, aCircuit);
@@ -183,7 +186,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
183 // else do the remote thing 186 // else do the remote thing
184 if (!m_localBackend.IsLocalRegion(regionHandle)) 187 if (!m_localBackend.IsLocalRegion(regionHandle))
185 { 188 {
186 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 189 uint x = 0, y = 0;
190 Utils.LongToUInts(regionHandle, out x, out y);
191 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
187 if (regInfo != null) 192 if (regInfo != null)
188 { 193 {
189 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); 194 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
@@ -204,7 +209,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
204 // else do the remote thing 209 // else do the remote thing
205 if (!m_localBackend.IsLocalRegion(regionHandle)) 210 if (!m_localBackend.IsLocalRegion(regionHandle))
206 { 211 {
207 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 212 uint x = 0, y = 0;
213 Utils.LongToUInts(regionHandle, out x, out y);
214 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
208 if (regInfo != null) 215 if (regInfo != null)
209 { 216 {
210 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); 217 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
@@ -225,7 +232,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
225 // else do the remote thing 232 // else do the remote thing
226 if (!m_localBackend.IsLocalRegion(regionHandle)) 233 if (!m_localBackend.IsLocalRegion(regionHandle))
227 { 234 {
228 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 235 uint x = 0, y = 0;
236 Utils.LongToUInts(regionHandle, out x, out y);
237 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
229 if (regInfo != null) 238 if (regInfo != null)
230 { 239 {
231 return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent); 240 return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent);
@@ -257,7 +266,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
257 // else do the remote thing 266 // else do the remote thing
258 if (!m_localBackend.IsLocalRegion(regionHandle)) 267 if (!m_localBackend.IsLocalRegion(regionHandle))
259 { 268 {
260 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 269 uint x = 0, y = 0;
270 Utils.LongToUInts(regionHandle, out x, out y);
271 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
261 if (regInfo != null) 272 if (regInfo != null)
262 { 273 {
263 return m_regionClient.DoCloseAgentCall(regInfo, id); 274 return m_regionClient.DoCloseAgentCall(regInfo, id);
@@ -284,7 +295,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
284 // else do the remote thing 295 // else do the remote thing
285 if (!m_localBackend.IsLocalRegion(regionHandle)) 296 if (!m_localBackend.IsLocalRegion(regionHandle))
286 { 297 {
287 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 298 uint x = 0, y = 0;
299 Utils.LongToUInts(regionHandle, out x, out y);
300 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
288 if (regInfo != null) 301 if (regInfo != null)
289 { 302 {
290 return m_regionClient.DoCreateObjectCall( 303 return m_regionClient.DoCreateObjectCall(
@@ -798,13 +811,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
798 return false; 811 return false;
799 } 812 }
800 813
801 public override void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) 814 public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
802 { 815 {
803 try 816 try
804 { 817 {
805 if (m_aScene.SceneGridService is HGSceneCommunicationService) 818 if (m_aScene.SceneGridService is HGSceneCommunicationService)
806 { 819 {
807 ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(regInfo, aCircuit); 820 // big hack for now
821 RegionInfo r = new RegionInfo();
822 r.ExternalHostName = regInfo.ExternalHostName;
823 r.HttpPort = regInfo.HttpPort;
824 r.RegionID = regInfo.RegionID;
825 r.RegionLocX = (uint)regInfo.RegionLocX;
826 r.RegionLocY = (uint)regInfo.RegionLocY;
827 ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(r, aCircuit);
808 } 828 }
809 } 829 }
810 catch // Bad cast 830 catch // Bad cast
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/RemoteNeighourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs
index c5bc03b..912c393 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,6 +133,8 @@ 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 }
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..e3661fa 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,12 +128,12 @@ 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
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 1f25f28..bd12218 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.RegionLocY - 8) * (int)Constants.RegionSize,
241 (int)(m_scene.RegionInfo.RegionLocX + 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,23 @@ 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, minY * (int)Constants.RegionSize,
740 maxX * (int)Constants.RegionSize, maxY * (int)Constants.RegionSize);
741
742 if (regions != null)
725 { 743 {
726 foreach (MapBlockData block in mapBlocks) 744 foreach (GridRegion r in regions)
727 { 745 {
728 if (block.X == minX && block.Y == minY) 746 if ((r.RegionLocX == minX * (int)Constants.RegionSize) &&
747 (r.RegionLocY == minY * (int)Constants.RegionSize))
729 { 748 {
730 // found it => add it to response 749 // found it => add it to response
750 MapBlockData block = new MapBlockData();
751 MapBlockFromGridRegion(block, r);
731 response.Add(block); 752 response.Add(block);
732 break; 753 break;
733 } 754 }
@@ -754,10 +775,28 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
754 775
755 protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 776 protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
756 { 777 {
757 List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); 778 List<MapBlockData> mapBlocks = new List<MapBlockData>();
779 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
780 (minX - 4) * (int)Constants.RegionSize, (minY - 4) * (int)Constants.RegionSize,
781 (maxX + 4) * (int)Constants.RegionSize, (maxY + 4) * (int)Constants.RegionSize);
782 foreach (GridRegion r in regions)
783 {
784 MapBlockData block = new MapBlockData();
785 MapBlockFromGridRegion(block, r);
786 mapBlocks.Add(block);
787 }
758 remoteClient.SendMapBlock(mapBlocks, flag); 788 remoteClient.SendMapBlock(mapBlocks, flag);
759 } 789 }
760 790
791 protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r)
792 {
793 block.Access = r.Access;
794 block.MapImageId = r.TerrainImage;
795 block.Name = r.RegionName;
796 block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
797 block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
798 }
799
761 public Hashtable OnHTTPGetMapImage(Hashtable keysvals) 800 public Hashtable OnHTTPGetMapImage(Hashtable keysvals)
762 { 801 {
763 m_log.Debug("[WORLD MAP]: Sending map image jpeg"); 802 m_log.Debug("[WORLD MAP]: Sending map image jpeg");
@@ -874,31 +913,34 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
874 m_log.InfoFormat( 913 m_log.InfoFormat(
875 "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath); 914 "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath);
876 915
877 List<MapBlockData> mapBlocks = 916 List<MapBlockData> mapBlocks = new List<MapBlockData>();
878 m_scene.CommsManager.GridService.RequestNeighbourMapBlocks( 917 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
879 (int)(m_scene.RegionInfo.RegionLocX - 9), 918 (int)(m_scene.RegionInfo.RegionLocX - 9) * (int)Constants.RegionSize,
880 (int)(m_scene.RegionInfo.RegionLocY - 9), 919 (int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize,
881 (int)(m_scene.RegionInfo.RegionLocX + 9), 920 (int)(m_scene.RegionInfo.RegionLocX + 9) * (int)Constants.RegionSize,
882 (int)(m_scene.RegionInfo.RegionLocY + 9)); 921 (int)(m_scene.RegionInfo.RegionLocY + 9) * (int)Constants.RegionSize);
883 List<AssetBase> textures = new List<AssetBase>(); 922 List<AssetBase> textures = new List<AssetBase>();
884 List<Image> bitImages = new List<Image>(); 923 List<Image> bitImages = new List<Image>();
885 924
886 foreach (MapBlockData mapBlock in mapBlocks) 925 foreach (GridRegion r in regions)
887 { 926 {
927 MapBlockData mapBlock = new MapBlockData();
928 MapBlockFromGridRegion(mapBlock, r);
888 AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); 929 AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
889 930
890 if (texAsset != null) 931 if (texAsset != null)
891 { 932 {
892 textures.Add(texAsset); 933 textures.Add(texAsset);
893 } 934 }
894 else 935 //else
895 { 936 //{
896 texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); 937 // // WHAT?!? This doesn't seem right. Commenting (diva)
897 if (texAsset != null) 938 // texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
898 { 939 // if (texAsset != null)
899 textures.Add(texAsset); 940 // {
900 } 941 // textures.Add(texAsset);
901 } 942 // }
943 //}
902 } 944 }
903 945
904 foreach (AssetBase asset in textures) 946 foreach (AssetBase asset in textures)
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
deleted file mode 100644
index a576feb..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
+++ /dev/null
@@ -1,232 +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.Net;
30using System.Reflection;
31using log4net;
32using OpenMetaverse;
33using OpenSim.Framework;
34
35namespace OpenSim.Region.Framework.Scenes.Hypergrid
36{
37 public class HGHyperlink
38 {
39 private static readonly ILog m_log =
40 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41 private static Random random = new Random();
42
43 public static RegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc)
44 {
45 string host = "127.0.0.1";
46 string portstr;
47 string regionName = "";
48 uint port = 9000;
49 string[] parts = mapName.Split(new char[] { ':' });
50 if (parts.Length >= 1)
51 {
52 host = parts[0];
53 }
54 if (parts.Length >= 2)
55 {
56 portstr = parts[1];
57 if (!UInt32.TryParse(portstr, out port))
58 regionName = parts[1];
59 }
60 // always take the last one
61 if (parts.Length >= 3)
62 {
63 regionName = parts[2];
64 }
65
66 // Sanity check. Don't ever link to this sim.
67 IPAddress ipaddr = null;
68 try
69 {
70 ipaddr = Util.GetHostFromDNS(host);
71 }
72 catch { }
73
74 if ((ipaddr != null) &&
75 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
76 {
77 RegionInfo regInfo;
78 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
79 if (success)
80 {
81 regInfo.RegionName = mapName;
82 return regInfo;
83 }
84 }
85
86 return null;
87 }
88
89 public static RegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
90 {
91 uint xloc = (uint)(random.Next(0, Int16.MaxValue));
92 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
93 }
94
95 public static bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc,
96 string externalRegionName, uint externalPort, string externalHostName, out RegionInfo regInfo)
97 {
98 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
99
100 regInfo = new RegionInfo();
101 regInfo.RegionName = externalRegionName;
102 regInfo.HttpPort = externalPort;
103 regInfo.ExternalHostName = externalHostName;
104 regInfo.RegionLocX = xloc;
105 regInfo.RegionLocY = yloc;
106
107 try
108 {
109 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
110 }
111 catch (Exception e)
112 {
113 m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message);
114 return false;
115 }
116 regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
117
118 // Finally, link it
119 try
120 {
121 m_scene.CommsManager.GridService.RegisterRegion(regInfo);
122 }
123 catch (Exception e)
124 {
125 m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
126 return false;
127 }
128
129 uint x, y;
130 if (!Check4096(m_scene, regInfo, out x, out y))
131 {
132 m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
133 if (client != null)
134 client.SendAlertMessage("Region is too far (" + x + ", " + y + ")");
135 m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")");
136 return false;
137 }
138
139 if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y))
140 {
141 m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
142 if (client != null)
143 client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")");
144 m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")");
145 return false;
146 }
147
148 m_log.Debug("[HGrid]: link region succeeded");
149 return true;
150 }
151
152 public static bool TryUnlinkRegion(Scene m_scene, string mapName)
153 {
154 RegionInfo regInfo = null;
155 if (mapName.Contains(":"))
156 {
157 string host = "127.0.0.1";
158 //string portstr;
159 //string regionName = "";
160 uint port = 9000;
161 string[] parts = mapName.Split(new char[] { ':' });
162 if (parts.Length >= 1)
163 {
164 host = parts[0];
165 }
166// if (parts.Length >= 2)
167// {
168// portstr = parts[1];
169// if (!UInt32.TryParse(portstr, out port))
170// regionName = parts[1];
171// }
172 // always take the last one
173// if (parts.Length >= 3)
174// {
175// regionName = parts[2];
176// }
177 regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(host, port);
178 }
179 else
180 {
181 regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(mapName);
182 }
183 if (regInfo != null)
184 {
185 return m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
186 }
187 else
188 {
189 m_log.InfoFormat("[HGrid]: Region {0} not found", mapName);
190 return false;
191 }
192 }
193
194 /// <summary>
195 /// Cope with this viewer limitation.
196 /// </summary>
197 /// <param name="regInfo"></param>
198 /// <returns></returns>
199 public static bool Check4096(Scene m_scene, RegionInfo regInfo, out uint x, out uint y)
200 {
201 ulong realHandle;
202 if (UInt64.TryParse(regInfo.regionSecret, out realHandle))
203 {
204 Utils.LongToUInts(realHandle, out x, out y);
205 x = x / Constants.RegionSize;
206 y = y / Constants.RegionSize;
207
208 if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) ||
209 (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096))
210 {
211 return false;
212 }
213 return true;
214 }
215 else
216 {
217 m_scene.CommsManager.GridService.RegisterRegion(regInfo);
218 m_log.Debug("[HGrid]: Gnomes. Region deregistered.");
219 x = y = 0;
220 return false;
221 }
222 }
223
224 public static bool CheckCoords(uint thisx, uint thisy, uint x, uint y)
225 {
226 if ((thisx == x) && (thisy == y))
227 return false;
228 return true;
229 }
230
231 }
232}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
index bf55df7..b1981b6 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
@@ -29,6 +29,7 @@ using OpenMetaverse;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenSim.Framework.Communications.Cache; 30using OpenSim.Framework.Communications.Cache;
31using TPFlags = OpenSim.Framework.Constants.TeleportFlags; 31using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
32 33
33namespace OpenSim.Region.Framework.Scenes.Hypergrid 34namespace OpenSim.Region.Framework.Scenes.Hypergrid
34{ 35{
@@ -50,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
50 51
51 if (UserProfile != null) 52 if (UserProfile != null)
52 { 53 {
53 RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); 54 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
54 //if (regionInfo != null) 55 //if (regionInfo != null)
55 //{ 56 //{
56 // UserProfile.HomeRegionID = regionInfo.RegionID; 57 // UserProfile.HomeRegionID = regionInfo.RegionID;
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
index 5c99d73..e8e5e78 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
@@ -38,6 +38,7 @@ using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache; 38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Capabilities; 39using OpenSim.Framework.Capabilities;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41 42
42namespace OpenSim.Region.Framework.Scenes.Hypergrid 43namespace OpenSim.Region.Framework.Scenes.Hypergrid
43{ 44{
@@ -106,7 +107,10 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
106 } 107 }
107 else 108 else
108 { 109 {
109 RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); 110 uint x = 0, y = 0;
111 Utils.LongToUInts(regionHandle, out x, out y);
112 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
113
110 if (reg != null) 114 if (reg != null)
111 { 115 {
112 116
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d8478a2..8990f29 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -49,6 +49,7 @@ using OpenSim.Region.Framework.Scenes.Serialization;
49using OpenSim.Region.Physics.Manager; 49using OpenSim.Region.Physics.Manager;
50using Timer=System.Timers.Timer; 50using Timer=System.Timers.Timer;
51using TPFlags = OpenSim.Framework.Constants.TeleportFlags; 51using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
52using GridRegion = OpenSim.Services.Interfaces.GridRegion;
52 53
53namespace OpenSim.Region.Framework.Scenes 54namespace OpenSim.Region.Framework.Scenes
54{ 55{
@@ -193,6 +194,26 @@ namespace OpenSim.Region.Framework.Scenes
193 } 194 }
194 } 195 }
195 196
197 protected IGridService m_GridService = null;
198
199 public IGridService GridService
200 {
201 get
202 {
203 if (m_GridService == null)
204 {
205 m_GridService = RequestModuleInterface<IGridService>();
206
207 if (m_GridService == null)
208 {
209 throw new Exception("No IGridService available. This could happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. Please also check that you have the correct version of your inventory service dll. Sometimes old versions of this dll will still exist. Do a clean checkout and re-create the opensim.ini from the opensim.ini.example.");
210 }
211 }
212
213 return m_GridService;
214 }
215 }
216
196 protected IXMLRPC m_xmlrpcModule; 217 protected IXMLRPC m_xmlrpcModule;
197 protected IWorldComm m_worldCommModule; 218 protected IWorldComm m_worldCommModule;
198 protected IAvatarFactory m_AvatarFactory; 219 protected IAvatarFactory m_AvatarFactory;
@@ -1336,24 +1357,31 @@ namespace OpenSim.Region.Framework.Scenes
1336 RegisterCommsEvents(); 1357 RegisterCommsEvents();
1337 1358
1338 // These two 'commands' *must be* next to each other or sim rebooting fails. 1359 // These two 'commands' *must be* next to each other or sim rebooting fails.
1339 m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo); 1360 //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo);
1361
1362 GridRegion region = new GridRegion(RegionInfo);
1363 bool success = GridService.RegisterRegion(RegionInfo.ScopeID, region);
1364 if (!success)
1365 throw new Exception("Can't register with grid");
1366
1367 m_sceneGridService.SetScene(this);
1340 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); 1368 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
1341 1369
1342 Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings(); 1370 //Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings();
1343 1371
1344 if (dGridSettings.ContainsKey("allow_forceful_banlines")) 1372 //if (dGridSettings.ContainsKey("allow_forceful_banlines"))
1345 { 1373 //{
1346 if (dGridSettings["allow_forceful_banlines"] != "TRUE") 1374 // if (dGridSettings["allow_forceful_banlines"] != "TRUE")
1347 { 1375 // {
1348 m_log.Info("[GRID]: Grid is disabling forceful parcel banlists"); 1376 // m_log.Info("[GRID]: Grid is disabling forceful parcel banlists");
1349 EventManager.TriggerSetAllowForcefulBan(false); 1377 // EventManager.TriggerSetAllowForcefulBan(false);
1350 } 1378 // }
1351 else 1379 // else
1352 { 1380 // {
1353 m_log.Info("[GRID]: Grid is allowing forceful parcel banlists"); 1381 // m_log.Info("[GRID]: Grid is allowing forceful parcel banlists");
1354 EventManager.TriggerSetAllowForcefulBan(true); 1382 // EventManager.TriggerSetAllowForcefulBan(true);
1355 } 1383 // }
1356 } 1384 //}
1357 } 1385 }
1358 1386
1359 /// <summary> 1387 /// <summary>
@@ -2717,10 +2745,12 @@ namespace OpenSim.Region.Framework.Scenes
2717 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); 2745 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId);
2718 if (UserProfile != null) 2746 if (UserProfile != null)
2719 { 2747 {
2720 RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegionID); 2748 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
2721 if (regionInfo == null) 2749 if (regionInfo == null)
2722 { 2750 {
2723 regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); 2751 uint x = 0, y = 0;
2752 Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
2753 regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
2724 if (regionInfo != null) // home region can be away temporarily, too 2754 if (regionInfo != null) // home region can be away temporarily, too
2725 { 2755 {
2726 UserProfile.HomeRegionID = regionInfo.RegionID; 2756 UserProfile.HomeRegionID = regionInfo.RegionID;
@@ -3111,7 +3141,11 @@ namespace OpenSim.Region.Framework.Scenes
3111 if (m_interregionCommsIn != null) 3141 if (m_interregionCommsIn != null)
3112 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3142 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3113 3143
3144 // this does nothing; should be removed
3114 m_sceneGridService.Close(); 3145 m_sceneGridService.Close();
3146
3147 if (!GridService.DeregisterRegion(m_regInfo.RegionID))
3148 m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName);
3115 } 3149 }
3116 3150
3117 /// <summary> 3151 /// <summary>
@@ -3557,30 +3591,6 @@ namespace OpenSim.Region.Framework.Scenes
3557 } 3591 }
3558 3592
3559 /// <summary> 3593 /// <summary>
3560 /// Requests information about this region from gridcomms
3561 /// </summary>
3562 /// <param name="regionHandle"></param>
3563 /// <returns></returns>
3564 public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
3565 {
3566 return m_sceneGridService.RequestNeighbouringRegionInfo(regionHandle);
3567 }
3568
3569 /// <summary>
3570 /// Requests textures for map from minimum region to maximum region in world cordinates
3571 /// </summary>
3572 /// <param name="remoteClient"></param>
3573 /// <param name="minX"></param>
3574 /// <param name="minY"></param>
3575 /// <param name="maxX"></param>
3576 /// <param name="maxY"></param>
3577 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
3578 {
3579 m_log.DebugFormat("[MAPBLOCK]: {0}-{1}, {2}-{3}", minX, minY, maxX, maxY);
3580 m_sceneGridService.RequestMapBlocks(remoteClient, minX, minY, maxX, maxY);
3581 }
3582
3583 /// <summary>
3584 /// Tries to teleport agent to other region. 3594 /// Tries to teleport agent to other region.
3585 /// </summary> 3595 /// </summary>
3586 /// <param name="remoteClient"></param> 3596 /// <param name="remoteClient"></param>
@@ -3591,7 +3601,7 @@ namespace OpenSim.Region.Framework.Scenes
3591 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, 3601 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
3592 Vector3 lookat, uint teleportFlags) 3602 Vector3 lookat, uint teleportFlags)
3593 { 3603 {
3594 RegionInfo regionInfo = m_sceneGridService.RequestClosestRegion(regionName); 3604 GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName);
3595 if (regionInfo == null) 3605 if (regionInfo == null)
3596 { 3606 {
3597 // can't find the region: Tell viewer and abort 3607 // can't find the region: Tell viewer and abort
@@ -3680,7 +3690,7 @@ namespace OpenSim.Region.Framework.Scenes
3680 /// <param name="position"></param> 3690 /// <param name="position"></param>
3681 public void RequestTeleportLandmark(IClientAPI remoteClient, UUID regionID, Vector3 position) 3691 public void RequestTeleportLandmark(IClientAPI remoteClient, UUID regionID, Vector3 position)
3682 { 3692 {
3683 RegionInfo info = CommsManager.GridService.RequestNeighbourInfo(regionID); 3693 GridRegion info = GridService.GetRegionByUUID(UUID.Zero, regionID);
3684 3694
3685 if (info == null) 3695 if (info == null)
3686 { 3696 {
@@ -3864,10 +3874,6 @@ namespace OpenSim.Region.Framework.Scenes
3864 return LandChannel.GetLandObject((int)x, (int)y).landData; 3874 return LandChannel.GetLandObject((int)x, (int)y).landData;
3865 } 3875 }
3866 3876
3867 public RegionInfo RequestClosestRegion(string name)
3868 {
3869 return m_sceneGridService.RequestClosestRegion(name);
3870 }
3871 3877
3872 #endregion 3878 #endregion
3873 3879
@@ -4178,14 +4184,18 @@ namespace OpenSim.Region.Framework.Scenes
4178 4184
4179 public void RegionHandleRequest(IClientAPI client, UUID regionID) 4185 public void RegionHandleRequest(IClientAPI client, UUID regionID)
4180 { 4186 {
4181 RegionInfo info; 4187 ulong handle = 0;
4182 if (regionID == RegionInfo.RegionID) 4188 if (regionID == RegionInfo.RegionID)
4183 info = RegionInfo; 4189 handle = RegionInfo.RegionHandle;
4184 else 4190 else
4185 info = CommsManager.GridService.RequestNeighbourInfo(regionID); 4191 {
4192 GridRegion r = GridService.GetRegionByUUID(UUID.Zero, regionID);
4193 if (r != null)
4194 handle = r.RegionHandle;
4195 }
4186 4196
4187 if (info != null) 4197 if (handle != 0)
4188 client.SendRegionHandle(regionID, info.RegionHandle); 4198 client.SendRegionHandle(regionID, handle);
4189 } 4199 }
4190 4200
4191 public void TerrainUnAcked(IClientAPI client, int patchX, int patchY) 4201 public void TerrainUnAcked(IClientAPI client, int patchX, int patchY)
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 56cd87d..60e89e0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework.Capabilities;
41using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
43using OSD = OpenMetaverse.StructuredData.OSD; 43using OSD = OpenMetaverse.StructuredData.OSD;
44using GridRegion = OpenSim.Services.Interfaces.GridRegion;
44 45
45namespace OpenSim.Region.Framework.Scenes 46namespace OpenSim.Region.Framework.Scenes
46{ 47{
@@ -58,6 +59,7 @@ namespace OpenSim.Region.Framework.Scenes
58 protected CommunicationsManager m_commsProvider; 59 protected CommunicationsManager m_commsProvider;
59 protected IInterregionCommsOut m_interregionCommsOut; 60 protected IInterregionCommsOut m_interregionCommsOut;
60 protected RegionInfo m_regionInfo; 61 protected RegionInfo m_regionInfo;
62 protected Scene m_scene;
61 63
62 protected RegionCommsListener regionCommsHost; 64 protected RegionCommsListener regionCommsHost;
63 65
@@ -131,6 +133,13 @@ namespace OpenSim.Region.Framework.Scenes
131 m_agentsInTransit = new List<UUID>(); 133 m_agentsInTransit = new List<UUID>();
132 } 134 }
133 135
136 public void SetScene(Scene s)
137 {
138 m_scene = s;
139 m_regionInfo = s.RegionInfo;
140 m_interregionCommsOut = m_scene.RequestModuleInterface<IInterregionCommsOut>();
141 }
142
134 /// <summary> 143 /// <summary>
135 /// Register a region with the grid 144 /// Register a region with the grid
136 /// </summary> 145 /// </summary>
@@ -138,40 +147,30 @@ namespace OpenSim.Region.Framework.Scenes
138 /// <exception cref="System.Exception">Thrown if region registration fails.</exception> 147 /// <exception cref="System.Exception">Thrown if region registration fails.</exception>
139 public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos) 148 public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos)
140 { 149 {
141 m_interregionCommsOut = comms_out; 150 //m_interregionCommsOut = comms_out;
142 151
143 m_regionInfo = regionInfos; 152 //m_regionInfo = regionInfos;
144 m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName; 153 //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
145 regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); 154 //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
146 155
147 if (regionCommsHost != null) 156 //if (regionCommsHost != null)
148 { 157 //{
149 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString()); 158 // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
150 159
151 regionCommsHost.debugRegionName = regionInfos.RegionName; 160 // regionCommsHost.debugRegionName = regionInfos.RegionName;
152 regionCommsHost.OnExpectPrim += IncomingPrimCrossing; 161 // regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
153 regionCommsHost.OnExpectUser += NewUserConnection; 162 // regionCommsHost.OnExpectUser += NewUserConnection;
154 regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; 163 // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
155 regionCommsHost.OnCloseAgentConnection += CloseConnection; 164 // regionCommsHost.OnCloseAgentConnection += CloseConnection;
156 regionCommsHost.OnRegionUp += newRegionUp; 165 // regionCommsHost.OnRegionUp += newRegionUp;
157 regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; 166 // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
158 regionCommsHost.OnLogOffUser += GridLogOffUser; 167 // regionCommsHost.OnLogOffUser += GridLogOffUser;
159 regionCommsHost.OnGetLandData += FetchLandData; 168 // regionCommsHost.OnGetLandData += FetchLandData;
160 } 169 //}
161 else 170 //else
162 { 171 //{
163 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null"); 172 // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null");
164 } 173 //}
165 }
166
167 /// <summary>
168 /// Returns a region with the name closest to string provided
169 /// </summary>
170 /// <param name="name">Partial Region Name for matching</param>
171 /// <returns>Region Information for the region</returns>
172 public RegionInfo RequestClosestRegion(string name)
173 {
174 return m_commsProvider.GridService.RequestClosestRegion(name);
175 } 174 }
176 175
177 /// <summary> 176 /// <summary>
@@ -180,30 +179,31 @@ namespace OpenSim.Region.Framework.Scenes
180 /// </summary> 179 /// </summary>
181 public void Close() 180 public void Close()
182 { 181 {
183 if (regionCommsHost != null) 182
184 { 183 //if (regionCommsHost != null)
185 regionCommsHost.OnLogOffUser -= GridLogOffUser; 184 //{
186 regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; 185 // regionCommsHost.OnLogOffUser -= GridLogOffUser;
187 regionCommsHost.OnRegionUp -= newRegionUp; 186 // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
188 regionCommsHost.OnExpectUser -= NewUserConnection; 187 // regionCommsHost.OnRegionUp -= newRegionUp;
189 regionCommsHost.OnExpectPrim -= IncomingPrimCrossing; 188 // regionCommsHost.OnExpectUser -= NewUserConnection;
190 regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; 189 // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
191 regionCommsHost.OnCloseAgentConnection -= CloseConnection; 190 // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
192 regionCommsHost.OnGetLandData -= FetchLandData; 191 // regionCommsHost.OnCloseAgentConnection -= CloseConnection;
192 // regionCommsHost.OnGetLandData -= FetchLandData;
193 193
194 try 194 // try
195 { 195 // {
196 m_commsProvider.GridService.DeregisterRegion(m_regionInfo); 196 // m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
197 } 197 // }
198 catch (Exception e) 198 // catch (Exception e)
199 { 199 // {
200 m_log.ErrorFormat( 200 // m_log.ErrorFormat(
201 "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing", 201 // "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing",
202 m_regionInfo.RegionName, e); 202 // m_regionInfo.RegionName, e);
203 } 203 // }
204 204
205 regionCommsHost = null; 205 // regionCommsHost = null;
206 } 206 //}
207 } 207 }
208 208
209 #region CommsManager Event handlers 209 #region CommsManager Event handlers
@@ -337,7 +337,7 @@ namespace OpenSim.Region.Framework.Scenes
337 #region Inform Client of Neighbours 337 #region Inform Client of Neighbours
338 338
339 private delegate void InformClientOfNeighbourDelegate( 339 private delegate void InformClientOfNeighbourDelegate(
340 ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, IPEndPoint endPoint, bool newAgent); 340 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
341 341
342 private void InformClientOfNeighbourCompleted(IAsyncResult iar) 342 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
343 { 343 {
@@ -355,7 +355,7 @@ namespace OpenSim.Region.Framework.Scenes
355 /// <param name="a"></param> 355 /// <param name="a"></param>
356 /// <param name="regionHandle"></param> 356 /// <param name="regionHandle"></param>
357 /// <param name="endPoint"></param> 357 /// <param name="endPoint"></param>
358 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, 358 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
359 IPEndPoint endPoint, bool newAgent) 359 IPEndPoint endPoint, bool newAgent)
360 { 360 {
361 // Let's wait just a little to give time to originating regions to catch up with closing child agents 361 // Let's wait just a little to give time to originating regions to catch up with closing child agents
@@ -371,11 +371,15 @@ namespace OpenSim.Region.Framework.Scenes
371 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort 371 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
372 + "/CAPS/" + a.CapsPath + "0000/"; 372 + "/CAPS/" + a.CapsPath + "0000/";
373 373
374 m_log.DebugFormat("[XXX] CAPS = {0}", capsPath);
375 m_log.DebugFormat("[XXX] ExternalEndPoint = {0}", endPoint.ToString());
376
374 string reason = String.Empty; 377 string reason = String.Empty;
375 378
376 //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a); 379 //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a);
377 380
378 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason); 381 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason);
382 m_log.DebugFormat("[XXX] Here 1 {0}", regionAccepted);
379 383
380 if (regionAccepted && newAgent) 384 if (regionAccepted && newAgent)
381 { 385 {
@@ -390,6 +394,7 @@ namespace OpenSim.Region.Framework.Scenes
390 } 394 }
391 #endregion 395 #endregion
392 396
397 m_log.DebugFormat("[XXX] HERE 2");
393 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID); 398 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
394 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath); 399 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
395 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}", 400 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}",
@@ -407,17 +412,7 @@ namespace OpenSim.Region.Framework.Scenes
407 412
408 } 413 }
409 414
410 public void RequestNeighbors(RegionInfo region) 415 public List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
411 {
412 // List<SimpleRegionInfo> neighbours =
413 m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
414 //IPEndPoint blah = new IPEndPoint();
415
416 //blah.Address = region.RemotingAddress;
417 //blah.Port = region.RemotingPort;
418 }
419
420 public List<SimpleRegionInfo> RequestNeighbors(Scene pScene, uint pRegionLocX, uint pRegionLocY)
421 { 416 {
422 Border[] northBorders = pScene.NorthBorders.ToArray(); 417 Border[] northBorders = pScene.NorthBorders.ToArray();
423 Border[] southBorders = pScene.SouthBorders.ToArray(); 418 Border[] southBorders = pScene.SouthBorders.ToArray();
@@ -427,50 +422,34 @@ namespace OpenSim.Region.Framework.Scenes
427 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. 422 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement.
428 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) 423 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
429 { 424 {
430 return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); 425 return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
431 } 426 }
432 else 427 else
433 { 428 {
434 Vector2 extent = Vector2.Zero; 429 Vector2 extent = Vector2.Zero;
435 for (int i=0;i<eastBorders.Length;i++) 430 for (int i = 0; i < eastBorders.Length; i++)
436 { 431 {
437 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; 432 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
438 } 433 }
439 for (int i=0;i<northBorders.Length;i++) 434 for (int i = 0; i < northBorders.Length; i++)
440 { 435 {
441 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; 436 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
442 } 437 }
443 438
444 List<SimpleRegionInfo> neighbourList = new List<SimpleRegionInfo>();
445
446 // Loss of fraction on purpose 439 // Loss of fraction on purpose
447 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; 440 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
448 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; 441 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
449 442
450 int startX = (int) pRegionLocX - 1; 443 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
451 int startY = (int) pRegionLocY - 1; 444 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
452 445
453 int endX = (int) pRegionLocX + (int)extent.X; 446 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
454 int endY = (int) pRegionLocY + (int)extent.Y; 447 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
455 448
456 for (int i=startX;i<endX;i++) 449 List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
457 { 450 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
458 for (int j=startY;j<endY;j++) 451
459 { 452 return neighbours;
460 // Skip CurrentRegion
461 if (i == (int)pRegionLocX && j == (int)pRegionLocY)
462 continue;
463
464 ulong regionHandle = Util.UIntsToLong((uint)(i * Constants.RegionSize),
465 (uint)(j * Constants.RegionSize));
466 RegionInfo neighborreg = m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
467 if (neighborreg != null)
468 {
469 neighbourList.Add(neighborreg);
470 }
471 }
472 }
473 return neighbourList;
474 //SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo() 453 //SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo()
475 //return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); 454 //return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY);
476 } 455 }
@@ -482,23 +461,24 @@ namespace OpenSim.Region.Framework.Scenes
482 /// </summary> 461 /// </summary>
483 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours) 462 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
484 { 463 {
485 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); 464 //List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
465 List<GridRegion> neighbours = new List<GridRegion>();
486 466
487 //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 467 ////m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
488 for (int i = 0; i < lstneighbours.Count; i++) 468 //for (int i = 0; i < lstneighbours.Count; i++)
489 { 469 //{
490 // We don't want to keep sending to regions that consistently fail on comms. 470 // // We don't want to keep sending to regions that consistently fail on comms.
491 if (!(lstneighbours[i].commFailTF)) 471 // if (!(lstneighbours[i].commFailTF))
492 { 472 // {
493 neighbours.Add(new SimpleRegionInfo(lstneighbours[i])); 473 // neighbours.Add(new SimpleRegionInfo(lstneighbours[i]));
494 } 474 // }
495 } 475 //}
496 // we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be 476 // we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be
497 // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/ 477 // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/
498 if (m_regionInfo != null) 478 if (m_regionInfo != null)
499 { 479 {
500 neighbours = 480 neighbours =
501 RequestNeighbors(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 481 RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
502 } 482 }
503 else 483 else
504 { 484 {
@@ -547,8 +527,9 @@ namespace OpenSim.Region.Framework.Scenes
547 527
548 /// Create the necessary child agents 528 /// Create the necessary child agents
549 List<AgentCircuitData> cagents = new List<AgentCircuitData>(); 529 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
550 foreach (SimpleRegionInfo neighbour in neighbours) 530 //foreach (SimpleRegionInfo neighbour in neighbours)
551 { 531 foreach (GridRegion neighbour in neighbours)
532 {
552 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle) 533 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
553 { 534 {
554 535
@@ -588,7 +569,7 @@ namespace OpenSim.Region.Framework.Scenes
588 569
589 bool newAgent = false; 570 bool newAgent = false;
590 int count = 0; 571 int count = 0;
591 foreach (SimpleRegionInfo neighbour in neighbours) 572 foreach (GridRegion neighbour in neighbours)
592 { 573 {
593 // Don't do it if there's already an agent in that region 574 // Don't do it if there's already an agent in that region
594 if (newRegions.Contains(neighbour.RegionHandle)) 575 if (newRegions.Contains(neighbour.RegionHandle))
@@ -641,7 +622,7 @@ namespace OpenSim.Region.Framework.Scenes
641 /// This informs a single neighboring region about agent "avatar". 622 /// This informs a single neighboring region about agent "avatar".
642 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 623 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
643 /// </summary> 624 /// </summary>
644 public void InformNeighborChildAgent(ScenePresence avatar, SimpleRegionInfo region) 625 public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
645 { 626 {
646 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); 627 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
647 agent.BaseFolder = UUID.Zero; 628 agent.BaseFolder = UUID.Zero;
@@ -700,18 +681,16 @@ namespace OpenSim.Region.Framework.Scenes
700 } 681 }
701 } 682 }
702 683
703 /// <summary> 684
704 /// Called by scene when region is initialized (not always when it's listening for agents)
705 /// This is an inter-region message that informs the surrounding neighbors that the sim is up.
706 /// </summary>
707 public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region) 685 public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region)
708 { 686 {
709 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); 687 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
710 688
711 689
712 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); 690 List<GridRegion> neighbours = new List<GridRegion>();
713 // This stays uncached because we don't already know about our neighbors at this point. 691 // This stays uncached because we don't already know about our neighbors at this point.
714 neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 692
693 neighbours = m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
715 if (neighbours != null) 694 if (neighbours != null)
716 { 695 {
717 for (int i = 0; i < neighbours.Count; i++) 696 for (int i = 0; i < neighbours.Count; i++)
@@ -727,6 +706,7 @@ namespace OpenSim.Region.Framework.Scenes
727 //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region)); 706 //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region));
728 } 707 }
729 708
709
730 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle); 710 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle);
731 711
732 /// <summary> 712 /// <summary>
@@ -822,41 +802,6 @@ namespace OpenSim.Region.Framework.Scenes
822 } 802 }
823 } 803 }
824 804
825 /// <summary>
826 /// Helper function to request neighbors from grid-comms
827 /// </summary>
828 /// <param name="regionHandle"></param>
829 /// <returns></returns>
830 public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
831 {
832 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionHandle.ToString());
833 return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
834 }
835
836 /// <summary>
837 /// Helper function to request neighbors from grid-comms
838 /// </summary>
839 /// <param name="regionID"></param>
840 /// <returns></returns>
841 public virtual RegionInfo RequestNeighbouringRegionInfo(UUID regionID)
842 {
843 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionID);
844 return m_commsProvider.GridService.RequestNeighbourInfo(regionID);
845 }
846
847 /// <summary>
848 /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
849 /// </summary>
850 /// <param name="minX"></param>
851 /// <param name="minY"></param>
852 /// <param name="maxX"></param>
853 /// <param name="maxY"></param>
854 public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
855 {
856 List<MapBlockData> mapBlocks;
857 mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4);
858 remoteClient.SendMapBlock(mapBlocks, 0);
859 }
860 805
861 /// <summary> 806 /// <summary>
862 /// Try to teleport an agent to a new region. 807 /// Try to teleport an agent to a new region.
@@ -921,7 +866,10 @@ namespace OpenSim.Region.Framework.Scenes
921 } 866 }
922 else 867 else
923 { 868 {
924 RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); 869 uint x = 0, y = 0;
870 Utils.LongToUInts(regionHandle, out x, out y);
871 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
872
925 if (reg != null) 873 if (reg != null)
926 { 874 {
927 m_log.DebugFormat( 875 m_log.DebugFormat(
@@ -1228,10 +1176,10 @@ namespace OpenSim.Region.Framework.Scenes
1228 return false; 1176 return false;
1229 } 1177 }
1230 1178
1231 private List<ulong> NeighbourHandles(List<SimpleRegionInfo> neighbours) 1179 private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
1232 { 1180 {
1233 List<ulong> handles = new List<ulong>(); 1181 List<ulong> handles = new List<ulong>();
1234 foreach (SimpleRegionInfo reg in neighbours) 1182 foreach (GridRegion reg in neighbours)
1235 { 1183 {
1236 handles.Add(reg.RegionHandle); 1184 handles.Add(reg.RegionHandle);
1237 } 1185 }
@@ -1482,7 +1430,10 @@ namespace OpenSim.Region.Framework.Scenes
1482 m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); 1430 m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
1483 1431
1484 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); 1432 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
1485 SimpleRegionInfo neighbourRegion = RequestNeighbouringRegionInfo(neighbourHandle); 1433
1434 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
1435 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
1436
1486 if (neighbourRegion != null && agent.ValidateAttachments()) 1437 if (neighbourRegion != null && agent.ValidateAttachments())
1487 { 1438 {
1488 pos = pos + (agent.Velocity); 1439 pos = pos + (agent.Velocity);
@@ -1609,11 +1560,6 @@ namespace OpenSim.Region.Framework.Scenes
1609 } 1560 }
1610 1561
1611 1562
1612 public Dictionary<string, string> GetGridSettings()
1613 {
1614 return m_commsProvider.GridService.GetGridSettings();
1615 }
1616
1617 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) 1563 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
1618 { 1564 {
1619 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat); 1565 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
@@ -1650,19 +1596,14 @@ namespace OpenSim.Region.Framework.Scenes
1650 return m_commsProvider.GetUserFriendList(friendlistowner); 1596 return m_commsProvider.GetUserFriendList(friendlistowner);
1651 } 1597 }
1652 1598
1653 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
1654 {
1655 return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
1656 }
1657
1658 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) 1599 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
1659 { 1600 {
1660 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); 1601 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
1661 } 1602 }
1662 1603
1663 public List<RegionInfo> RequestNamedRegions(string name, int maxNumber) 1604 public List<GridRegion> RequestNamedRegions(string name, int maxNumber)
1664 { 1605 {
1665 return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber); 1606 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
1666 } 1607 }
1667 1608
1668 //private void Dump(string msg, List<ulong> handles) 1609 //private void Dump(string msg, List<ulong> handles)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 6772f75..286b7ca 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework.Communications.Cache;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes.Types; 37using OpenSim.Region.Framework.Scenes.Types;
38using OpenSim.Region.Physics.Manager; 38using OpenSim.Region.Physics.Manager;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
40namespace OpenSim.Region.Framework.Scenes 41namespace OpenSim.Region.Framework.Scenes
41{ 42{
@@ -2934,8 +2935,9 @@ namespace OpenSim.Region.Framework.Scenes
2934 else if (dir > 3 && dir < 7) // Heading Sout 2935 else if (dir > 3 && dir < 7) // Heading Sout
2935 neighboury--; 2936 neighboury--;
2936 2937
2937 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); 2938 int x = (int)(neighbourx * Constants.RegionSize);
2938 SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); 2939 int y = (int)(neighboury * Constants.RegionSize);
2940 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y);
2939 2941
2940 if (neighbourRegion == null) 2942 if (neighbourRegion == null)
2941 { 2943 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 4c52b11..1ebe24e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -50,6 +50,9 @@ using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
50using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 50using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
51using OpenSim.Region.ScriptEngine.Interfaces; 51using OpenSim.Region.ScriptEngine.Interfaces;
52using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; 52using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
53using OpenSim.Services.Interfaces;
54
55using GridRegion = OpenSim.Services.Interfaces.GridRegion;
53 56
54using AssetLandmark = OpenSim.Framework.AssetLandmark; 57using AssetLandmark = OpenSim.Framework.AssetLandmark;
55 58
@@ -5226,12 +5229,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5226 } 5229 }
5227 } 5230 }
5228 5231
5229 List<SimpleRegionInfo> neighbors = World.CommsManager.GridService.RequestNeighbours(World.RegionInfo.RegionLocX, World.RegionInfo.RegionLocY); 5232 List<GridRegion> neighbors = World.GridService.GetNeighbours(World.RegionInfo.ScopeID, World.RegionInfo.RegionID);
5230 5233
5231 uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x; 5234 uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x;
5232 uint neighborY = World.RegionInfo.RegionLocY + (uint)dir.y; 5235 uint neighborY = World.RegionInfo.RegionLocY + (uint)dir.y;
5233 5236
5234 foreach (SimpleRegionInfo sri in neighbors) 5237 foreach (GridRegion sri in neighbors)
5235 { 5238 {
5236 if (sri.RegionLocX == neighborX && sri.RegionLocY == neighborY) 5239 if (sri.RegionLocX == neighborX && sri.RegionLocY == neighborY)
5237 return 0; 5240 return 0;
@@ -8181,7 +8184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8181 8184
8182 string reply = String.Empty; 8185 string reply = String.Empty;
8183 8186
8184 RegionInfo info = m_ScriptEngine.World.RequestClosestRegion(simulator); 8187 GridRegion info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator);
8185 8188
8186 switch (data) 8189 switch (data)
8187 { 8190 {
@@ -8208,7 +8211,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8208 ConditionalScriptSleep(1000); 8211 ConditionalScriptSleep(1000);
8209 return UUID.Zero.ToString(); 8212 return UUID.Zero.ToString();
8210 } 8213 }
8211 int access = info.RegionSettings.Maturity; 8214 int access = info.Maturity;
8212 if (access == 0) 8215 if (access == 0)
8213 reply = "PG"; 8216 reply = "PG";
8214 else if (access == 1) 8217 else if (access == 1)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index ccdd4c5..0b95abc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -48,6 +48,8 @@ using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
48using OpenSim.Region.ScriptEngine.Interfaces; 48using OpenSim.Region.ScriptEngine.Interfaces;
49using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; 49using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
50using TPFlags = OpenSim.Framework.Constants.TeleportFlags; 50using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
51using OpenSim.Services.Interfaces;
52using GridRegion = OpenSim.Services.Interfaces.GridRegion;
51using System.Text.RegularExpressions; 53using System.Text.RegularExpressions;
52 54
53using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; 55using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
@@ -599,17 +601,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
599 if (regionName.Contains(".") && regionName.Contains(":")) 601 if (regionName.Contains(".") && regionName.Contains(":"))
600 { 602 {
601 // Try to link the region 603 // Try to link the region
602 RegionInfo regInfo = HGHyperlink.TryLinkRegion(World, 604 IHyperlinkService hyperService = World.RequestModuleInterface<IHyperlinkService>();
603 presence.ControllingClient, 605 if (hyperService != null)
604 regionName);
605 // Get the region name
606 if (regInfo != null)
607 { 606 {
608 regionName = regInfo.RegionName; 607 GridRegion regInfo = hyperService.TryLinkRegion(presence.ControllingClient,
609 } 608 regionName);
610 else 609 // Get the region name
611 { 610 if (regInfo != null)
612 // Might need to ping the client here in case of failure?? 611 {
612 regionName = regInfo.RegionName;
613 }
614 else
615 {
616 // Might need to ping the client here in case of failure??
617 }
613 } 618 }
614 } 619 }
615 presence.ControllingClient.SendTeleportLocationStart(); 620 presence.ControllingClient.SendTeleportLocationStart();
diff --git a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
index 0243f1f..06bc11c 100644
--- a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
@@ -38,6 +38,7 @@ using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
39using OpenMetaverse; 39using OpenMetaverse;
40using Nwc.XmlRpc; 40using Nwc.XmlRpc;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41 42
42namespace OpenSim.Services.Connectors 43namespace OpenSim.Services.Connectors
43{ 44{
@@ -47,20 +48,20 @@ namespace OpenSim.Services.Connectors
47 LogManager.GetLogger( 48 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType); 49 MethodBase.GetCurrentMethod().DeclaringType);
49 50
50 protected IGridServices m_MapService = null; 51 protected IGridService m_GridService = null;
51 52
52 public LandServicesConnector() 53 public LandServicesConnector()
53 { 54 {
54 } 55 }
55 56
56 public LandServicesConnector(IGridServices gridServices) 57 public LandServicesConnector(IGridService gridServices)
57 { 58 {
58 Initialise(gridServices); 59 Initialise(gridServices);
59 } 60 }
60 61
61 public virtual void Initialise(IGridServices gridServices) 62 public virtual void Initialise(IGridService gridServices)
62 { 63 {
63 m_MapService = gridServices; 64 m_GridService = gridServices;
64 } 65 }
65 66
66 public virtual LandData GetLandData(ulong regionHandle, uint x, uint y) 67 public virtual LandData GetLandData(ulong regionHandle, uint x, uint y)
@@ -76,7 +77,9 @@ namespace OpenSim.Services.Connectors
76 77
77 try 78 try
78 { 79 {
79 RegionInfo info = m_MapService.RequestNeighbourInfo(regionHandle); 80 uint xpos = 0, ypos = 0;
81 Utils.LongToUInts(regionHandle, out xpos, out ypos);
82 GridRegion info = m_GridService.GetRegionByPosition(UUID.Zero, (int)xpos, (int)ypos);
80 if (info != null) // just to be sure 83 if (info != null) // just to be sure
81 { 84 {
82 XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); 85 XmlRpcRequest request = new XmlRpcRequest("land_data", paramList);
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs
index 7fff537..1b595e7 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs
@@ -41,6 +41,8 @@ using OpenSim.Services.Interfaces;
41using OpenMetaverse; 41using OpenMetaverse;
42using OpenMetaverse.StructuredData; 42using OpenMetaverse.StructuredData;
43 43
44using GridRegion = OpenSim.Services.Interfaces.GridRegion;
45
44namespace OpenSim.Services.Connectors 46namespace OpenSim.Services.Connectors
45{ 47{
46 public class NeighbourServicesConnector : INeighbourService 48 public class NeighbourServicesConnector : INeighbourService
@@ -49,25 +51,27 @@ namespace OpenSim.Services.Connectors
49 LogManager.GetLogger( 51 LogManager.GetLogger(
50 MethodBase.GetCurrentMethod().DeclaringType); 52 MethodBase.GetCurrentMethod().DeclaringType);
51 53
52 protected IGridServices m_MapService = null; 54 protected IGridService m_GridService = null;
53 55
54 public NeighbourServicesConnector() 56 public NeighbourServicesConnector()
55 { 57 {
56 } 58 }
57 59
58 public NeighbourServicesConnector(IGridServices gridServices) 60 public NeighbourServicesConnector(IGridService gridServices)
59 { 61 {
60 Initialise(gridServices); 62 Initialise(gridServices);
61 } 63 }
62 64
63 public virtual void Initialise(IGridServices gridServices) 65 public virtual void Initialise(IGridService gridServices)
64 { 66 {
65 m_MapService = gridServices; 67 m_GridService = gridServices;
66 } 68 }
67 69
68 public virtual bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) 70 public virtual bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
69 { 71 {
70 RegionInfo regInfo = m_MapService.RequestNeighbourInfo(regionHandle); 72 uint x = 0, y = 0;
73 Utils.LongToUInts(regionHandle, out x, out y);
74 GridRegion regInfo = m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
71 if ((regInfo != null) && 75 if ((regInfo != null) &&
72 // Don't remote-call this instance; that's a startup hickup 76 // Don't remote-call this instance; that's a startup hickup
73 !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort))) 77 !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort)))
@@ -79,7 +83,7 @@ namespace OpenSim.Services.Connectors
79 return false; 83 return false;
80 } 84 }
81 85
82 public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) 86 public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion)
83 { 87 {
84 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; 88 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/";
85 //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); 89 //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri);
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index ce432ab..96dc82b9 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -122,9 +122,6 @@ namespace OpenSim.Services.Interfaces
122 } 122 }
123 protected string m_regionName = String.Empty; 123 protected string m_regionName = String.Empty;
124 124
125 protected bool Allow_Alternate_Ports;
126 public bool m_allow_alternate_ports;
127
128 protected string m_externalHostName; 125 protected string m_externalHostName;
129 126
130 protected IPEndPoint m_internalEndPoint; 127 protected IPEndPoint m_internalEndPoint;
@@ -146,6 +143,10 @@ namespace OpenSim.Services.Interfaces
146 public UUID RegionID = UUID.Zero; 143 public UUID RegionID = UUID.Zero;
147 public UUID ScopeID = UUID.Zero; 144 public UUID ScopeID = UUID.Zero;
148 145
146 public UUID TerrainImage = UUID.Zero;
147 public byte Access;
148 public int Maturity;
149
149 public GridRegion() 150 public GridRegion()
150 { 151 {
151 } 152 }
@@ -183,9 +184,11 @@ namespace OpenSim.Services.Interfaces
183 m_internalEndPoint = ConvertFrom.InternalEndPoint; 184 m_internalEndPoint = ConvertFrom.InternalEndPoint;
184 m_externalHostName = ConvertFrom.ExternalHostName; 185 m_externalHostName = ConvertFrom.ExternalHostName;
185 m_httpPort = ConvertFrom.HttpPort; 186 m_httpPort = ConvertFrom.HttpPort;
186 m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; 187 RegionID = ConvertFrom.RegionID;
187 RegionID = UUID.Zero;
188 ServerURI = ConvertFrom.ServerURI; 188 ServerURI = ConvertFrom.ServerURI;
189 TerrainImage = ConvertFrom.RegionSettings.TerrainImageID;
190 Access = ConvertFrom.AccessLevel;
191 Maturity = ConvertFrom.RegionSettings.Maturity;
189 } 192 }
190 193
191 194
@@ -268,7 +271,9 @@ namespace OpenSim.Services.Interfaces
268 kvp["serverHttpPort"] = HttpPort.ToString(); 271 kvp["serverHttpPort"] = HttpPort.ToString();
269 kvp["serverURI"] = ServerURI; 272 kvp["serverURI"] = ServerURI;
270 kvp["serverPort"] = InternalEndPoint.Port.ToString(); 273 kvp["serverPort"] = InternalEndPoint.Port.ToString();
271 274 kvp["regionMapTexture"] = TerrainImage.ToString();
275 kvp["access"] = Access.ToString();
276 // Maturity doesn't seem to exist in the DB
272 return kvp; 277 return kvp;
273 } 278 }
274 279
@@ -312,6 +317,16 @@ namespace OpenSim.Services.Interfaces
312 317
313 if (kvp.ContainsKey("serverURI")) 318 if (kvp.ContainsKey("serverURI"))
314 ServerURI = (string)kvp["serverURI"]; 319 ServerURI = (string)kvp["serverURI"];
320
321 if (kvp.ContainsKey("regionMapTexture"))
322 {
323 UUID.TryParse((string)kvp["regionMapTexture"], out TerrainImage);
324 }
325
326 if (kvp.ContainsKey("access"))
327 {
328 Access = Byte.Parse((string)kvp["access"]); ;
329 }
315 } 330 }
316 } 331 }
317 332