From 7fc289c039ca3cdbad0f050e17c1b1d13e684c73 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 15 Feb 2014 17:02:53 -0800 Subject: Properly restore position on crossing failure for mega-regions. Fix odd "cannot cross into banned parcel" viewer error message when crossing into non-existant region. Proper permission failure messages are now returned. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 46 ++++++++++++++++-------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 576b8c2..d4af9fc 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3473,8 +3473,6 @@ namespace OpenSim.Region.Framework.Scenes Vector3 pos2 = AbsolutePosition; Vector3 origPosition = pos2; Vector3 vel = Velocity; - int neighbor = 0; - int[] fix = new int[2]; // Compute the avatar position in the next physics tick. // If the avatar will be crossing, we force the crossing to happen now @@ -3507,23 +3505,13 @@ namespace OpenSim.Region.Framework.Scenes if (m_requestedSitTargetUUID == UUID.Zero) { m_log.DebugFormat("{0} CheckForBorderCrossing: Crossing failed. Restoring old position.", LogHeader); - const float borderFudge = 0.1f; - - if (origPosition.X < 0) - origPosition.X = borderFudge; - else if (origPosition.X > (float)m_scene.RegionInfo.RegionSizeX) - origPosition.X = (float)m_scene.RegionInfo.RegionSizeX - borderFudge; - if (origPosition.Y < 0) - origPosition.Y = borderFudge; - else if (origPosition.Y > (float)m_scene.RegionInfo.RegionSizeY) - origPosition.Y = (float)m_scene.RegionInfo.RegionSizeY - borderFudge; + Velocity = Vector3.Zero; - AbsolutePosition = origPosition; + AbsolutePosition = EnforceSanityOnPosition(origPosition); AddToPhysicalScene(isFlying); } } - } } else @@ -3541,6 +3529,36 @@ namespace OpenSim.Region.Framework.Scenes } } + // Given a position, make sure it is within the current region. + // If just outside some border, the returned position will be just inside the border on that side. + private Vector3 EnforceSanityOnPosition(Vector3 origPosition) + { + const float borderFudge = 0.1f; + Vector3 ret = origPosition; + + // Sanity checking on the position to make sure it is in the region we couldn't cross from + float extentX = (float)m_scene.RegionInfo.RegionSizeX; + float extentY = (float)m_scene.RegionInfo.RegionSizeY; + IRegionCombinerModule combiner = m_scene.RequestModuleInterface(); + if (combiner != null) + { + // If a mega-region, the size could be much bigger + Vector2 megaExtent = combiner.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID); + extentX = megaExtent.X; + extentY = megaExtent.Y; + } + if (ret.X < 0) + ret.X = borderFudge; + else if (ret.X >= extentX) + ret.X = extentX - borderFudge; + if (ret.Y < 0) + ret.Y = borderFudge; + else if (ret.Y >= extentY) + ret.Y = extentY - borderFudge; + + return ret; + } + /// /// Moves the agent outside the region bounds /// Tells neighbor region that we're crossing to it -- cgit v1.1