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.
This commit is contained in:
Robert Adams
2014-02-15 17:02:53 -08:00
parent 877bdcdce1
commit 7fc289c039
4 changed files with 51 additions and 22 deletions

View File

@@ -92,11 +92,12 @@ namespace OpenSim.Region.Framework.Interfaces
void EnableChildAgent(ScenePresence agent, GridRegion region);
GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out string version, out Vector3 newpos);
GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out string version,
out Vector3 newpos, out string reason);
void Cross(SceneObjectGroup sog, Vector3 position, bool silent);
ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version);
ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version);
}
public interface IUserAgentVerificationModule

View File

@@ -459,6 +459,7 @@ namespace OpenSim.Region.Framework.Scenes
IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
string version = String.Empty;
Vector3 newpos = Vector3.Zero;
string failureReason = String.Empty;
OpenSim.Services.Interfaces.GridRegion destination = null;
if (m_rootPart.KeyframeMotion != null)
@@ -476,7 +477,7 @@ namespace OpenSim.Region.Framework.Scenes
// We set the avatar position as being the object
// position to get the region to send to
if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out version, out newpos)) == null)
if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out version, out newpos, out failureReason)) == null)
{
canCross = false;
break;

View File

@@ -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<IRegionCombinerModule>();
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;
}
/// <summary>
/// Moves the agent outside the region bounds
/// Tells neighbor region that we're crossing to it