aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs81
1 files changed, 41 insertions, 40 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index b547317..230706e 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -51,15 +51,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
51 { 51 {
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 public const int DefaultMaxTransferDistance = 4095;
55
54 /// <summary> 56 /// <summary>
55 /// The maximum distance, in standard region units (256m) that an agent is allowed to transfer. 57 /// The maximum distance, in standard region units (256m) that an agent is allowed to transfer.
56 /// </summary> 58 /// </summary>
57 private int m_MaxTransferDistance = 4095; 59 public int MaxTransferDistance { get; set; }
58 public int MaxTransferDistance
59 {
60 get { return m_MaxTransferDistance; }
61 set { m_MaxTransferDistance = value; }
62 }
63 60
64 protected bool m_Enabled = false; 61 protected bool m_Enabled = false;
65 protected Scene m_aScene; 62 protected Scene m_aScene;
@@ -102,9 +99,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
102 { 99 {
103 IConfig transferConfig = source.Configs["EntityTransfer"]; 100 IConfig transferConfig = source.Configs["EntityTransfer"];
104 if (transferConfig != null) 101 if (transferConfig != null)
105 { 102 MaxTransferDistance = transferConfig.GetInt("max_distance", DefaultMaxTransferDistance);
106 MaxTransferDistance = transferConfig.GetInt("max_distance", 4095); 103 else
107 } 104 MaxTransferDistance = DefaultMaxTransferDistance;
108 105
109 m_agentsInTransit = new List<UUID>(); 106 m_agentsInTransit = new List<UUID>();
110 m_Enabled = true; 107 m_Enabled = true;
@@ -288,18 +285,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
288 return; 285 return;
289 } 286 }
290 287
291 uint curX = 0, curY = 0;
292 Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY);
293 int curCellX = (int)(curX / Constants.RegionSize);
294 int curCellY = (int)(curY / Constants.RegionSize);
295 int destCellX = (int)(finalDestination.RegionLocX / Constants.RegionSize);
296 int destCellY = (int)(finalDestination.RegionLocY / Constants.RegionSize);
297
298// m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Source co-ords are x={0} y={1}", curRegionX, curRegionY);
299//
300// m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final dest is x={0} y={1} {2}@{3}",
301// destRegionX, destRegionY, finalDestination.RegionID, finalDestination.ServerURI);
302
303 // Check that these are not the same coordinates 288 // Check that these are not the same coordinates
304 if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX && 289 if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX &&
305 finalDestination.RegionLocY == sp.Scene.RegionInfo.RegionLocY) 290 finalDestination.RegionLocY == sp.Scene.RegionInfo.RegionLocY)
@@ -309,18 +294,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
309 return; 294 return;
310 } 295 }
311 296
312 if (Math.Abs(curCellX - destCellX) > MaxTransferDistance || Math.Abs(curCellY - destCellY) > MaxTransferDistance)
313 {
314 sp.ControllingClient.SendTeleportFailed(
315 string.Format(
316 "Can't teleport to {0} ({1},{2}) from {3} ({4},{5}), destination is more than {6} regions way",
317 finalDestination.RegionName, destCellX, destCellY,
318 sp.Scene.RegionInfo.RegionName, curCellX, curCellY,
319 MaxTransferDistance));
320
321 return;
322 }
323
324 // 297 //
325 // This is it 298 // This is it
326 // 299 //
@@ -332,7 +305,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
332 else 305 else
333 { 306 {
334 finalDestination = null; 307 finalDestination = null;
335 308
336 // TP to a place that doesn't exist (anymore) 309 // TP to a place that doesn't exist (anymore)
337 // Inform the viewer about that 310 // Inform the viewer about that
338 sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore"); 311 sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
@@ -352,10 +325,44 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
352 } 325 }
353 } 326 }
354 327
328 /// <summary>
329 /// Determines whether this instance is within the max transfer distance.
330 /// </summary>
331 /// <param name="sourceRegion"></param>
332 /// <param name="destRegion"></param>
333 /// <returns>
334 /// <c>true</c> if this instance is within max transfer distance; otherwise, <c>false</c>.
335 /// </returns>
336 private bool IsWithinMaxTeleportDistance(RegionInfo sourceRegion, GridRegion destRegion)
337 {
338// m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Source co-ords are x={0} y={1}", curRegionX, curRegionY);
339//
340// m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final dest is x={0} y={1} {2}@{3}",
341// destRegionX, destRegionY, finalDestination.RegionID, finalDestination.ServerURI);
342
343 // Insanely, RegionLoc on RegionInfo is the 256m map co-ord whilst GridRegion.RegionLoc is the raw meters position.
344 return Math.Abs(sourceRegion.RegionLocX - destRegion.RegionCoordX) <= MaxTransferDistance
345 && Math.Abs(sourceRegion.RegionLocY - destRegion.RegionCoordY) <= MaxTransferDistance;
346 }
347
355 public void DoTeleport( 348 public void DoTeleport(
356 ScenePresence sp, GridRegion reg, GridRegion finalDestination, 349 ScenePresence sp, GridRegion reg, GridRegion finalDestination,
357 Vector3 position, Vector3 lookAt, uint teleportFlags) 350 Vector3 position, Vector3 lookAt, uint teleportFlags)
358 { 351 {
352 RegionInfo sourceRegion = sp.Scene.RegionInfo;
353
354 if (!IsWithinMaxTeleportDistance(sourceRegion, finalDestination))
355 {
356 sp.ControllingClient.SendTeleportFailed(
357 string.Format(
358 "Can't teleport to {0} ({1},{2}) from {3} ({4},{5}), destination is more than {6} regions way",
359 finalDestination.RegionName, finalDestination.RegionCoordX, finalDestination.RegionCoordY,
360 sourceRegion.RegionName, sourceRegion.RegionLocX, sourceRegion.RegionLocY,
361 MaxTransferDistance));
362
363 return;
364 }
365
359 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>(); 366 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
360 367
361 if (reg == null || finalDestination == null) 368 if (reg == null || finalDestination == null)
@@ -665,7 +672,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
665 672
666 protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) 673 protected virtual bool IsOutsideRegion(Scene s, Vector3 pos)
667 { 674 {
668
669 if (s.TestBorderCross(pos, Cardinals.N)) 675 if (s.TestBorderCross(pos, Cardinals.N))
670 return true; 676 return true;
671 if (s.TestBorderCross(pos, Cardinals.S)) 677 if (s.TestBorderCross(pos, Cardinals.S))
@@ -806,7 +812,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
806 neighboury = ba.TriggerRegionY; 812 neighboury = ba.TriggerRegionY;
807 neighbourx = ba.TriggerRegionX; 813 neighbourx = ba.TriggerRegionX;
808 814
809
810 Vector3 newposition = pos; 815 Vector3 newposition = pos;
811 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; 816 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
812 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; 817 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
@@ -814,7 +819,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
814 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); 819 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
815 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); 820 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
816 821
817
818 return true; 822 return true;
819 } 823 }
820 824
@@ -854,8 +858,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
854 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize); 858 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize);
855 newpos.Y = enterDistance; 859 newpos.Y = enterDistance;
856 } 860 }
857
858
859 } 861 }
860 else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) 862 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
861 { 863 {
@@ -882,7 +884,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
882 } 884 }
883 else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 885 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
884 { 886 {
885
886 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); 887 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
887 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); 888 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
888 newpos.Y = enterDistance; 889 newpos.Y = enterDistance;