diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/GridService/HypergridLinker.cs | 236 |
1 files changed, 171 insertions, 65 deletions
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 7abed20..9d016fc 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs | |||
@@ -47,7 +47,7 @@ using OpenMetaverse; | |||
47 | 47 | ||
48 | namespace OpenSim.Services.GridService | 48 | namespace OpenSim.Services.GridService |
49 | { | 49 | { |
50 | public class HypergridLinker | 50 | public class HypergridLinker : IHypergridLinker |
51 | { | 51 | { |
52 | private static readonly ILog m_log = | 52 | private static readonly ILog m_log = |
53 | LogManager.GetLogger( | 53 | LogManager.GetLogger( |
@@ -63,14 +63,11 @@ namespace OpenSim.Services.GridService | |||
63 | protected GatekeeperServiceConnector m_GatekeeperConnector; | 63 | protected GatekeeperServiceConnector m_GatekeeperConnector; |
64 | 64 | ||
65 | protected UUID m_ScopeID = UUID.Zero; | 65 | protected UUID m_ScopeID = UUID.Zero; |
66 | // protected bool m_Check4096 = true; | ||
66 | protected string m_MapTileDirectory = string.Empty; | 67 | protected string m_MapTileDirectory = string.Empty; |
67 | protected string m_ThisGatekeeper = string.Empty; | 68 | protected string m_ThisGatekeeper = string.Empty; |
68 | protected Uri m_ThisGatekeeperURI = null; | 69 | protected Uri m_ThisGatekeeperURI = null; |
69 | 70 | ||
70 | // Hyperlink regions are hyperlinks on the map | ||
71 | public readonly Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>(); | ||
72 | protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>(); | ||
73 | |||
74 | protected GridRegion m_DefaultRegion; | 71 | protected GridRegion m_DefaultRegion; |
75 | protected GridRegion DefaultRegion | 72 | protected GridRegion DefaultRegion |
76 | { | 73 | { |
@@ -78,7 +75,7 @@ namespace OpenSim.Services.GridService | |||
78 | { | 75 | { |
79 | if (m_DefaultRegion == null) | 76 | if (m_DefaultRegion == null) |
80 | { | 77 | { |
81 | List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID); | 78 | List<GridRegion> defs = m_GridService.GetDefaultHypergridRegions(m_ScopeID); |
82 | if (defs != null && defs.Count > 0) | 79 | if (defs != null && defs.Count > 0) |
83 | m_DefaultRegion = defs[0]; | 80 | m_DefaultRegion = defs[0]; |
84 | else | 81 | else |
@@ -123,9 +120,14 @@ namespace OpenSim.Services.GridService | |||
123 | if (scope != string.Empty) | 120 | if (scope != string.Empty) |
124 | UUID.TryParse(scope, out m_ScopeID); | 121 | UUID.TryParse(scope, out m_ScopeID); |
125 | 122 | ||
123 | // m_Check4096 = gridConfig.GetBoolean("Check4096", true); | ||
124 | |||
126 | m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles"); | 125 | m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles"); |
127 | 126 | ||
128 | m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", string.Empty); | 127 | m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", |
128 | new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); | ||
129 | // Legacy. Remove soon! | ||
130 | m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper); | ||
129 | try | 131 | try |
130 | { | 132 | { |
131 | m_ThisGatekeeperURI = new Uri(m_ThisGatekeeper); | 133 | m_ThisGatekeeperURI = new Uri(m_ThisGatekeeper); |
@@ -154,18 +156,18 @@ namespace OpenSim.Services.GridService | |||
154 | 156 | ||
155 | if (MainConsole.Instance != null) | 157 | if (MainConsole.Instance != null) |
156 | { | 158 | { |
157 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", | 159 | MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region", |
158 | "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]", | 160 | "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]", |
159 | "Link a HyperGrid Region. Examples for <ServerURI>: http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand); | 161 | "Link a HyperGrid Region. Examples for <ServerURI>: http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand); |
160 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", | 162 | MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region", |
161 | "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]", | 163 | "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]", |
162 | "Link a hypergrid region (deprecated)", RunCommand); | 164 | "Link a hypergrid region (deprecated)", RunCommand); |
163 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region", | 165 | MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "unlink-region", |
164 | "unlink-region <local name>", | 166 | "unlink-region <local name>", |
165 | "Unlink a hypergrid region", RunCommand); | 167 | "Unlink a hypergrid region", RunCommand); |
166 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>]", | 168 | MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-mapping", "link-mapping [<x> <y>]", |
167 | "Set local coordinate to map HG regions to", RunCommand); | 169 | "Set local coordinate to map HG regions to", RunCommand); |
168 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks", | 170 | MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "show hyperlinks", "show hyperlinks", |
169 | "List the HG regions", HandleShow); | 171 | "List the HG regions", HandleShow); |
170 | } | 172 | } |
171 | } | 173 | } |
@@ -177,14 +179,14 @@ namespace OpenSim.Services.GridService | |||
177 | public GridRegion LinkRegion(UUID scopeID, string regionDescriptor) | 179 | public GridRegion LinkRegion(UUID scopeID, string regionDescriptor) |
178 | { | 180 | { |
179 | string reason = string.Empty; | 181 | string reason = string.Empty; |
180 | int xloc = random.Next(0, Int16.MaxValue) * (int)Constants.RegionSize; | 182 | uint xloc = Util.RegionToWorldLoc((uint)random.Next(0, Int16.MaxValue)); |
181 | return TryLinkRegionToCoords(scopeID, regionDescriptor, xloc, 0, out reason); | 183 | return TryLinkRegionToCoords(scopeID, regionDescriptor, (int)xloc, 0, out reason); |
182 | } | 184 | } |
183 | 185 | ||
184 | private static Random random = new Random(); | 186 | private static Random random = new Random(); |
185 | 187 | ||
186 | // From the command line link-region (obsolete) and the map | 188 | // From the command line link-region (obsolete) and the map |
187 | public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason) | 189 | private GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason) |
188 | { | 190 | { |
189 | return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); | 191 | return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); |
190 | } | 192 | } |
@@ -194,24 +196,36 @@ namespace OpenSim.Services.GridService | |||
194 | reason = string.Empty; | 196 | reason = string.Empty; |
195 | GridRegion regInfo = null; | 197 | GridRegion regInfo = null; |
196 | 198 | ||
199 | mapName = mapName.Trim(); | ||
200 | |||
197 | if (!mapName.StartsWith("http")) | 201 | if (!mapName.StartsWith("http")) |
198 | { | 202 | { |
199 | string host = "127.0.0.1"; | 203 | // Formats: grid.example.com:8002:region name |
200 | string portstr; | 204 | // grid.example.com:region name |
205 | // grid.example.com:8002 | ||
206 | // grid.example.com | ||
207 | |||
208 | string host; | ||
209 | uint port = 80; | ||
201 | string regionName = ""; | 210 | string regionName = ""; |
202 | uint port = 0; | 211 | |
203 | string[] parts = mapName.Split(new char[] { ':' }); | 212 | string[] parts = mapName.Split(new char[] { ':' }); |
204 | if (parts.Length >= 1) | 213 | |
214 | if (parts.Length == 0) | ||
205 | { | 215 | { |
206 | host = parts[0]; | 216 | reason = "Wrong format for link-region"; |
217 | return null; | ||
207 | } | 218 | } |
219 | |||
220 | host = parts[0]; | ||
221 | |||
208 | if (parts.Length >= 2) | 222 | if (parts.Length >= 2) |
209 | { | 223 | { |
210 | portstr = parts[1]; | 224 | // If it's a number then assume it's a port. Otherwise, it's a region name. |
211 | //m_log.Debug("-- port = " + portstr); | 225 | if (!UInt32.TryParse(parts[1], out port)) |
212 | if (!UInt32.TryParse(portstr, out port)) | ||
213 | regionName = parts[1]; | 226 | regionName = parts[1]; |
214 | } | 227 | } |
228 | |||
215 | // always take the last one | 229 | // always take the last one |
216 | if (parts.Length >= 3) | 230 | if (parts.Length >= 3) |
217 | { | 231 | { |
@@ -228,14 +242,30 @@ namespace OpenSim.Services.GridService | |||
228 | } | 242 | } |
229 | else | 243 | else |
230 | { | 244 | { |
231 | string[] parts = mapName.Split(new char[] {' '}); | 245 | // Formats: http://grid.example.com region name |
232 | string regionName = String.Empty; | 246 | // http://grid.example.com "region name" |
233 | if (parts.Length > 1) | 247 | // http://grid.example.com |
248 | |||
249 | string serverURI; | ||
250 | string regionName = ""; | ||
251 | |||
252 | string[] parts = mapName.Split(new char[] { ' ' }); | ||
253 | |||
254 | if (parts.Length == 0) | ||
234 | { | 255 | { |
235 | regionName = mapName.Substring(parts[0].Length + 1); | 256 | reason = "Wrong format for link-region"; |
236 | regionName = regionName.Trim(new char[] {'"'}); | 257 | return null; |
237 | } | 258 | } |
238 | if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, parts[0], ownerID, out regInfo, out reason)) | 259 | |
260 | serverURI = parts[0]; | ||
261 | |||
262 | if (parts.Length >= 2) | ||
263 | { | ||
264 | regionName = mapName.Substring(serverURI.Length); | ||
265 | regionName = regionName.Trim(new char[] { '"', ' ' }); | ||
266 | } | ||
267 | |||
268 | if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason)) | ||
239 | { | 269 | { |
240 | regInfo.RegionName = mapName; | 270 | regInfo.RegionName = mapName; |
241 | return regInfo; | 271 | return regInfo; |
@@ -244,31 +274,39 @@ namespace OpenSim.Services.GridService | |||
244 | 274 | ||
245 | return null; | 275 | return null; |
246 | } | 276 | } |
247 | 277 | ||
248 | public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, UUID ownerID, out GridRegion regInfo, out string reason) | 278 | private bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, UUID ownerID, out GridRegion regInfo, out string reason) |
249 | { | 279 | { |
250 | return TryCreateLink(scopeID, xloc, yloc, remoteRegionName, externalPort, externalHostName, null, ownerID, out regInfo, out reason); | 280 | return TryCreateLink(scopeID, xloc, yloc, remoteRegionName, externalPort, externalHostName, null, ownerID, out regInfo, out reason); |
251 | } | 281 | } |
252 | 282 | ||
253 | public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) | 283 | private bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) |
254 | { | 284 | { |
255 | m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}", | 285 | lock (this) |
286 | { | ||
287 | return TryCreateLinkImpl(scopeID, xloc, yloc, remoteRegionName, externalPort, externalHostName, serverURI, ownerID, out regInfo, out reason); | ||
288 | } | ||
289 | } | ||
290 | |||
291 | private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) | ||
292 | { | ||
293 | m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>", | ||
256 | ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), | 294 | ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), |
257 | remoteRegionName, xloc / Constants.RegionSize, yloc / Constants.RegionSize); | 295 | remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc)); |
258 | 296 | ||
259 | reason = string.Empty; | 297 | reason = string.Empty; |
260 | Uri uri = null; | 298 | Uri uri = null; |
261 | 299 | ||
262 | regInfo = new GridRegion(); | 300 | regInfo = new GridRegion(); |
263 | if ( externalPort > 0) | 301 | if (externalPort > 0) |
264 | regInfo.HttpPort = externalPort; | 302 | regInfo.HttpPort = externalPort; |
265 | else | 303 | else |
266 | regInfo.HttpPort = 0; | 304 | regInfo.HttpPort = 80; |
267 | if ( externalHostName != null) | 305 | if (externalHostName != null) |
268 | regInfo.ExternalHostName = externalHostName; | 306 | regInfo.ExternalHostName = externalHostName; |
269 | else | 307 | else |
270 | regInfo.ExternalHostName = "0.0.0.0"; | 308 | regInfo.ExternalHostName = "0.0.0.0"; |
271 | if ( serverURI != null) | 309 | if (serverURI != null) |
272 | { | 310 | { |
273 | regInfo.ServerURI = serverURI; | 311 | regInfo.ServerURI = serverURI; |
274 | try | 312 | try |
@@ -280,7 +318,7 @@ namespace OpenSim.Services.GridService | |||
280 | catch {} | 318 | catch {} |
281 | } | 319 | } |
282 | 320 | ||
283 | if ( remoteRegionName != string.Empty ) | 321 | if (remoteRegionName != string.Empty) |
284 | regInfo.RegionName = remoteRegionName; | 322 | regInfo.RegionName = remoteRegionName; |
285 | 323 | ||
286 | regInfo.RegionLocX = xloc; | 324 | regInfo.RegionLocX = xloc; |
@@ -293,6 +331,7 @@ namespace OpenSim.Services.GridService | |||
293 | { | 331 | { |
294 | if (regInfo.ExternalHostName == m_ThisGatekeeperURI.Host && regInfo.HttpPort == m_ThisGatekeeperURI.Port) | 332 | if (regInfo.ExternalHostName == m_ThisGatekeeperURI.Host && regInfo.HttpPort == m_ThisGatekeeperURI.Port) |
295 | { | 333 | { |
334 | m_log.InfoFormat("[HYPERGRID LINKER]: Cannot hyperlink to regions on the same grid"); | ||
296 | reason = "Cannot hyperlink to regions on the same grid"; | 335 | reason = "Cannot hyperlink to regions on the same grid"; |
297 | return false; | 336 | return false; |
298 | } | 337 | } |
@@ -304,8 +343,8 @@ namespace OpenSim.Services.GridService | |||
304 | GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY); | 343 | GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY); |
305 | if (region != null) | 344 | if (region != null) |
306 | { | 345 | { |
307 | m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}", | 346 | m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates <{0},{1}> are already occupied by region {2} with uuid {3}", |
308 | regInfo.RegionLocX / Constants.RegionSize, regInfo.RegionLocY / Constants.RegionSize, | 347 | Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY), |
309 | region.RegionName, region.RegionID); | 348 | region.RegionName, region.RegionID); |
310 | reason = "Coordinates are already in use"; | 349 | reason = "Coordinates are already in use"; |
311 | return false; | 350 | return false; |
@@ -340,12 +379,25 @@ namespace OpenSim.Services.GridService | |||
340 | region = m_GridService.GetRegionByUUID(scopeID, regionID); | 379 | region = m_GridService.GetRegionByUUID(scopeID, regionID); |
341 | if (region != null) | 380 | if (region != null) |
342 | { | 381 | { |
343 | m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", | 382 | m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>", |
344 | region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize); | 383 | Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY)); |
345 | regInfo = region; | 384 | regInfo = region; |
346 | return true; | 385 | return true; |
347 | } | 386 | } |
348 | 387 | ||
388 | // We are now performing this check for each individual teleport in the EntityTransferModule instead. This | ||
389 | // allows us to give better feedback when teleports fail because of the distance reason (which can't be | ||
390 | // done here) and it also hypergrid teleports that are within range (possibly because the source grid | ||
391 | // itself has regions that are very far apart). | ||
392 | // uint x, y; | ||
393 | // if (m_Check4096 && !Check4096(handle, out x, out y)) | ||
394 | // { | ||
395 | // //RemoveHyperlinkRegion(regInfo.RegionID); | ||
396 | // reason = "Region is too far (" + x + ", " + y + ")"; | ||
397 | // m_log.Info("[HYPERGRID LINKER]: Unable to link, region is too far (" + x + ", " + y + ")"); | ||
398 | // //return false; | ||
399 | // } | ||
400 | |||
349 | regInfo.RegionID = regionID; | 401 | regInfo.RegionID = regionID; |
350 | 402 | ||
351 | if (externalName == string.Empty) | 403 | if (externalName == string.Empty) |
@@ -362,7 +414,8 @@ namespace OpenSim.Services.GridService | |||
362 | regInfo.RegionSecret = handle.ToString(); | 414 | regInfo.RegionSecret = handle.ToString(); |
363 | 415 | ||
364 | AddHyperlinkRegion(regInfo, handle); | 416 | AddHyperlinkRegion(regInfo, handle); |
365 | m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} with image {1}", regInfo.RegionName, regInfo.TerrainImage); | 417 | m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} at <{1},{2}> with image {3}", |
418 | regInfo.RegionName, Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY), regInfo.TerrainImage); | ||
366 | return true; | 419 | return true; |
367 | } | 420 | } |
368 | 421 | ||
@@ -371,7 +424,7 @@ namespace OpenSim.Services.GridService | |||
371 | m_log.DebugFormat("[HYPERGRID LINKER]: Request to unlink {0}", mapName); | 424 | m_log.DebugFormat("[HYPERGRID LINKER]: Request to unlink {0}", mapName); |
372 | GridRegion regInfo = null; | 425 | GridRegion regInfo = null; |
373 | 426 | ||
374 | List<RegionData> regions = m_Database.Get(mapName, m_ScopeID); | 427 | List<RegionData> regions = m_Database.Get(Util.EscapeForLike(mapName), m_ScopeID); |
375 | if (regions != null && regions.Count > 0) | 428 | if (regions != null && regions.Count > 0) |
376 | { | 429 | { |
377 | OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); | 430 | OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); |
@@ -395,6 +448,52 @@ namespace OpenSim.Services.GridService | |||
395 | } | 448 | } |
396 | } | 449 | } |
397 | 450 | ||
451 | // Not currently used | ||
452 | // /// <summary> | ||
453 | // /// Cope with this viewer limitation. | ||
454 | // /// </summary> | ||
455 | // /// <param name="regInfo"></param> | ||
456 | // /// <returns></returns> | ||
457 | // public bool Check4096(ulong realHandle, out uint x, out uint y) | ||
458 | // { | ||
459 | // uint ux = 0, uy = 0; | ||
460 | // Utils.LongToUInts(realHandle, out ux, out uy); | ||
461 | // x = Util.WorldToRegionLoc(ux); | ||
462 | // y = Util.WorldToRegionLoc(uy); | ||
463 | // | ||
464 | // const uint limit = Util.RegionToWorldLoc(4096 - 1); | ||
465 | // uint xmin = ux - limit; | ||
466 | // uint xmax = ux + limit; | ||
467 | // uint ymin = uy - limit; | ||
468 | // uint ymax = uy + limit; | ||
469 | // // World map boundary checks | ||
470 | // if (xmin < 0 || xmin > ux) | ||
471 | // xmin = 0; | ||
472 | // if (xmax > int.MaxValue || xmax < ux) | ||
473 | // xmax = int.MaxValue; | ||
474 | // if (ymin < 0 || ymin > uy) | ||
475 | // ymin = 0; | ||
476 | // if (ymax > int.MaxValue || ymax < uy) | ||
477 | // ymax = int.MaxValue; | ||
478 | // | ||
479 | // // Check for any regions that are within the possible teleport range to the linked region | ||
480 | // List<GridRegion> regions = m_GridService.GetRegionRange(m_ScopeID, (int)xmin, (int)xmax, (int)ymin, (int)ymax); | ||
481 | // if (regions.Count == 0) | ||
482 | // { | ||
483 | // return false; | ||
484 | // } | ||
485 | // else | ||
486 | // { | ||
487 | // // Check for regions which are not linked regions | ||
488 | // List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); | ||
489 | // IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks); | ||
490 | // if (availableRegions.Count() == 0) | ||
491 | // return false; | ||
492 | // } | ||
493 | // | ||
494 | // return true; | ||
495 | // } | ||
496 | |||
398 | private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) | 497 | private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) |
399 | { | 498 | { |
400 | RegionData rdata = m_GridService.RegionInfo2RegionData(regionInfo); | 499 | RegionData rdata = m_GridService.RegionInfo2RegionData(regionInfo); |
@@ -437,9 +536,14 @@ namespace OpenSim.Services.GridService | |||
437 | MainConsole.Instance.Output(new string('-', 72)); | 536 | MainConsole.Instance.Output(new string('-', 72)); |
438 | foreach (RegionData r in regions) | 537 | foreach (RegionData r in regions) |
439 | { | 538 | { |
440 | MainConsole.Instance.Output(String.Format("{0}\n{2,-32} {1}\n", | 539 | MainConsole.Instance.Output( |
441 | r.RegionName, r.RegionID, String.Format("{0},{1} ({2},{3})", r.posX, r.posY, | 540 | String.Format("{0}\n{2,-32} {1}\n", |
442 | r.posX / Constants.RegionSize, r.posY / Constants.RegionSize))); | 541 | r.RegionName, r.RegionID, |
542 | String.Format("{0},{1} ({2},{3})", r.posX, r.posY, | ||
543 | Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY) | ||
544 | ) | ||
545 | ) | ||
546 | ); | ||
443 | } | 547 | } |
444 | return; | 548 | return; |
445 | } | 549 | } |
@@ -464,8 +568,8 @@ namespace OpenSim.Services.GridService | |||
464 | int xloc, yloc; | 568 | int xloc, yloc; |
465 | string serverURI; | 569 | string serverURI; |
466 | string remoteName = null; | 570 | string remoteName = null; |
467 | xloc = Convert.ToInt32(cmdparams[0]) * (int)Constants.RegionSize; | 571 | xloc = (int)Util.RegionToWorldLoc((uint)Convert.ToInt32(cmdparams[0])); |
468 | yloc = Convert.ToInt32(cmdparams[1]) * (int)Constants.RegionSize; | 572 | yloc = (int)Util.RegionToWorldLoc((uint)Convert.ToInt32(cmdparams[1])); |
469 | serverURI = cmdparams[2]; | 573 | serverURI = cmdparams[2]; |
470 | if (cmdparams.Length > 3) | 574 | if (cmdparams.Length > 3) |
471 | remoteName = string.Join(" ", cmdparams, 3, cmdparams.Length - 3); | 575 | remoteName = string.Join(" ", cmdparams, 3, cmdparams.Length - 3); |
@@ -536,13 +640,13 @@ namespace OpenSim.Services.GridService | |||
536 | { | 640 | { |
537 | // old format | 641 | // old format |
538 | GridRegion regInfo; | 642 | GridRegion regInfo; |
539 | int xloc, yloc; | 643 | uint xloc, yloc; |
540 | uint externalPort; | 644 | uint externalPort; |
541 | string externalHostName; | 645 | string externalHostName; |
542 | try | 646 | try |
543 | { | 647 | { |
544 | xloc = Convert.ToInt32(cmdparams[0]); | 648 | xloc = Convert.ToUInt32(cmdparams[0]); |
545 | yloc = Convert.ToInt32(cmdparams[1]); | 649 | yloc = Convert.ToUInt32(cmdparams[1]); |
546 | externalPort = Convert.ToUInt32(cmdparams[3]); | 650 | externalPort = Convert.ToUInt32(cmdparams[3]); |
547 | externalHostName = cmdparams[2]; | 651 | externalHostName = cmdparams[2]; |
548 | //internalPort = Convert.ToUInt32(cmdparams[4]); | 652 | //internalPort = Convert.ToUInt32(cmdparams[4]); |
@@ -556,10 +660,11 @@ namespace OpenSim.Services.GridService | |||
556 | } | 660 | } |
557 | 661 | ||
558 | // Convert cell coordinates given by the user to meters | 662 | // Convert cell coordinates given by the user to meters |
559 | xloc = xloc * (int)Constants.RegionSize; | 663 | xloc = Util.RegionToWorldLoc(xloc); |
560 | yloc = yloc * (int)Constants.RegionSize; | 664 | yloc = Util.RegionToWorldLoc(yloc); |
561 | string reason = string.Empty; | 665 | string reason = string.Empty; |
562 | if (TryCreateLink(UUID.Zero, xloc, yloc, string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) | 666 | if (TryCreateLink(UUID.Zero, (int)xloc, (int)yloc, |
667 | string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) | ||
563 | { | 668 | { |
564 | // What is this? The GridRegion instance will be discarded anyway, | 669 | // What is this? The GridRegion instance will be discarded anyway, |
565 | // which effectively ignores any local name given with the command. | 670 | // which effectively ignores any local name given with the command. |
@@ -639,13 +744,13 @@ namespace OpenSim.Services.GridService | |||
639 | private void ReadLinkFromConfig(IConfig config) | 744 | private void ReadLinkFromConfig(IConfig config) |
640 | { | 745 | { |
641 | GridRegion regInfo; | 746 | GridRegion regInfo; |
642 | int xloc, yloc; | 747 | uint xloc, yloc; |
643 | uint externalPort; | 748 | uint externalPort; |
644 | string externalHostName; | 749 | string externalHostName; |
645 | uint realXLoc, realYLoc; | 750 | uint realXLoc, realYLoc; |
646 | 751 | ||
647 | xloc = Convert.ToInt32(config.GetString("xloc", "0")); | 752 | xloc = Convert.ToUInt32(config.GetString("xloc", "0")); |
648 | yloc = Convert.ToInt32(config.GetString("yloc", "0")); | 753 | yloc = Convert.ToUInt32(config.GetString("yloc", "0")); |
649 | externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); | 754 | externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); |
650 | externalHostName = config.GetString("externalHostName", ""); | 755 | externalHostName = config.GetString("externalHostName", ""); |
651 | realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); | 756 | realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); |
@@ -653,18 +758,19 @@ namespace OpenSim.Services.GridService | |||
653 | 758 | ||
654 | if (m_enableAutoMapping) | 759 | if (m_enableAutoMapping) |
655 | { | 760 | { |
656 | xloc = (int)((xloc % 100) + m_autoMappingX); | 761 | xloc = (xloc % 100) + m_autoMappingX; |
657 | yloc = (int)((yloc % 100) + m_autoMappingY); | 762 | yloc = (yloc % 100) + m_autoMappingY; |
658 | } | 763 | } |
659 | 764 | ||
660 | if (((realXLoc == 0) && (realYLoc == 0)) || | 765 | if (((realXLoc == 0) && (realYLoc == 0)) || |
661 | (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && | 766 | (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && |
662 | ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) | 767 | ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) |
663 | { | 768 | { |
664 | xloc = xloc * (int)Constants.RegionSize; | 769 | xloc = Util.RegionToWorldLoc(xloc); |
665 | yloc = yloc * (int)Constants.RegionSize; | 770 | yloc = Util.RegionToWorldLoc(yloc); |
666 | string reason = string.Empty; | 771 | string reason = string.Empty; |
667 | if (TryCreateLink(UUID.Zero, xloc, yloc, string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) | 772 | if (TryCreateLink(UUID.Zero, (int)xloc, (int)yloc, |
773 | string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) | ||
668 | { | 774 | { |
669 | regInfo.RegionName = config.GetString("localName", ""); | 775 | regInfo.RegionName = config.GetString("localName", ""); |
670 | } | 776 | } |