Add Avination's support for parcel eject and freeze

This commit is contained in:
Melanie
2013-04-25 00:24:48 +01:00
parent 1593d795ea
commit 6f3c905744
2 changed files with 110 additions and 15 deletions

View File

@@ -5138,9 +5138,14 @@ namespace OpenSim.Region.Framework.Scenes
get { return m_allowScriptCrossings; }
}
public Vector3? GetNearestAllowedPosition(ScenePresence avatar)
public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
{
ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
return GetNearestAllowedPosition(avatar, null);
}
public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
{
ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
if (nearestParcel != null)
{
@@ -5149,10 +5154,7 @@ namespace OpenSim.Region.Framework.Scenes
Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
if (nearestPoint != null)
{
// m_log.DebugFormat(
// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
return nearestPoint.Value;
}
@@ -5162,24 +5164,27 @@ namespace OpenSim.Region.Framework.Scenes
nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
if (nearestPoint != null)
{
// m_log.DebugFormat(
// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
return nearestPoint.Value;
}
//Ultimate backup if we have no idea where they are
// m_log.DebugFormat(
// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition);
ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
if (dest != excludeParcel)
{
// Ultimate backup if we have no idea where they are and
// the last allowed position was in another parcel
Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
return avatar.lastKnownAllowedPosition;
}
return avatar.lastKnownAllowedPosition;
// else fall through to region edge
}
//Go to the edge, this happens in teleporting to a region with no available parcels
Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar);
//Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString());
return nearestRegionEdgePoint;
}
@@ -5205,6 +5210,11 @@ namespace OpenSim.Region.Framework.Scenes
}
public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
{
return GetNearestAllowedParcel(avatarId, x, y, null);
}
public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
{
List<ILandObject> all = AllParcels();
float minParcelDistance = float.MaxValue;
@@ -5212,7 +5222,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (var parcel in all)
{
if (!parcel.IsEitherBannedOrRestricted(avatarId))
if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
{
float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
if (parcelDistance < minParcelDistance)