Move max teleport distance check down into etm.DoTeleport() since this should apply to all teleport calls, not just those through Teleport()
parent
25983f20a0
commit
c3ae90c067
|
@ -51,15 +51,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
public const int DefaultMaxTransferDistance = 4095;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum distance, in standard region units (256m) that an agent is allowed to transfer.
|
/// The maximum distance, in standard region units (256m) that an agent is allowed to transfer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int m_MaxTransferDistance = 4095;
|
public int MaxTransferDistance { get; set; }
|
||||||
public int MaxTransferDistance
|
|
||||||
{
|
|
||||||
get { return m_MaxTransferDistance; }
|
|
||||||
set { m_MaxTransferDistance = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
protected bool m_Enabled = false;
|
protected bool m_Enabled = false;
|
||||||
protected Scene m_aScene;
|
protected Scene m_aScene;
|
||||||
|
@ -102,7 +99,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
{
|
{
|
||||||
IConfig transferConfig = source.Configs["EntityTransfer"];
|
IConfig transferConfig = source.Configs["EntityTransfer"];
|
||||||
if (transferConfig != null)
|
if (transferConfig != null)
|
||||||
MaxTransferDistance = transferConfig.GetInt("max_distance", 4095);
|
MaxTransferDistance = transferConfig.GetInt("max_distance", DefaultMaxTransferDistance);
|
||||||
|
else
|
||||||
|
MaxTransferDistance = DefaultMaxTransferDistance;
|
||||||
|
|
||||||
m_agentsInTransit = new List<UUID>();
|
m_agentsInTransit = new List<UUID>();
|
||||||
m_Enabled = true;
|
m_Enabled = true;
|
||||||
|
@ -280,18 +279,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint curX = 0, curY = 0;
|
|
||||||
Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY);
|
|
||||||
int curCellX = (int)(curX / Constants.RegionSize);
|
|
||||||
int curCellY = (int)(curY / Constants.RegionSize);
|
|
||||||
int destCellX = (int)(finalDestination.RegionLocX / Constants.RegionSize);
|
|
||||||
int destCellY = (int)(finalDestination.RegionLocY / Constants.RegionSize);
|
|
||||||
|
|
||||||
// m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Source co-ords are x={0} y={1}", curRegionX, curRegionY);
|
|
||||||
//
|
|
||||||
// m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final dest is x={0} y={1} {2}@{3}",
|
|
||||||
// destRegionX, destRegionY, finalDestination.RegionID, finalDestination.ServerURI);
|
|
||||||
|
|
||||||
// Check that these are not the same coordinates
|
// Check that these are not the same coordinates
|
||||||
if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX &&
|
if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX &&
|
||||||
finalDestination.RegionLocY == sp.Scene.RegionInfo.RegionLocY)
|
finalDestination.RegionLocY == sp.Scene.RegionInfo.RegionLocY)
|
||||||
|
@ -301,18 +288,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.Abs(curCellX - destCellX) > MaxTransferDistance || Math.Abs(curCellY - destCellY) > MaxTransferDistance)
|
|
||||||
{
|
|
||||||
sp.ControllingClient.SendTeleportFailed(
|
|
||||||
string.Format(
|
|
||||||
"Can't teleport to {0} ({1},{2}) from {3} ({4},{5}), destination is more than {6} regions way",
|
|
||||||
finalDestination.RegionName, destCellX, destCellY,
|
|
||||||
sp.Scene.RegionInfo.RegionName, curCellX, curCellY,
|
|
||||||
MaxTransferDistance));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// This is it
|
// This is it
|
||||||
//
|
//
|
||||||
|
@ -324,7 +299,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
finalDestination = null;
|
finalDestination = null;
|
||||||
|
|
||||||
// TP to a place that doesn't exist (anymore)
|
// TP to a place that doesn't exist (anymore)
|
||||||
// Inform the viewer about that
|
// Inform the viewer about that
|
||||||
sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
|
sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
|
||||||
|
@ -344,10 +319,44 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether this instance is within the max transfer distance.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourceRegion"></param>
|
||||||
|
/// <param name="destRegion"></param>
|
||||||
|
/// <returns>
|
||||||
|
/// <c>true</c> if this instance is within max transfer distance; otherwise, <c>false</c>.
|
||||||
|
/// </returns>
|
||||||
|
private bool IsWithinMaxTeleportDistance(RegionInfo sourceRegion, GridRegion destRegion)
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Source co-ords are x={0} y={1}", curRegionX, curRegionY);
|
||||||
|
//
|
||||||
|
// m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final dest is x={0} y={1} {2}@{3}",
|
||||||
|
// destRegionX, destRegionY, finalDestination.RegionID, finalDestination.ServerURI);
|
||||||
|
|
||||||
|
// Insanely, RegionLoc on RegionInfo is the 256m map co-ord whilst GridRegion.RegionLoc is the raw meters position.
|
||||||
|
return Math.Abs(sourceRegion.RegionLocX - destRegion.RegionCoordX) <= MaxTransferDistance
|
||||||
|
&& Math.Abs(sourceRegion.RegionLocY - destRegion.RegionCoordY) <= MaxTransferDistance;
|
||||||
|
}
|
||||||
|
|
||||||
public void DoTeleport(
|
public void DoTeleport(
|
||||||
ScenePresence sp, GridRegion reg, GridRegion finalDestination,
|
ScenePresence sp, GridRegion reg, GridRegion finalDestination,
|
||||||
Vector3 position, Vector3 lookAt, uint teleportFlags)
|
Vector3 position, Vector3 lookAt, uint teleportFlags)
|
||||||
{
|
{
|
||||||
|
RegionInfo sourceRegion = sp.Scene.RegionInfo;
|
||||||
|
|
||||||
|
if (!IsWithinMaxTeleportDistance(sourceRegion, finalDestination))
|
||||||
|
{
|
||||||
|
sp.ControllingClient.SendTeleportFailed(
|
||||||
|
string.Format(
|
||||||
|
"Can't teleport to {0} ({1},{2}) from {3} ({4},{5}), destination is more than {6} regions way",
|
||||||
|
finalDestination.RegionName, finalDestination.RegionCoordX, finalDestination.RegionCoordY,
|
||||||
|
sourceRegion.RegionName, sourceRegion.RegionLocX, sourceRegion.RegionLocY,
|
||||||
|
MaxTransferDistance));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
|
IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
|
||||||
|
|
||||||
if (reg == null || finalDestination == null)
|
if (reg == null || finalDestination == null)
|
||||||
|
@ -657,7 +666,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
|
|
||||||
protected virtual bool IsOutsideRegion(Scene s, Vector3 pos)
|
protected virtual bool IsOutsideRegion(Scene s, Vector3 pos)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (s.TestBorderCross(pos, Cardinals.N))
|
if (s.TestBorderCross(pos, Cardinals.N))
|
||||||
return true;
|
return true;
|
||||||
if (s.TestBorderCross(pos, Cardinals.S))
|
if (s.TestBorderCross(pos, Cardinals.S))
|
||||||
|
@ -798,7 +806,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
neighboury = ba.TriggerRegionY;
|
neighboury = ba.TriggerRegionY;
|
||||||
neighbourx = ba.TriggerRegionX;
|
neighbourx = ba.TriggerRegionX;
|
||||||
|
|
||||||
|
|
||||||
Vector3 newposition = pos;
|
Vector3 newposition = pos;
|
||||||
newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
|
newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
|
||||||
newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
|
newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
|
||||||
|
@ -806,7 +813,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
|
String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
|
||||||
InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
|
InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,8 +852,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize);
|
neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize);
|
||||||
newpos.Y = enterDistance;
|
newpos.Y = enterDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
|
else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
|
||||||
{
|
{
|
||||||
|
@ -874,7 +878,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
}
|
}
|
||||||
else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
|
else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
|
||||||
{
|
{
|
||||||
|
|
||||||
Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
|
Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
|
||||||
neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
|
neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
|
||||||
newpos.Y = enterDistance;
|
newpos.Y = enterDistance;
|
||||||
|
|
Loading…
Reference in New Issue