aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application
diff options
context:
space:
mode:
authordiva2009-02-07 16:10:23 +0000
committerdiva2009-02-07 16:10:23 +0000
commitff0fa1290397d96dbf49477a2668fa62e9be22dc (patch)
treee7be5308f5379f5a6d2c0f663ebe0b8aa6bf87f4 /OpenSim/Region/Application
parentFix a .NET issue where changing a locked reference would cause a crash (diff)
downloadopensim-SC_OLD-ff0fa1290397d96dbf49477a2668fa62e9be22dc.zip
opensim-SC_OLD-ff0fa1290397d96dbf49477a2668fa62e9be22dc.tar.gz
opensim-SC_OLD-ff0fa1290397d96dbf49477a2668fa62e9be22dc.tar.bz2
opensim-SC_OLD-ff0fa1290397d96dbf49477a2668fa62e9be22dc.tar.xz
Adds support for HG linking to specific regions within an instance. The format is Host:Port:Region. Refactored the linking code from MapSearchModule to HGHyperlink, so that it can be used both by the MapSearchModule and the Console command.
Diffstat (limited to 'OpenSim/Region/Application')
-rw-r--r--OpenSim/Region/Application/HGOpenSimNode.cs124
1 files changed, 56 insertions, 68 deletions
diff --git a/OpenSim/Region/Application/HGOpenSimNode.cs b/OpenSim/Region/Application/HGOpenSimNode.cs
index 2de9ddf..57c6fa3 100644
--- a/OpenSim/Region/Application/HGOpenSimNode.cs
+++ b/OpenSim/Region/Application/HGOpenSimNode.cs
@@ -79,7 +79,7 @@ namespace OpenSim
79 base.StartupSpecific(); 79 base.StartupSpecific();
80 80
81 MainConsole.Instance.Commands.AddCommand("hypergrid", "link-mapping", "link-mapping [<x> <y>] <cr>", "Set local coordinate to map HG regions to", RunCommand); 81 MainConsole.Instance.Commands.AddCommand("hypergrid", "link-mapping", "link-mapping [<x> <y>] <cr>", "Set local coordinate to map HG regions to", RunCommand);
82 MainConsole.Instance.Commands.AddCommand("hypergrid", "link-region", "link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName> <cr>", "Link a hypergrid region", RunCommand); 82 MainConsole.Instance.Commands.AddCommand("hypergrid", "link-region", "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", "Link a hypergrid region", RunCommand);
83 } 83 }
84 84
85 protected override void InitialiseStandaloneServices(LibraryRootFolder libraryRootFolder) 85 protected override void InitialiseStandaloneServices(LibraryRootFolder libraryRootFolder)
@@ -175,50 +175,71 @@ namespace OpenSim
175 } 175 }
176 else if (command.Equals("link-region")) 176 else if (command.Equals("link-region"))
177 { 177 {
178 // link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName> 178 if (cmdparams.Count < 3)
179 if (cmdparams.Count < 4)
180 { 179 {
181 if ((cmdparams.Count == 1) || (cmdparams.Count ==2)) 180 LinkRegionCmdUsage();
181 return;
182 }
183
184 if (cmdparams[2].Contains(":"))
185 { // New format
186 uint xloc, yloc;
187 string mapName;
188 try
182 { 189 {
183 LoadXmlLinkFile(cmdparams.ToArray()); 190 xloc = Convert.ToUInt32(cmdparams[0]);
191 yloc = Convert.ToUInt32(cmdparams[1]);
192 mapName = cmdparams[2];
193 if (cmdparams.Count > 3)
194 for (int i = 3; i < cmdparams.Count; i++)
195 mapName += " " + cmdparams[i];
196
197 Console.WriteLine(">> MapName: " + mapName);
198 //internalPort = Convert.ToUInt32(cmdparams[4]);
199 //remotingPort = Convert.ToUInt32(cmdparams[5]);
184 } 200 }
185 else 201 catch (Exception e)
186 { 202 {
203 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
187 LinkRegionCmdUsage(); 204 LinkRegionCmdUsage();
205 return;
188 } 206 }
189 return;
190 }
191 207
192 RegionInfo regInfo; 208 HGHyperlink.TryLinkRegionToCoords(m_sceneManager.CurrentOrFirstScene, null, mapName, xloc, yloc);
193 uint xloc, yloc;
194 uint externalPort;
195 string externalHostName;
196 try
197 {
198 xloc = Convert.ToUInt32(cmdparams[0]);
199 yloc = Convert.ToUInt32(cmdparams[1]);
200 externalPort = Convert.ToUInt32(cmdparams[3]);
201 externalHostName = cmdparams[2];
202 //internalPort = Convert.ToUInt32(cmdparams[4]);
203 //remotingPort = Convert.ToUInt32(cmdparams[5]);
204 }
205 catch (Exception e)
206 {
207 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
208 LinkRegionCmdUsage();
209 return;
210 } 209 }
210 else
211 { // old format
212 RegionInfo regInfo;
213 uint xloc, yloc;
214 uint externalPort;
215 string externalHostName;
216 try
217 {
218 xloc = Convert.ToUInt32(cmdparams[0]);
219 yloc = Convert.ToUInt32(cmdparams[1]);
220 externalPort = Convert.ToUInt32(cmdparams[3]);
221 externalHostName = cmdparams[2];
222 //internalPort = Convert.ToUInt32(cmdparams[4]);
223 //remotingPort = Convert.ToUInt32(cmdparams[5]);
224 }
225 catch (Exception e)
226 {
227 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
228 LinkRegionCmdUsage();
229 return;
230 }
211 231
212 if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo)) 232 //if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
213 { 233 if (HGHyperlink.TryCreateLink(m_sceneManager.CurrentOrFirstScene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
214 if (cmdparams.Count >= 5)
215 { 234 {
216 regInfo.RegionName = ""; 235 if (cmdparams.Count >= 5)
217 for (int i = 4; i < cmdparams.Count; i++) 236 {
218 regInfo.RegionName += cmdparams[i] + " "; 237 regInfo.RegionName = "";
238 for (int i = 4; i < cmdparams.Count; i++)
239 regInfo.RegionName += cmdparams[i] + " ";
240 }
219 } 241 }
220 } 242 }
221
222 return; 243 return;
223 } 244 }
224 } 245 }
@@ -292,49 +313,16 @@ namespace OpenSim
292 313
293 if (((realXLoc == 0) && (realYLoc == 0)) || (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) 314 if (((realXLoc == 0) && (realYLoc == 0)) || (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
294 { 315 {
295 if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo)) 316 if (HGHyperlink.TryCreateLink(m_sceneManager.CurrentOrFirstScene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
296 { 317 {
297 regInfo.RegionName = config.GetString("localName", ""); 318 regInfo.RegionName = config.GetString("localName", "");
298 } 319 }
299 } 320 }
300 } 321 }
301 322
302 private bool TryCreateLink(uint xloc, uint yloc, uint externalPort, string externalHostName, out RegionInfo regInfo)
303 {
304 regInfo = new RegionInfo();
305 regInfo.RegionLocX = xloc;
306 regInfo.RegionLocY = yloc;
307 regInfo.ExternalHostName = externalHostName;
308 regInfo.HttpPort = externalPort;
309 //regInfo.RemotingPort = remotingPort;
310 try
311 {
312 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
313 }
314 catch (Exception e)
315 {
316 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
317 LinkRegionCmdUsage();
318 return false;
319 }
320 regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
321
322 // Finally, link it
323 try
324 {
325 m_sceneManager.CurrentOrFirstScene.CommsManager.GridService.RegisterRegion(regInfo);
326 }
327 catch (Exception e)
328 {
329 m_log.Warn("[HGrid] Unable to link region: " + e.StackTrace);
330 return false;
331 }
332
333 return true;
334 }
335
336 private void LinkRegionCmdUsage() 323 private void LinkRegionCmdUsage()
337 { 324 {
325 Console.WriteLine("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
338 Console.WriteLine("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]"); 326 Console.WriteLine("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
339 } 327 }
340 } 328 }